@@ -76,14 +76,46 @@ 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
+ debugFollowPlatformBrightness = true ;
116
+ tester.platformDispatcher.platformBrightnessTestValue = Brightness .light;
117
+ addTearDown (tester.platformDispatcher.clearPlatformBrightnessTestValue);
118
+
87
119
await tester.pumpWidget (const ZulipApp ());
88
120
await tester.pump ();
89
121
@@ -96,8 +128,19 @@ void main() {
96
128
// Compares all the swatch's members; see [ColorSwatch]'s `operator ==`.
97
129
check (colorSwatchFor (element, subscription))
98
130
.equals (StreamColorSwatch .light (baseColor));
99
- });
100
131
101
- // TODO(#95) test with Brightness.dark and lerping between light/dark
132
+ tester.platformDispatcher.platformBrightnessTestValue = Brightness .dark;
133
+ await tester.pump ();
134
+
135
+ await tester.pump (kThemeAnimationDuration * 0.4 );
136
+ final expectedLerped = StreamColorSwatch .lerp (
137
+ StreamColorSwatch .light (baseColor),
138
+ StreamColorSwatch .dark (baseColor),
139
+ 0.4 )! ;
140
+ check (colorSwatchFor (element, subscription)).equals (expectedLerped);
141
+
142
+ await tester.pump (kThemeAnimationDuration * 0.6 );
143
+ check (colorSwatchFor (element, subscription)).equals (StreamColorSwatch .dark (baseColor));
144
+ });
102
145
});
103
146
}
0 commit comments