|
1 | 1 | import 'package:checks/checks.dart'; |
2 | | -import 'package:flutter/foundation.dart'; |
3 | 2 | import 'package:flutter/widgets.dart'; |
4 | 3 | import 'package:flutter_test/flutter_test.dart'; |
5 | 4 | import 'package:zulip/api/core.dart'; |
@@ -199,107 +198,59 @@ void main() { |
199 | 198 | }); |
200 | 199 | }); |
201 | 200 |
|
202 | | - group('ImageAnimationMode.shouldAnimate', () { |
| 201 | +group('ImageAnimationMode.shouldAnimate', () { |
203 | 202 |
|
204 | | - testWidgets('animateAlways returns true', (tester) async { |
205 | | - await tester.pumpWidget(const Placeholder()); |
206 | | - final context = tester.element(find.byType(Placeholder)); |
207 | | - |
208 | | - expect( |
209 | | - ImageAnimationMode.animateAlways.shouldAnimate(context), |
210 | | - true, |
211 | | - ); |
212 | | - }); |
213 | | - |
214 | | - testWidgets('animateNever returns false', (tester) async { |
215 | | - await tester.pumpWidget(const Placeholder()); |
216 | | - final context = tester.element(find.byType(Placeholder)); |
217 | | - |
218 | | - expect( |
219 | | - ImageAnimationMode.animateNever.shouldAnimate(context), |
220 | | - false, |
221 | | - ); |
222 | | - }); |
223 | | - |
224 | | - testWidgets('returns false when MediaQuery disables animations', (tester) async { |
225 | | - await tester.pumpWidget( |
226 | | - const MediaQuery( |
227 | | - data: MediaQueryData(disableAnimations: true), |
228 | | - child: Placeholder(), |
229 | | - ), |
230 | | - ); |
231 | | - |
232 | | - final context = tester.element(find.byType(Placeholder)); |
233 | | - |
234 | | - expect( |
235 | | - ImageAnimationMode.animateConditionally.shouldAnimate(context), |
236 | | - false, |
237 | | - ); |
238 | | - }); |
239 | | - |
240 | | - testWidgets('returns true when animations are allowed', (tester) async { |
241 | | - await tester.pumpWidget( |
242 | | - const MediaQuery( |
243 | | - data: MediaQueryData(disableAnimations: false), |
244 | | - child: Placeholder(), |
245 | | - ), |
246 | | - ); |
247 | | - |
248 | | - final context = tester.element(find.byType(Placeholder)); |
| 203 | + testWidgets('animateAlways returns true', (tester) async { |
| 204 | + await tester.pumpWidget(const Placeholder()); |
| 205 | + final context = tester.element(find.byType(Placeholder)); |
249 | 206 |
|
250 | | - expect( |
251 | | - ImageAnimationMode.animateConditionally.shouldAnimate(context), |
252 | | - true, |
253 | | - ); |
254 | | - }); |
255 | | - |
256 | | - testWidgets('returns false on iOS when reduceMotion is enabled', (tester) async { |
257 | | - debugDefaultTargetPlatformOverride = TargetPlatform.iOS; |
258 | | - |
259 | | - tester.binding.platformDispatcher.accessibilityFeaturesTestValue = |
260 | | - const FakeAccessibilityFeatures(reduceMotion: true); |
261 | | - |
262 | | - await tester.pumpWidget( |
263 | | - const MediaQuery( |
264 | | - data: MediaQueryData(disableAnimations: false), |
265 | | - child: Placeholder(), |
266 | | - ), |
267 | | - ); |
268 | | - |
269 | | - final context = tester.element(find.byType(Placeholder)); |
270 | | - |
271 | | - expect( |
272 | | - ImageAnimationMode.animateConditionally.shouldAnimate(context), |
273 | | - false, |
274 | | - ); |
| 207 | + expect( |
| 208 | + ImageAnimationMode.animateAlways.shouldAnimate(context), |
| 209 | + true, |
| 210 | + ); |
| 211 | + }); |
275 | 212 |
|
276 | | - debugDefaultTargetPlatformOverride = null; |
277 | | - tester.binding.platformDispatcher.clearAccessibilityFeaturesTestValue(); |
278 | | - }); |
| 213 | + testWidgets('animateNever returns false', (tester) async { |
| 214 | + await tester.pumpWidget(const Placeholder()); |
| 215 | + final context = tester.element(find.byType(Placeholder)); |
279 | 216 |
|
280 | | - testWidgets('returns false on iOS when autoPlayAnimatedImages is disabled', (tester) async { |
281 | | - debugDefaultTargetPlatformOverride = TargetPlatform.iOS; |
| 217 | + expect( |
| 218 | + ImageAnimationMode.animateNever.shouldAnimate(context), |
| 219 | + false, |
| 220 | + ); |
| 221 | + }); |
282 | 222 |
|
283 | | - tester.binding.platformDispatcher.accessibilityFeaturesTestValue = |
284 | | - const FakeAccessibilityFeatures(autoPlayAnimatedImages: false); |
| 223 | + testWidgets('returns false when MediaQuery disables animations', (tester) async { |
| 224 | + await tester.pumpWidget( |
| 225 | + const MediaQuery( |
| 226 | + data: MediaQueryData(disableAnimations: true), |
| 227 | + child: Placeholder(), |
| 228 | + ), |
| 229 | + ); |
285 | 230 |
|
286 | | - await tester.pumpWidget( |
287 | | - const MediaQuery( |
288 | | - data: MediaQueryData(disableAnimations: false), |
289 | | - child: Placeholder(), |
290 | | - ), |
291 | | - ); |
| 231 | + final context = tester.element(find.byType(Placeholder)); |
292 | 232 |
|
293 | | - final context = tester.element(find.byType(Placeholder)); |
| 233 | + expect( |
| 234 | + ImageAnimationMode.animateConditionally.shouldAnimate(context), |
| 235 | + false, |
| 236 | + ); |
| 237 | + }); |
294 | 238 |
|
295 | | - expect( |
296 | | - ImageAnimationMode.animateConditionally.shouldAnimate(context), |
297 | | - false, |
298 | | - ); |
| 239 | + testWidgets('returns true when animations are allowed', (tester) async { |
| 240 | + await tester.pumpWidget( |
| 241 | + const MediaQuery( |
| 242 | + data: MediaQueryData(disableAnimations: false), |
| 243 | + child: Placeholder(), |
| 244 | + ), |
| 245 | + ); |
299 | 246 |
|
300 | | - debugDefaultTargetPlatformOverride = null; |
301 | | - tester.binding.platformDispatcher.clearAccessibilityFeaturesTestValue(); |
302 | | - }); |
| 247 | + final context = tester.element(find.byType(Placeholder)); |
303 | 248 |
|
| 249 | + expect( |
| 250 | + ImageAnimationMode.animateConditionally.shouldAnimate(context), |
| 251 | + true, |
| 252 | + ); |
304 | 253 | }); |
| 254 | + |
| 255 | +}); |
305 | 256 | } |
0 commit comments