Skip to content

Commit

Permalink
test: Update goldens due to changes in test framework;
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed Jul 3, 2024
1 parent b5b61bb commit 4fb7508
Show file tree
Hide file tree
Showing 50 changed files with 28 additions and 17 deletions.
4 changes: 3 additions & 1 deletion lib/src/utils/rounded.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -68,7 +70,7 @@ extension Rounded on BuildContext {
return (widget as dynamic).rounded as bool;
}
} catch (e) {
debugPrint('Widget does not have rounded');
log('Widget(${widget.runtimeType}) does not have rounded \n $e');
}

return ZetaRoundedScope.of(this)?._rounded ?? Zeta.of(this).rounded;
Expand Down
34 changes: 21 additions & 13 deletions lib/src/zeta_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,17 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
late ThemeMode _themeMode;

/// Represents the late initialization of the ZetaThemeData object.
late ZetaThemeData _themeData;
late ZetaThemeData _zetaThemeData;

/// Represents the late initialization of the system's current brightness (dark or light mode).
late Brightness _platformBrightness;

/// {@macro zeta-component-rounded}
late bool _rounded;

/// Represents the late initialization of the ThemeData object.
late ThemeData? _themeData;

/// Represents a nullable brightness value to be used for brightness change debouncing.
Brightness? _debounceBrightness;

Expand Down Expand Up @@ -188,7 +192,10 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
_rounded = widget.initialRounded;

// Apply the initial contrast to the theme data.
_themeData = widget.initialZetaThemeData.apply(contrast: _contrast);
_zetaThemeData = widget.initialZetaThemeData.apply(contrast: _contrast);

// Set the initial theme data.
_themeData = widget.initialThemeData;
}

