@@ -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,26 +199,29 @@ 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+ transitionDurationObserver = TransitionDurationObserver ();
206207 await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
208+ navigatorObservers: [transitionDurationObserver],
207209 child: const HomePage ()));
208210 await tester.pump ();
209211 await tester.tap (find.byIcon (ZulipIcons .hash_italic));
210212 await tester.pump ();
211213 check (find.byType (SubscriptionListPageBody )).findsOne ();
212214
213215 await tester.longPress (find.text (someChannel.name).hitTestable ());
214- await tester. pump ( const Duration (milliseconds : 250 ) );
216+ await transitionDurationObserver. pumpPastTransition (tester );
215217 }
216218
217219 Future <void > showFromMsglistAppBar (WidgetTester tester, {
218220 ZulipStream ? channel,
219221 required Narrow narrow,
220222 }) async {
221223 channel ?? = someChannel;
224+ transitionDurationObserver = TransitionDurationObserver ();
222225
223226 connection.prepare (json: eg.newestGetMessagesResult (
224227 foundOldest: true , messages: []).toJson ());
@@ -229,31 +232,34 @@ void main() {
229232 }
230233 await tester.pumpWidget (TestZulipApp (
231234 accountId: eg.selfAccount.id,
235+ navigatorObservers: [transitionDurationObserver],
232236 child: MessageListPage (
233237 initNarrow: narrow)));
234238 await tester.pumpAndSettle ();
235239
236240 await tester.longPress (find.descendant (
237241 of: find.byType (ZulipAppBar ),
238242 matching: find.text (channel.name)));
239- await tester. pump ( const Duration (milliseconds : 250 ) );
243+ await transitionDurationObserver. pumpPastTransition (tester );
240244 }
241245
242246 Future <void > showFromRecipientHeader (WidgetTester tester, {
243247 StreamMessage ? message,
244248 }) async {
245249 message ?? = someMessage;
250+ transitionDurationObserver = TransitionDurationObserver ();
246251
247252 connection.prepare (json: eg.newestGetMessagesResult (
248253 foundOldest: true , messages: [message]).toJson ());
249254 await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
255+ navigatorObservers: [transitionDurationObserver],
250256 child: const MessageListPage (initNarrow: CombinedFeedNarrow ())));
251257 await tester.pumpAndSettle ();
252258
253259 await tester.longPress (find.descendant (
254260 of: find.byType (RecipientHeader ),
255261 matching: find.text (message.displayRecipient ?? '' )));
256- await tester. pump ( const Duration (milliseconds : 250 ) );
262+ await transitionDurationObserver. pumpPastTransition (tester );
257263 }
258264
259265 Future <void > showFromTopicListAppBar (WidgetTester tester, {int ? streamId}) async {
@@ -739,7 +745,7 @@ void main() {
739745
740746 await tester.longPress (find.text (topic));
741747 // sheet appears onscreen; default duration of bottom-sheet enter animation
742- await tester. pump ( const Duration (milliseconds : 250 ) );
748+ await transitionDurationObserver. pumpPastTransition (tester );
743749 }
744750
745751 Future <void > showFromAppBar (WidgetTester tester, {
@@ -766,7 +772,7 @@ void main() {
766772 effectiveTopic.displayName ?? eg.defaultRealmEmptyTopicDisplayName));
767773 await tester.longPress (topicRow);
768774 // sheet appears onscreen; default duration of bottom-sheet enter animation
769- await tester. pump ( const Duration (milliseconds : 250 ) );
775+ await transitionDurationObserver. pumpPastTransition (tester );
770776 }
771777
772778 Future <void > showFromRecipientHeader (WidgetTester tester, {
@@ -785,7 +791,7 @@ void main() {
785791 of: find.byType (RecipientHeader ),
786792 matching: find.text (effectiveMessage.topic.displayName! )));
787793 // sheet appears onscreen; default duration of bottom-sheet enter animation
788- await tester. pump ( const Duration (milliseconds : 250 ) );
794+ await transitionDurationObserver. pumpPastTransition (tester );
789795 }
790796
791797 final actionSheetFinder = find.byType (BottomSheet );
@@ -2049,9 +2055,11 @@ void main() {
20492055 delay: const Duration (milliseconds: 500 ));
20502056 await tapCopyMessageTextButton (tester);
20512057 // … and pump a frame to finish the NavigationState.pop animation…
2052- await tester. pump ( const Duration (milliseconds : 250 ) );
2058+ await transitionDurationObserver. pumpPastTransition (tester );
20532059 // … before the request finishes. This is the repro condition for #732.
2054- await tester.pump (const Duration (milliseconds: 250 ));
2060+ await transitionDurationObserver.pumpPastTransition (tester);
2061+ // …pump for snackbar to show
2062+ await tester.pumpAndSettle ();
20552063
20562064 final snackbar = tester.widget <SnackBar >(find.byType (SnackBar ));
20572065 check (snackbar.behavior).equals (SnackBarBehavior .floating);
@@ -2283,7 +2291,7 @@ void main() {
22832291 // See comment in setupToMessageActionSheet about warnIfMissed: false
22842292 await tester.longPress (find.byType (MessageContent ), warnIfMissed: false );
22852293 // sheet appears onscreen; default duration of bottom-sheet enter animation
2286- await tester. pump ( const Duration (milliseconds : 250 ) );
2294+ await transitionDurationObserver. pumpPastTransition (tester );
22872295 check (find.byType (BottomSheet )).findsOne ();
22882296 checkButtonIsPresent (expected);
22892297
0 commit comments