@@ -8,105 +8,125 @@ void _homeCommunityFlightTests(
88 })
99 buildTestable,
1010) {
11- for (final reduced in [false , true ]) {
12- testWidgets (
13- 'Home community flight lands at the moved menu (reduced: $reduced )' ,
14- (tester) async {
15- debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
16- addTearDown (() => debugDefaultTargetPlatformOverride = null );
17- tester.view.physicalSize = const Size (390 , 844 );
18- tester.view.devicePixelRatio = 1 ;
19- addTearDown (tester.view.resetPhysicalSize);
20- addTearDown (tester.view.resetDevicePixelRatio);
21- final communities = [
22- for (final id in ['alpha' , 'bravo' ])
23- Community (
24- id: id,
25- name: id,
26- relayUrl: 'wss://$id .example.com' ,
27- addedAt: DateTime (2025 ),
28- ),
29- ];
30- final notifier = _FakeCommunityListNotifier (communities);
31- final loaded = Completer <List <Channel >>();
32- SharedPreferences .setMockInitialValues ({});
33- final prefs = await SharedPreferences .getInstance ();
34- await tester.pumpWidget (
35- buildTestable (
36- realHome: true ,
37- disableAnimations: reduced,
38- overrides: [
39- savedPrefsProvider.overrideWithValue (prefs),
40- channelsProvider.overrideWith (
41- () => _FakeNotifier (
42- [],
43- load: () => notifier.activeId == 'bravo'
44- ? loaded.future
45- : Future .value ([]),
46- ),
11+ for (final size in [const Size (390 , 844 ), const Size (844 , 390 )]) {
12+ for (final reduced in [false , true ]) {
13+ testWidgets (
14+ 'Home community flight lands at the moved menu (size: $size , reduced: $reduced )' ,
15+ (tester) async {
16+ debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
17+ addTearDown (() => debugDefaultTargetPlatformOverride = null );
18+ tester.view.physicalSize = size;
19+ final center = size.center (Offset .zero);
20+ tester.view.devicePixelRatio = 1 ;
21+ addTearDown (tester.view.resetPhysicalSize);
22+ addTearDown (tester.view.resetDevicePixelRatio);
23+ final communities = [
24+ for (final id in ['alpha' , 'bravo' ])
25+ Community (
26+ id: id,
27+ name: id,
28+ relayUrl: 'wss://$id .example.com' ,
29+ addedAt: DateTime (2025 ),
4730 ),
48- communityListProvider.overrideWith (() => notifier),
49- activeCommunityProvider.overrideWith ((ref) async {
50- await ref.watch (communityListProvider.future);
51- return communities.firstWhere ((c) => c.id == notifier.activeId);
52- }),
53- ],
54- ),
55- );
56- await tester.pumpAndSettle ();
57- final menu = find.byWidgetPredicate (
58- (w) =>
59- w is IosMessageCreateButton &&
60- w.accessibilityLabel == 'Community menu' ,
61- );
62- final destination = tester.getCenter (menu);
63- tester.widget <IosMessageCreateButton >(menu).actions.first.onPressed !();
64- await tester.pumpAndSettle ();
65- await tester.tap (find.byKey (const Key ('community-switcher-row-bravo' )));
66- await tester.pump ();
67- final avatar = find.byKey (const Key ('community-flying-avatar' ));
68- final origin = tester.getCenter (avatar);
69- await tester.pump (const Duration (milliseconds: 105 ));
70- if (! reduced) {
71- expect (tester.getCenter (avatar), isNot (origin));
72- expect (tester.getCenter (avatar), isNot (const Offset (195 , 422 )));
73- }
74- await tester.pump (const Duration (milliseconds: 420 ));
75- await tester.pump ();
76- expect (tester.getCenter (avatar), const Offset (195 , 422 ));
77- expect (
78- find.byKey (const Key ('community-switch-loading' )),
79- findsOneWidget,
80- );
81- loaded.complete ([]);
82- // Advance until readiness starts departure, without skipping the flight.
83- for (var i = 0 ; i < 90 ; i++ ) {
84- await tester.pump (const Duration (milliseconds: 16 ));
85- if (find
86- .byKey (const Key ('community-switch-loading' ))
87- .evaluate ()
88- .isEmpty) {
89- break ;
31+ ];
32+ final notifier = _FakeCommunityListNotifier (communities);
33+ final loaded = Completer <List <Channel >>();
34+ SharedPreferences .setMockInitialValues ({});
35+ final prefs = await SharedPreferences .getInstance ();
36+ await tester.pumpWidget (
37+ buildTestable (
38+ realHome: true ,
39+ disableAnimations: reduced,
40+ overrides: [
41+ savedPrefsProvider.overrideWithValue (prefs),
42+ channelsProvider.overrideWith (
43+ () => _FakeNotifier (
44+ [],
45+ load: () => notifier.activeId == 'bravo'
46+ ? loaded.future
47+ : Future .value ([]),
48+ ),
49+ ),
50+ communityListProvider.overrideWith (() => notifier),
51+ activeCommunityProvider.overrideWith ((ref) async {
52+ await ref.watch (communityListProvider.future);
53+ return communities.firstWhere (
54+ (c) => c.id == notifier.activeId,
55+ );
56+ }),
57+ ],
58+ ),
59+ );
60+ await tester.pumpAndSettle ();
61+ final menu = find.byWidgetPredicate (
62+ (w) =>
63+ w is IosMessageCreateButton &&
64+ w.accessibilityLabel == 'Community menu' ,
65+ );
66+ final destination = tester.getCenter (menu);
67+ tester
68+ .widget <IosMessageCreateButton >(menu)
69+ .actions
70+ .first
71+ .onPressed !();
72+ await tester.pumpAndSettle ();
73+ await tester.tap (
74+ find.byKey (const Key ('community-switcher-row-bravo' )),
75+ );
76+ await tester.pump ();
77+ final avatar = find.byKey (const Key ('community-flying-avatar' ));
78+ final origin = tester.getCenter (avatar);
79+ await tester.pump (const Duration (milliseconds: 105 ));
80+ if (! reduced) {
81+ expect (tester.getCenter (avatar), isNot (origin));
82+ expect (tester.getCenter (avatar), isNot (center));
9083 }
91- }
92- if (! reduced) {
93- await tester.pump (const Duration (milliseconds: 65 ));
94- expect (tester.getCenter (avatar).dx, lessThan (195 ));
95- await tester.pump (const Duration (milliseconds: 195 ));
96- expect (tester.getCenter (avatar).dy, lessThan (422 ));
97- expect (tester.getCenter (avatar).dy, greaterThan (destination.dy));
98- await tester.pump (const Duration (milliseconds: 260 ));
84+ await tester.pump (const Duration (milliseconds: 420 ));
85+ await tester.pump ();
86+ expect (tester.getCenter (avatar), center);
9987 expect (
100- (tester. getCenter (avatar) - destination).distance ,
101- lessThan ( 1 ) ,
88+ find. byKey ( const Key ( 'community-switch-loading' )) ,
89+ findsOneWidget ,
10290 );
103- }
104- await tester.pumpAndSettle ();
105- expect (avatar, findsNothing);
106- expect (notifier.switchedIds, ['bravo' ]);
107- expect (tester.takeException (), isNull);
108- debugDefaultTargetPlatformOverride = null ;
109- },
110- );
91+ loaded.complete ([]);
92+ // Advance until readiness starts departure, without skipping the flight.
93+ for (var i = 0 ; i < 90 ; i++ ) {
94+ await tester.pump (const Duration (milliseconds: 16 ));
95+ if (find
96+ .byKey (const Key ('community-switch-loading' ))
97+ .evaluate ()
98+ .isEmpty) {
99+ break ;
100+ }
101+ }
102+ if (! reduced) {
103+ await tester.pump (const Duration (milliseconds: 65 ));
104+ if (size.width < size.height) {
105+ expect (tester.getCenter (avatar).dx, lessThan (center.dx));
106+ }
107+ expect (tester.getCenter (avatar).dy, greaterThanOrEqualTo (0 ));
108+ for (var frame = 0 ; frame < 13 ; frame++ ) {
109+ await tester.pump (const Duration (milliseconds: 15 ));
110+ expect (
111+ tester.getCenter (avatar).dy,
112+ inInclusiveRange (0 , size.height),
113+ );
114+ }
115+ expect (tester.getCenter (avatar).dy, lessThan (center.dy));
116+ expect (tester.getCenter (avatar).dy, greaterThan (destination.dy));
117+ await tester.pump (const Duration (milliseconds: 260 ));
118+ expect (
119+ (tester.getCenter (avatar) - destination).distance,
120+ lessThan (1 ),
121+ );
122+ }
123+ await tester.pumpAndSettle ();
124+ expect (avatar, findsNothing);
125+ expect (notifier.switchedIds, ['bravo' ]);
126+ expect (tester.takeException (), isNull);
127+ debugDefaultTargetPlatformOverride = null ;
128+ },
129+ );
130+ }
111131 }
112132}
0 commit comments