/// Clean up function to be called when this object is removed from the tree.
Expand Down Expand Up @@ -241,19 +248,19 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
if (widget.baseBuilder != _emptyBase) {
return Zeta(
themeMode: _themeMode,
themeData: _themeData,
themeData: _zetaThemeData,
contrast: _contrast,
mediaBrightness: _platformBrightness,
rounded: _rounded,
child: widget.baseBuilder(
context,
generateZetaTheme(
brightness: Brightness.light,
existingTheme: ThemeData(colorScheme: _themeData.colorsLight.toScheme()),
existingTheme: _themeData ?? ThemeData(colorScheme: _zetaThemeData.colorsLight.toScheme()),
),
generateZetaTheme(
brightness: Brightness.dark,
existingTheme: ThemeData(colorScheme: _themeData.colorsDark.toScheme()),
existingTheme: _themeData ?? ThemeData(colorScheme: _zetaThemeData.colorsDark.toScheme()),
),
_themeMode,
),
Expand All @@ -262,11 +269,11 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets

return Zeta(
themeMode: _themeMode,
themeData: _themeData,
themeData: _zetaThemeData,
contrast: _contrast,
rounded: _rounded,
mediaBrightness: _platformBrightness,
child: widget.builder(context, _themeData, _themeMode),
child: widget.builder(context, _zetaThemeData, _themeMode),
);
}

Expand All @@ -276,11 +283,13 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
if (oldWidget.initialContrast != widget.initialContrast ||
oldWidget.initialThemeMode != widget.initialThemeMode ||
oldWidget.initialThemeData != widget.initialThemeData ||
oldWidget.initialZetaThemeData != widget.initialZetaThemeData ||
oldWidget.initialRounded != widget.initialRounded) {
setState(() {
_themeMode = widget.initialThemeMode;
_contrast = widget.initialContrast;
_themeData = widget.initialZetaThemeData.apply(contrast: _contrast);
_zetaThemeData = widget.initialZetaThemeData.apply(contrast: _contrast);
_themeData = widget.initialThemeData;
_rounded = widget.initialRounded;
});
}
Expand All @@ -297,7 +306,7 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
/// Updates the current theme data.
void updateThemeData(ZetaThemeData data) {
setState(() {
_themeData = data.apply(contrast: _contrast);
_zetaThemeData = data.apply(contrast: _contrast);
_saveThemeChange();
});
}
Expand All @@ -306,15 +315,14 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
void updateContrast(ZetaContrast contrast) {
setState(() {
_contrast = contrast;
_themeData = _themeData.apply(contrast: contrast);
_zetaThemeData = _zetaThemeData.apply(contrast: contrast);
_saveThemeChange();
});
}

/// Updates the current rounded.
// ignore: avoid_positional_boolean_parameters
void updateRounded(bool rounded) {
//TODO: This is not triggering rebuild
setState(() {
_rounded = rounded;
_saveThemeChange();
Expand All @@ -324,7 +332,7 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
void _saveThemeChange() {
unawaited(
widget.themeService?.saveTheme(
themeData: _themeData,
themeData: _zetaThemeData,
themeMode: _themeMode,
contrast: _contrast,
),
Expand All @@ -335,7 +343,7 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty<ZetaThemeData>('themeData', _themeData))
..add(DiagnosticsProperty<ZetaThemeData>('themeData', _zetaThemeData))
..add(EnumProperty<ZetaContrast>('contrast', _contrast))
..add(EnumProperty<ThemeMode>('themeMode', _themeMode));
}
Expand Down
Binary file modified test/src/components/badge/golden/indicator_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/indicator_icon_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/indicator_icon_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_negative.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_neutral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_positive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_sharp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/priority_pill_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/priority_pill_high.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/priority_pill_low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/priority_pill_medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/status_label_custom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/status_label_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/tag_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/tag_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_negative.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_outline_subtle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_positive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_primary.png
Binary file modified test/src/components/button/golden/button_secondary.png
Binary file modified test/src/components/button/golden/button_text.png
Binary file modified test/src/components/checkbox/golden/checkbox_disabled.png
Binary file modified test/src/components/checkbox/golden/checkbox_enabled.png
Binary file modified test/src/components/dialpad/golden/dialpad_disabled.png
Binary file modified test/src/components/dialpad/golden/dialpad_enabled.png
Binary file modified test/src/components/dialpad/golden/dialpadbutton.png
Binary file modified test/src/components/fabs/golden/FAB_default.png
Binary file modified test/src/components/fabs/golden/FAB_inverse.png
Binary file modified test/src/components/fabs/golden/FAB_secondary.png
Binary file modified test/src/components/password/golden/password_default.png
Binary file modified test/src/components/password/golden/password_error.png
Binary file modified test/src/components/tooltip/golden/arrow_down.png
Binary file modified test/src/components/tooltip/golden/arrow_left.png
Binary file modified test/src/components/tooltip/golden/arrow_right.png
Binary file modified test/src/components/tooltip/golden/arrow_up.png
6 changes: 3 additions & 3 deletions test/src/zeta_provider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
final providerState = tester.state<ZetaProviderState>(find.byType(ZetaProvider));
expect(providerState.widget.initialThemeMode, ThemeMode.system);
expect(providerState.widget.initialContrast, ZetaContrast.aa);
expect(providerState.widget.initialThemeData, isNotNull);
expect(providerState.widget.initialZetaThemeData, isNotNull);
});

testWidgets('initializes with provided values', (WidgetTester tester) async {
Expand All @@ -42,7 +42,7 @@ void main() {
final providerState = tester.state<ZetaProviderState>(find.byType(ZetaProvider));
expect(providerState.widget.initialThemeMode, ThemeMode.light);
expect(providerState.widget.initialContrast, ZetaContrast.aaa);
expect(providerState.widget.initialThemeData, initialThemeData);
expect(providerState.widget.initialZetaThemeData, initialThemeData);
expect(providerState.widget.themeService, mockThemeService);
});

Expand Down Expand Up @@ -216,7 +216,7 @@ void main() {
),
),
);

//TODO: This does not work as expected
await tester.pumpAndSettle(const Duration(milliseconds: 250));

// Verifying through the public interface of Zeta widget
Expand Down
1 change: 1 addition & 0 deletions test/test_utils/test_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TestApp extends StatelessWidget {
Widget build(BuildContext context) {
return ZetaProvider.base(
initialThemeMode: themeMode ?? ThemeMode.system,
initialRounded: rounded ?? true,
builder: (context, lightTheme, darkTheme, themeMode) {
return MaterialApp(
theme: lightTheme,
Expand Down

0 comments on commit 4fb7508

Please sign in to comment.