From fe89b25fe9a02a16c819b80878caa7fda6ea87f0 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Wed, 25 Oct 2023 13:53:43 +0100 Subject: [PATCH] msglist test [nfc]: Deduplicate getAnimation helper --- test/widgets/message_list_test.dart | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/test/widgets/message_list_test.dart b/test/widgets/message_list_test.dart index c19e5456fd..a23df6ed03 100644 --- a/test/widgets/message_list_test.dart +++ b/test/widgets/message_list_test.dart @@ -302,9 +302,9 @@ void main() { }); group('_UnreadMarker animations', () { - Animation getAnimation(WidgetTester tester) { + Animation getAnimation(WidgetTester tester, int messageId) { final widget = tester.widget(find.descendant( - of: find.byType(MessageItem), + of: find.byKey(ValueKey(messageId)), matching: find.byType(FadeTransition))); return widget.opacity; } @@ -313,23 +313,23 @@ void main() { final message = eg.streamMessage(flags: [MessageFlag.read]); await setupMessageListPage(tester, messages: [message]); - check(getAnimation(tester).value).equals(0); + check(getAnimation(tester, message.id).value).equals(0); store.handleEvent(eg.updateMessageFlagsRemoveEvent( MessageFlag.read, [message])); await tester.pump(); // process handleEvent - check(getAnimation(tester).status).equals(AnimationStatus.forward); + check(getAnimation(tester, message.id).status).equals(AnimationStatus.forward); await tester.pumpAndSettle(); - check(getAnimation(tester).value).equals(1.0); + check(getAnimation(tester, message.id).value).equals(1.0); }); testWidgets('from unread to read', (WidgetTester tester) async { final message = eg.streamMessage(flags: []); await setupMessageListPage(tester, messages: [message]); - check(getAnimation(tester).value).equals(1.0); + check(getAnimation(tester, message.id).value).equals(1.0); store.handleEvent(UpdateMessageFlagsAddEvent( id: 1, @@ -338,21 +338,14 @@ void main() { all: false, )); await tester.pump(); // process handleEvent - check(getAnimation(tester).status).equals(AnimationStatus.forward); + check(getAnimation(tester, message.id).status).equals(AnimationStatus.forward); await tester.pumpAndSettle(); - check(getAnimation(tester).value).equals(0); + check(getAnimation(tester, message.id).value).equals(0); }); testWidgets('animation state persistence', (WidgetTester tester) async { - Animation getAnimation(WidgetTester tester, int messageId) { - final widget = tester.widget(find.descendant( - of: find.byKey(ValueKey(messageId)), - matching: find.byType(FadeTransition))); - return widget.opacity; - } - // Check that _UnreadMarker maintains its in-progress animation // as the number of items change in MessageList. final message = eg.streamMessage(id: 1, flags: []);