Skip to content

Commit 37366ad

Browse files
committed
msglist test [nfc]: Clean up tests of scroll-to-bottom button
1 parent 5f0752f commit 37366ad

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

test/widgets/message_list_test.dart

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,7 @@ void main() {
462462

463463
testWidgets('scrolling changes visibility', (tester) async {
464464
await setupMessageListPage(tester, messageCount: 10);
465-
466465
final scrollController = findMessageListScrollController(tester)!;
467-
468-
// Initial state should be not visible, as the message list renders with latest message in view
469466
check(isButtonVisible(tester)).equals(false);
470467

471468
scrollController.jumpTo(-600);
@@ -480,41 +477,38 @@ void main() {
480477
testWidgets('dimension updates changes visibility', (tester) async {
481478
await setupMessageListPage(tester, messageCount: 100);
482479

480+
// Scroll up, to hide the button.
483481
final scrollController = findMessageListScrollController(tester)!;
484-
485-
// Initial state should be not visible, as the message list renders with latest message in view
486-
check(isButtonVisible(tester)).equals(false);
487-
488482
scrollController.jumpTo(-600);
489483
await tester.pump();
490484
check(isButtonVisible(tester)).equals(true);
491485

486+
// Make the view taller, so that the bottom of the list is back in view.
492487
addTearDown(tester.view.resetPhysicalSize);
493488
tester.view.physicalSize = const Size(2000, 40000);
494489
await tester.pump();
495-
// Dimension changes use NotificationListener<ScrollMetricsNotification
496-
// which has a one frame lag. If that ever gets resolved this extra pump
497-
// would ideally be removed
490+
// (Dimension changes use NotificationListener<ScrollMetricsNotification>
491+
// which has a one-frame lag. If that ever gets resolved,
492+
// this extra pump would ideally be removed.)
498493
await tester.pump();
494+
// Check the button duly disappears again.
499495
check(isButtonVisible(tester)).equals(false);
500496
});
501497

502-
testWidgets('button functionality', (tester) async {
498+
testWidgets('button works', (tester) async {
503499
await setupMessageListPage(tester, messageCount: 10);
504-
505500
final scrollController = findMessageListScrollController(tester)!;
506-
507-
// Initial state should be not visible, as the message list renders with latest message in view
508-
check(isButtonVisible(tester)).equals(false);
509-
510501
scrollController.jumpTo(-600);
511502
await tester.pump();
512-
check(isButtonVisible(tester)).equals(true);
503+
check(scrollController.position.pixels).equals(-600);
513504

505+
// Tap button.
514506
await tester.tap(find.byType(ScrollToBottomButton));
507+
// The list scrolls to the end…
515508
await tester.pumpAndSettle();
516-
check(isButtonVisible(tester)).equals(false);
517509
check(scrollController.position.pixels).equals(0);
510+
// … and for good measure confirm the button disappeared.
511+
check(isButtonVisible(tester)).equals(false);
518512
});
519513
});
520514

0 commit comments

Comments
 (0)