Created
October 4, 2021 02:57
-
-
Save abhaysood/50f1cb296994ba66fdfd3a022325b2a9 to your computer and use it in GitHub Desktop.
semantic_announcement_tester sample tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testWidgets('One announcement', (WidgetTester tester) async { | |
final mock = MockSemanticAnnouncements(tester); | |
const expectedAnnouncement = AnnounceSemanticsEvent( | |
"Announcement made", | |
TextDirection.ltr, | |
); | |
await tester.pumpWidget(const MyApp()); | |
// Tap to trigger an announcement | |
await tester.tap(find.byType(ElevatedButton)); | |
expect( | |
mock.announcements, | |
hasOneAnnouncement(expectedAnnouncement), | |
); | |
}); | |
testWidgets('N announcements', (WidgetTester tester) async { | |
final mock = MockSemanticAnnouncements(tester); | |
const expectedAnnouncement = AnnounceSemanticsEvent( | |
"Announcement made", | |
TextDirection.ltr, | |
); | |
await tester.pumpWidget(const MyApp()); | |
// Tap twice to trigger two announcements | |
await tester.tap(find.byType(ElevatedButton)); | |
await tester.tap(find.byType(ElevatedButton)); | |
expect( | |
mock.announcements, | |
hasNAnnouncements([ | |
expectedAnnouncement, expectedAnnouncement | |
]), | |
); | |
}); | |
testWidgets("Zero announcements", (WidgetTester tester) async { | |
final mock = MockSemanticAnnouncements(tester); | |
await tester.pumpWidget(const MyApp()); | |
expect(mock.announcements, hasZeroAnnouncements()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment