@@ -76,14 +76,48 @@ void main() {
76
76
button: TextButton (onPressed: () {}, child: const Text (buttonText)));
77
77
});
78
78
79
+ group ('DesignVariables' , () {
80
+ group ('lerp' , () {
81
+ testWidgets ('light -> light' , (tester) async {
82
+ final a = DesignVariables .light ();
83
+ final b = DesignVariables .light ();
84
+ check (() => a.lerp (b, 0.5 )).returnsNormally ();
85
+ });
86
+
87
+ testWidgets ('light -> dark' , (tester) async {
88
+ final a = DesignVariables .light ();
89
+ final b = DesignVariables .dark ();
90
+ check (() => a.lerp (b, 0.5 )).returnsNormally ();
91
+ });
92
+
93
+ testWidgets ('dark -> light' , (tester) async {
94
+ final a = DesignVariables .dark ();
95
+ final b = DesignVariables .light ();
96
+ check (() => a.lerp (b, 0.5 )).returnsNormally ();
97
+ });
98
+
99
+ testWidgets ('dark -> dark' , (tester) async {
100
+ final a = DesignVariables .dark ();
101
+ final b = DesignVariables .dark ();
102
+ check (() => a.lerp (b, 0.5 )).returnsNormally ();
103
+ });
104
+ });
105
+ });
106
+
79
107
group ('colorSwatchFor' , () {
80
108
const baseColor = 0xff76ce90 ;
81
109
82
- testWidgets ('light $ baseColor ' , (WidgetTester tester) async {
110
+ testWidgets ('light–dark animation ' , (WidgetTester tester) async {
83
111
addTearDown (testBinding.reset);
84
112
85
113
final subscription = eg.subscription (eg.stream (), color: baseColor);
86
114
115
+ assert (! debugFollowPlatformBrightness); // to be removed with #95
116
+ debugFollowPlatformBrightness = true ;
117
+ addTearDown (() { debugFollowPlatformBrightness = false ; });
118
+ tester.platformDispatcher.platformBrightnessTestValue = Brightness .light;
119
+ addTearDown (tester.platformDispatcher.clearPlatformBrightnessTestValue);
120
+
87
121
await tester.pumpWidget (const ZulipApp ());
88
122
await tester.pump ();
89
123
@@ -96,8 +130,20 @@ void main() {
96
130
// Compares all the swatch's members; see [ColorSwatch]'s `operator ==`.
97
131
check (colorSwatchFor (element, subscription))
98
132
.equals (StreamColorSwatch .light (baseColor));
99
- });
100
133
101
- // TODO(#95) test with Brightness.dark and lerping between light/dark
134
+ tester.platformDispatcher.platformBrightnessTestValue = Brightness .dark;
135
+ await tester.pump ();
136
+
137
+ await tester.pump (kThemeAnimationDuration * 0.4 );
138
+ check (colorSwatchFor (element, subscription))
139
+ .equals (StreamColorSwatch .lerp (
140
+ StreamColorSwatch .light (baseColor),
141
+ StreamColorSwatch .dark (baseColor),
142
+ 0.4 )! );
143
+
144
+ await tester.pump (kThemeAnimationDuration * 0.6 );
145
+ check (colorSwatchFor (element, subscription))
146
+ .equals (StreamColorSwatch .dark (baseColor));
147
+ });
102
148
});
103
149
}
0 commit comments