Skip to content

Commit 231b054

Browse files
committed
msglist test: Generalize scroll-to-bottom tests to not assume 0 is end
These were implicitly assuming that the scroll position at the bottom of the list is 0.0. That's currently true, but we'll soon let it vary. Make them a bit more general in saying what they mean.
1 parent 5653816 commit 231b054

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/widgets/message_list_test.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,21 @@ void main() {
462462

463463
testWidgets('scrolling changes visibility', (tester) async {
464464
await setupMessageListPage(tester, messageCount: 10);
465+
// Scroll position starts at the end, so button hidden.
465466
final controller = findMessageListScrollController(tester)!;
467+
check(controller.position).extentAfter.equals(0);
466468
check(isButtonVisible(tester)).equals(false);
467469

470+
// Scrolling up, button becomes visible.
468471
controller.jumpTo(-600);
469472
await tester.pump();
473+
check(controller.position).extentAfter.isGreaterThan(0);
470474
check(isButtonVisible(tester)).equals(true);
471475

472-
controller.jumpTo(0);
476+
// Scrolling back down to end, button becomes hidden again.
477+
controller.jumpTo(controller.position.maxScrollExtent);
473478
await tester.pump();
479+
check(controller.position).extentAfter.equals(0);
474480
check(isButtonVisible(tester)).equals(false);
475481
});
476482

@@ -500,13 +506,13 @@ void main() {
500506
final controller = findMessageListScrollController(tester)!;
501507
controller.jumpTo(-600);
502508
await tester.pump();
503-
check(controller.position).pixels.equals(-600);
509+
check(controller.position).extentAfter.isGreaterOrEqual(600);
504510

505511
// Tap button.
506512
await tester.tap(find.byType(ScrollToBottomButton));
507513
// The list scrolls to the end…
508514
await tester.pumpAndSettle();
509-
check(controller.position).pixels.equals(0);
515+
check(controller.position).extentAfter.equals(0);
510516
// … and for good measure confirm the button disappeared.
511517
check(isButtonVisible(tester)).equals(false);
512518
});

0 commit comments

Comments
 (0)