@@ -76,14 +76,48 @@ void main() {
7676 button: TextButton (onPressed: () {}, child: const Text (buttonText)));
7777 });
7878
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+
79107 group ('colorSwatchFor' , () {
80108 const baseColor = 0xff76ce90 ;
81109
82- testWidgets ('light $ baseColor ' , (WidgetTester tester) async {
110+ testWidgets ('light–dark animation ' , (WidgetTester tester) async {
83111 addTearDown (testBinding.reset);
84112
85113 final subscription = eg.subscription (eg.stream (), color: baseColor);
86114
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+
87121 await tester.pumpWidget (const ZulipApp ());
88122 await tester.pump ();
89123
@@ -96,8 +130,20 @@ void main() {
96130 // Compares all the swatch's members; see [ColorSwatch]'s `operator ==`.
97131 check (colorSwatchFor (element, subscription))
98132 .equals (StreamColorSwatch .light (baseColor));
99- });
100133
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+ });
102148 });
103149}
0 commit comments