|
| 1 | +import 'package:flutter/animation.dart'; |
| 2 | +import 'package:flutter_test/flutter_test.dart'; |
| 3 | +import 'package:querya_desktop/core/motion/querya_motion.dart'; |
| 4 | +import 'package:querya_desktop/core/motion/querya_motion_scope.dart'; |
| 5 | +import 'package:querya_desktop/core/motion/querya_theme_motion.dart'; |
| 6 | + |
| 7 | +void main() { |
| 8 | + group('QueryaThemeMotion.duration', () { |
| 9 | + test('instant when preference disabled', () { |
| 10 | + expect( |
| 11 | + QueryaThemeMotion.duration( |
| 12 | + preferenceEnabled: false, |
| 13 | + level: QueryaMotionLevel.full, |
| 14 | + ), |
| 15 | + QueryaMotion.instant, |
| 16 | + ); |
| 17 | + }); |
| 18 | + |
| 19 | + test('instant when motion off', () { |
| 20 | + expect( |
| 21 | + QueryaThemeMotion.duration( |
| 22 | + preferenceEnabled: true, |
| 23 | + level: QueryaMotionLevel.off, |
| 24 | + ), |
| 25 | + QueryaMotion.instant, |
| 26 | + ); |
| 27 | + }); |
| 28 | + |
| 29 | + test('instant when OS disables animations', () { |
| 30 | + expect( |
| 31 | + QueryaThemeMotion.duration( |
| 32 | + preferenceEnabled: true, |
| 33 | + level: QueryaMotionLevel.full, |
| 34 | + disableAnimations: true, |
| 35 | + ), |
| 36 | + QueryaMotion.instant, |
| 37 | + ); |
| 38 | + }); |
| 39 | + |
| 40 | + test('slow for full motion', () { |
| 41 | + expect( |
| 42 | + QueryaThemeMotion.duration( |
| 43 | + preferenceEnabled: true, |
| 44 | + level: QueryaMotionLevel.full, |
| 45 | + ), |
| 46 | + QueryaMotion.slow, |
| 47 | + ); |
| 48 | + }); |
| 49 | + |
| 50 | + test('halved slow for reduced motion', () { |
| 51 | + expect( |
| 52 | + QueryaThemeMotion.duration( |
| 53 | + preferenceEnabled: true, |
| 54 | + level: QueryaMotionLevel.reduced, |
| 55 | + ), |
| 56 | + Duration(microseconds: QueryaMotion.slow.inMicroseconds ~/ 2), |
| 57 | + ); |
| 58 | + }); |
| 59 | + }); |
| 60 | + |
| 61 | + group('QueryaThemeMotion.curve', () { |
| 62 | + test('linear when not animating', () { |
| 63 | + expect( |
| 64 | + QueryaThemeMotion.curve( |
| 65 | + preferenceEnabled: false, |
| 66 | + level: QueryaMotionLevel.full, |
| 67 | + ), |
| 68 | + Curves.linear, |
| 69 | + ); |
| 70 | + }); |
| 71 | + |
| 72 | + test('emphasized when animating', () { |
| 73 | + expect( |
| 74 | + QueryaThemeMotion.curve( |
| 75 | + preferenceEnabled: true, |
| 76 | + level: QueryaMotionLevel.full, |
| 77 | + ), |
| 78 | + QueryaMotion.emphasized, |
| 79 | + ); |
| 80 | + }); |
| 81 | + }); |
| 82 | + |
| 83 | + group('QueryaThemeMotion.enabled', () { |
| 84 | + test('true only when duration is non-zero', () { |
| 85 | + expect( |
| 86 | + QueryaThemeMotion.enabled( |
| 87 | + preferenceEnabled: true, |
| 88 | + level: QueryaMotionLevel.full, |
| 89 | + ), |
| 90 | + isTrue, |
| 91 | + ); |
| 92 | + expect( |
| 93 | + QueryaThemeMotion.enabled( |
| 94 | + preferenceEnabled: true, |
| 95 | + level: QueryaMotionLevel.off, |
| 96 | + ), |
| 97 | + isFalse, |
| 98 | + ); |
| 99 | + }); |
| 100 | + }); |
| 101 | +} |
0 commit comments