-
Notifications
You must be signed in to change notification settings - Fork 373
test: Get route-transition duration robustly,instead of hard-coding #1920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,8 +139,8 @@ Future<void> setupToMessageActionSheet(WidgetTester tester, { | |
| // the long-press might land where no child hit-tests as true, | ||
| // like if it's in padding around a Paragraph. | ||
| await tester.longPress(find.byType(MessageContent), warnIfMissed: false); | ||
| // sheet appears onscreen; default duration of bottom-sheet enter animation | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| // sheet appears onscreen | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| // Check the action sheet did in fact open, so we don't defeat any tests that | ||
| // use simple `find.byIcon`-style checks to test presence/absence of a button. | ||
| check(find.byType(BottomSheet)).findsOne(); | ||
|
|
@@ -199,26 +199,29 @@ void main() { | |
| check(find.byType(InboxPageBody)).findsOne(); | ||
|
|
||
| await tester.longPress(find.text(someChannel.name).hitTestable()); | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| } | ||
|
|
||
| Future<void> showFromSubscriptionList(WidgetTester tester) async { | ||
| transitionDurationObserver = TransitionDurationObserver(); | ||
| await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id, | ||
| navigatorObservers: [transitionDurationObserver], | ||
| child: const HomePage())); | ||
| await tester.pump(); | ||
| await tester.tap(find.byIcon(ZulipIcons.hash_italic)); | ||
| await tester.pump(); | ||
| check(find.byType(SubscriptionListPageBody)).findsOne(); | ||
|
|
||
| await tester.longPress(find.text(someChannel.name).hitTestable()); | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| } | ||
|
|
||
| Future<void> showFromMsglistAppBar(WidgetTester tester, { | ||
| ZulipStream? channel, | ||
| required Narrow narrow, | ||
| }) async { | ||
| channel ??= someChannel; | ||
| transitionDurationObserver = TransitionDurationObserver(); | ||
|
|
||
| connection.prepare(json: eg.newestGetMessagesResult( | ||
| foundOldest: true, messages: []).toJson()); | ||
|
|
@@ -229,31 +232,34 @@ void main() { | |
| } | ||
| await tester.pumpWidget(TestZulipApp( | ||
| accountId: eg.selfAccount.id, | ||
| navigatorObservers: [transitionDurationObserver], | ||
| child: MessageListPage( | ||
| initNarrow: narrow))); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| await tester.longPress(find.descendant( | ||
| of: find.byType(ZulipAppBar), | ||
| matching: find.text(channel.name))); | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| } | ||
|
|
||
| Future<void> showFromRecipientHeader(WidgetTester tester, { | ||
| StreamMessage? message, | ||
| }) async { | ||
| message ??= someMessage; | ||
| transitionDurationObserver = TransitionDurationObserver(); | ||
|
|
||
| connection.prepare(json: eg.newestGetMessagesResult( | ||
| foundOldest: true, messages: [message]).toJson()); | ||
| await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id, | ||
| navigatorObservers: [transitionDurationObserver], | ||
| child: const MessageListPage(initNarrow: CombinedFeedNarrow()))); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| await tester.longPress(find.descendant( | ||
| of: find.byType(RecipientHeader), | ||
| matching: find.text(message.displayRecipient ?? ''))); | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| } | ||
|
|
||
| Future<void> showFromTopicListAppBar(WidgetTester tester, {int? streamId}) async { | ||
|
|
@@ -738,8 +744,8 @@ void main() { | |
| check(find.byType(InboxPageBody)).findsOne(); | ||
|
|
||
| await tester.longPress(find.text(topic)); | ||
| // sheet appears onscreen; default duration of bottom-sheet enter animation | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| // sheet appears onscreen | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this instance, we're using Does that mean we don't need to set |
||
| } | ||
|
|
||
| Future<void> showFromAppBar(WidgetTester tester, { | ||
|
|
@@ -765,8 +771,8 @@ void main() { | |
| matching: find.text( | ||
| effectiveTopic.displayName ?? eg.defaultRealmEmptyTopicDisplayName)); | ||
| await tester.longPress(topicRow); | ||
| // sheet appears onscreen; default duration of bottom-sheet enter animation | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| // sheet appears onscreen | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| } | ||
|
|
||
| Future<void> showFromRecipientHeader(WidgetTester tester, { | ||
|
|
@@ -784,8 +790,8 @@ void main() { | |
| await tester.longPress(find.descendant( | ||
| of: find.byType(RecipientHeader), | ||
| matching: find.text(effectiveMessage.topic.displayName!))); | ||
| // sheet appears onscreen; default duration of bottom-sheet enter animation | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| // sheet appears onscreen | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| } | ||
|
|
||
| final actionSheetFinder = find.byType(BottomSheet); | ||
|
|
@@ -2049,9 +2055,11 @@ void main() { | |
| delay: const Duration(milliseconds: 500)); | ||
| await tapCopyMessageTextButton(tester); | ||
| // … and pump a frame to finish the NavigationState.pop animation… | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| // … before the request finishes. This is the repro condition for #732. | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| await tester.pump(Duration(milliseconds: 500)); | ||
| // … pump for snackbar to show; default duration of snackbar enter animation | ||
| await tester.pump(Duration(milliseconds: 250)); | ||
|
Comment on lines
2059
to
+2062
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this change about? (And what does the comment mean? It doesn't seem to make any sense syntactically — this new comment line starts with a "…" as if it's continuing something, but the previous comment ends with a "." and the end of a sentence.) |
||
|
|
||
| final snackbar = tester.widget<SnackBar>(find.byType(SnackBar)); | ||
| check(snackbar.behavior).equals(SnackBarBehavior.floating); | ||
|
|
@@ -2282,8 +2290,8 @@ void main() { | |
|
|
||
| // See comment in setupToMessageActionSheet about warnIfMissed: false | ||
| await tester.longPress(find.byType(MessageContent), warnIfMissed: false); | ||
| // sheet appears onscreen; default duration of bottom-sheet enter animation | ||
| await tester.pump(const Duration(milliseconds: 250)); | ||
| // sheet appears onscreen | ||
| await transitionDurationObserver.pumpPastTransition(tester); | ||
| check(find.byType(BottomSheet)).findsOne(); | ||
| checkButtonIsPresent(expected); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm — it seems awfully messy for there to be so many different functions that are setting this shared variable. When does it need to get set? How did you confirm for yourself that you've set it in all of the places it needs to get set in?
In short, this setup seems likely to cause bugs.