@@ -140,7 +140,7 @@ Future<void> setupToMessageActionSheet(WidgetTester tester, {
140140 // like if it's in padding around a Paragraph.
141141 await tester.longPress (find.byType (MessageContent ), warnIfMissed: false );
142142 // sheet appears onscreen; default duration of bottom-sheet enter animation
143- await tester. pump ( const Duration (milliseconds : 250 ) );
143+ await transitionDurationObserver. pumpPastTransition (tester );
144144 // Check the action sheet did in fact open, so we don't defeat any tests that
145145 // use simple `find.byIcon`-style checks to test presence/absence of a button.
146146 check (find.byType (BottomSheet )).findsOne ();
@@ -199,19 +199,22 @@ void main() {
199199 check (find.byType (InboxPageBody )).findsOne ();
200200
201201 await tester.longPress (find.text (someChannel.name).hitTestable ());
202- await tester. pump ( const Duration (milliseconds : 250 ) );
202+ await transitionDurationObserver. pumpPastTransition (tester );
203203 }
204204
205205 Future <void > showFromSubscriptionList (WidgetTester tester) async {
206+ final transitionDurationObserver = TransitionDurationObserver ();
207+
206208 await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
209+ navigatorObservers: [transitionDurationObserver],
207210 child: const HomePage ()));
208211 await tester.pump ();
209212 await tester.tap (find.byIcon (ZulipIcons .hash_italic));
210213 await tester.pump ();
211214 check (find.byType (SubscriptionListPageBody )).findsOne ();
212215
213216 await tester.longPress (find.text (someChannel.name).hitTestable ());
214- await tester. pump ( const Duration (milliseconds : 250 ) );
217+ await transitionDurationObserver. pumpPastTransition (tester );
215218 }
216219
217220 Future <void > showFromMsglistAppBar (WidgetTester tester, {
@@ -220,6 +223,8 @@ void main() {
220223 }) async {
221224 channel ?? = someChannel;
222225
226+ final transitionDurationObserver = TransitionDurationObserver ();
227+
223228 connection.prepare (json: eg.newestGetMessagesResult (
224229 foundOldest: true , messages: []).toJson ());
225230 if (narrow case ChannelNarrow ()) {
@@ -229,31 +234,35 @@ void main() {
229234 }
230235 await tester.pumpWidget (TestZulipApp (
231236 accountId: eg.selfAccount.id,
237+ navigatorObservers: [transitionDurationObserver],
232238 child: MessageListPage (
233239 initNarrow: narrow)));
234240 await tester.pumpAndSettle ();
235241
236242 await tester.longPress (find.descendant (
237243 of: find.byType (ZulipAppBar ),
238244 matching: find.text (channel.name)));
239- await tester. pump ( const Duration (milliseconds : 250 ) );
245+ await transitionDurationObserver. pumpPastTransition (tester );
240246 }
241247
242248 Future <void > showFromRecipientHeader (WidgetTester tester, {
243249 StreamMessage ? message,
244250 }) async {
245251 message ?? = someMessage;
246252
253+ final transitionDurationObserver = TransitionDurationObserver ();
254+
247255 connection.prepare (json: eg.newestGetMessagesResult (
248256 foundOldest: true , messages: [message]).toJson ());
249257 await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
258+ navigatorObservers: [transitionDurationObserver],
250259 child: const MessageListPage (initNarrow: CombinedFeedNarrow ())));
251260 await tester.pumpAndSettle ();
252261
253262 await tester.longPress (find.descendant (
254263 of: find.byType (RecipientHeader ),
255264 matching: find.text (message.displayRecipient ?? '' )));
256- await tester. pump ( const Duration (milliseconds : 250 ) );
265+ await transitionDurationObserver. pumpPastTransition (tester );
257266 }
258267
259268 Future <void > showFromTopicListAppBar (WidgetTester tester, {int ? streamId}) async {
@@ -739,7 +748,7 @@ void main() {
739748
740749 await tester.longPress (find.text (topic));
741750 // sheet appears onscreen; default duration of bottom-sheet enter animation
742- await tester. pump ( const Duration (milliseconds : 250 ) );
751+ await transitionDurationObserver. pumpPastTransition (tester );
743752 }
744753
745754 Future <void > showFromAppBar (WidgetTester tester, {
@@ -766,7 +775,7 @@ void main() {
766775 effectiveTopic.displayName ?? eg.defaultRealmEmptyTopicDisplayName));
767776 await tester.longPress (topicRow);
768777 // sheet appears onscreen; default duration of bottom-sheet enter animation
769- await tester. pump ( const Duration (milliseconds : 250 ) );
778+ await transitionDurationObserver. pumpPastTransition (tester );
770779 }
771780
772781 Future <void > showFromRecipientHeader (WidgetTester tester, {
@@ -785,7 +794,7 @@ void main() {
785794 of: find.byType (RecipientHeader ),
786795 matching: find.text (effectiveMessage.topic.displayName! )));
787796 // sheet appears onscreen; default duration of bottom-sheet enter animation
788- await tester. pump ( const Duration (milliseconds : 250 ) );
797+ await transitionDurationObserver. pumpPastTransition (tester );
789798 }
790799
791800 final actionSheetFinder = find.byType (BottomSheet );
@@ -2037,21 +2046,28 @@ void main() {
20372046 check (await Clipboard .getData ('text/plain' )).isNotNull ().text.equals ('Hello world' );
20382047 });
20392048
2040- testWidgets ('can show snackbar on success' , (tester) async {
2049+ testWidgets ('can show snackbar on success' , (WidgetTester tester) async {
20412050 // Regression test for: https://github.com/zulip/zulip-flutter/issues/732
2042- testBinding.deviceInfoResult = const IosDeviceInfo (systemVersion: '16.0' );
2043-
2051+ final TransitionDurationObserver transitionDurationObserver = TransitionDurationObserver ();
2052+ await tester.pumpWidget (
2053+ MaterialApp (
2054+ navigatorObservers: < NavigatorObserver > [transitionDurationObserver],
2055+ home: Scaffold (
2056+ body: Builder (builder: (context) {
2057+ testBinding.deviceInfoResult = const IosDeviceInfo (systemVersion: '16.0' );
2058+ final message = eg.streamMessage ();
2059+ setupToMessageActionSheet (tester,message: message,narrow: TopicNarrow .ofMessage (message));
2060+ return const SizedBox .shrink ();}
2061+ ))));
20442062 final message = eg.streamMessage ();
2045- await setupToMessageActionSheet (tester, message: message, narrow: TopicNarrow .ofMessage (message));
2046-
20472063 // Make the request take a bit of time to complete…
20482064 prepareRawContentResponseSuccess (message: message, rawContent: 'Hello world' ,
20492065 delay: const Duration (milliseconds: 500 ));
20502066 await tapCopyMessageTextButton (tester);
20512067 // … and pump a frame to finish the NavigationState.pop animation…
2052- await tester. pump ( const Duration (milliseconds : 250 ) );
2068+ await transitionDurationObserver. pumpPastTransition (tester );
20532069 // … before the request finishes. This is the repro condition for #732.
2054- await tester. pump ( const Duration (milliseconds : 250 ) );
2070+ await transitionDurationObserver. pumpPastTransition (tester );
20552071
20562072 final snackbar = tester.widget <SnackBar >(find.byType (SnackBar ));
20572073 check (snackbar.behavior).equals (SnackBarBehavior .floating);
@@ -2283,7 +2299,7 @@ void main() {
22832299 // See comment in setupToMessageActionSheet about warnIfMissed: false
22842300 await tester.longPress (find.byType (MessageContent ), warnIfMissed: false );
22852301 // sheet appears onscreen; default duration of bottom-sheet enter animation
2286- await tester. pump ( const Duration (milliseconds : 250 ) );
2302+ await transitionDurationObserver. pumpPastTransition (tester );
22872303 check (find.byType (BottomSheet )).findsOne ();
22882304 checkButtonIsPresent (expected);
22892305
0 commit comments