Use case
Currently, when testing announceSemantics, we retrieve a list of CapturedAccessibilityAnnouncement objects via tester.takeAnnouncements(). Verifying the content of these announcements often requires manual checks of the properties (message, textDirection, assertiveness), which can be verbose, especially for lists.
Proposal
I suggest introducing an accessibilityAnnouncement matcher (with PR #180058). This would allow developers to write cleaner and more readable tests.
Benefits
The main advantage is the ability to easily check lists of announcements using standard collection matchers.
For example, existing tests in widget_tester_test.dart or user apps often manually iterate through the list or check indices. With this matcher, we can simply use contains, orderedEquals, or containsAll.
Example Usage:
Current approach:
expect(tester.takeAnnouncements().length, 1);
expect(tester.takeAnnouncements().first.message, 'Hello');
expect(tester.takeAnnouncements().first.textDirection, TextDirection.ltr);
With proposed Matcher:
expect(
tester.takeAnnouncements(),
[accessibilityAnnouncement('Hello', textDirection: TextDirection.ltr)],
);
Use case
Currently, when testing announceSemantics, we retrieve a list of
CapturedAccessibilityAnnouncementobjects viatester.takeAnnouncements(). Verifying the content of these announcements often requires manual checks of the properties (message,textDirection,assertiveness), which can be verbose, especially for lists.Proposal
I suggest introducing an
accessibilityAnnouncementmatcher (with PR #180058). This would allow developers to write cleaner and more readable tests.Benefits
The main advantage is the ability to easily check lists of announcements using standard collection matchers.
For example, existing tests in
widget_tester_test.dartor user apps often manually iterate through the list or check indices. With this matcher, we can simply usecontains,orderedEquals, orcontainsAll.Example Usage:
Current approach:
With proposed Matcher: