@@ -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,29 +2046,40 @@ 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 {
2041- // Regression test for: https://github.com/zulip/zulip-flutter/issues/732
2042- testBinding.deviceInfoResult = const IosDeviceInfo (systemVersion: '16.0' );
2043-
2044- final message = eg.streamMessage ();
2045- await setupToMessageActionSheet (tester, message: message, narrow: TopicNarrow .ofMessage (message));
2049+ testWidgets ('can show snackbar on success' , (WidgetTester tester) async {
2050+ // Regression test for: https://github.com/zulip/zulip-flutter/issues/732
2051+ final TransitionDurationObserver transitionDurationObserver = TransitionDurationObserver ();
2052+ await tester.pumpWidget (
2053+ MaterialApp (
2054+ navigatorObservers: < NavigatorObserver > [transitionDurationObserver],
2055+ home: Scaffold (
2056+ body: Builder (
2057+ builder: (context) {
2058+ testBinding.deviceInfoResult = const IosDeviceInfo (systemVersion: '16.0' );
2059+ final message = eg.streamMessage ();
2060+ setupToMessageActionSheet (tester,message: message,narrow: TopicNarrow .ofMessage (message));
2061+ return const SizedBox .shrink ();}
2062+ ))));
2063+ final message = eg.streamMessage ();
2064+ // Make the request take a bit of time to complete
2065+ prepareRawContentResponseSuccess (message: message,rawContent: 'Hello world' ,delay: const Duration (milliseconds: 500 ),
2066+ );
2067+ await tapCopyMessageTextButton (tester);
2068+ // … and pump a frame to finish the NavigationState.pop animation…
2069+ await transitionDurationObserver.pumpPastTransition (tester);
2070+ // … before the request finishes. This is the repro condition for #732.
2071+ await transitionDurationObserver.pumpPastTransition (tester);
20462072
2047- // Make the request take a bit of time to complete…
2048- prepareRawContentResponseSuccess (message: message, rawContent: 'Hello world' ,
2049- delay: const Duration (milliseconds: 500 ));
2050- await tapCopyMessageTextButton (tester);
2051- // … and pump a frame to finish the NavigationState.pop animation…
2052- await tester.pump (const Duration (milliseconds: 250 ));
2053- // … before the request finishes. This is the repro condition for #732.
2054- await tester.pump (const Duration (milliseconds: 250 ));
2073+ final snackbar = tester.widget <SnackBar >(find.byType (SnackBar ));
2074+ check (snackbar.behavior).equals (SnackBarBehavior .floating);
20552075
2056- final snackbar = tester.widget <SnackBar >(find.byType (SnackBar ));
2057- check (snackbar.behavior).equals (SnackBarBehavior .floating);
2058- final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
2059- tester.widget (find.descendant (matchRoot: true ,
2076+ final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
2077+ tester.widget (find.descendant (matchRoot: true ,
20602078 of: find.byWidget (snackbar.content),
2061- matching: find.text (zulipLocalizations.successMessageTextCopied)));
2062- });
2079+ matching: find.text (zulipLocalizations.successMessageTextCopied),
2080+ ));
2081+ });
2082+
20632083
20642084 testWidgets ('request has an error' , (tester) async {
20652085 final message = eg.streamMessage ();
@@ -2283,7 +2303,7 @@ void main() {
22832303 // See comment in setupToMessageActionSheet about warnIfMissed: false
22842304 await tester.longPress (find.byType (MessageContent ), warnIfMissed: false );
22852305 // sheet appears onscreen; default duration of bottom-sheet enter animation
2286- await tester. pump ( const Duration (milliseconds : 250 ) );
2306+ await transitionDurationObserver. pumpPastTransition (tester );
22872307 check (find.byType (BottomSheet )).findsOne ();
22882308 checkButtonIsPresent (expected);
22892309
0 commit comments