Repository navigation
Better API for triggering SemanticsActions in tests #112413
Description
Activity
- addeda: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: multi windowIssues related to multi window supportIssues related to multi window support
on Sep 26, 2022 Implementing this would also be helpful for the multi window project: the
pipelineOwnerattribute on the binding is going away as part of that project, so all tests, which are currently relying ontester.binding.pipelineOwner.semanticsOwnerto perform semantics actions need to be migrated anyways. Would be good to migrate them straight to a more sensible API on widget tester instead of migrating them to what's replacing thepipelineOwnerattribute.(Under the hood, the API on WidgetTester can still be based on
pipelineOwnerfor now. Once the multi window stuff is ready, we would then have a single place to migrate that over to the new API instead of doing it for every single test that triggers semantics actions.)/cc @pdblasi-google Would you be up for looking into this?
Yeah, I'd be happy to look into this. This actually gave me an idea for improving the API for #107866 as well. What would you think about adding a
semantics/semanticsTesterproperty toWidgetTesterthat could include various semantics related APIs?It'd be implemented with a
SemanticsTesterclass, which could help organize out those specific needs. I've been trying to make aFinderin #107866 for a simulated semantics traversal, but the API isn't quite right. It'd fit better in eitherWidgetTesteror a dedicatedSemanticsTester, so I could create an initialSemanticsTesteras part of #107866 and add in new functionality for this ticket when I get to it.What API are you envisioning for that semantics/semanticsTester property? Could it live right on WidgetTester as a first-class citizen like most of the other testing related API?
I was thinking that the semantics property would be implemented with a separate class, but be exposed through WidgetTester. The end result would look something like this while writing tests:
tester.semantics.tap(find.byKey(key));To make things nicer, I had thought to split out the separate SemanticActions into different methods, but a
tester.semantics.performActioncould be an alternative or simply included as well.Personally, I think having this separated out through a property and separate class makes things more readable, discoverable, and prevents us from having to prefix every method with
semantics*to differentiate it from the currentWidgetTestermethods. It also makes it easier for us to expand on our semantics testing API more consistently, lowering the overall maintenance burden.I like that idea!
Awesome! I'll start on that idea with #107866 and expand on it here for semantics interactions!
- addedP1High-priority issues at the top of the work listHigh-priority issues at the top of the work list
on Sep 27, 2022 3 remaining items
- addedteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamand removedtriaged-frameworkTriaged by Framework teamTriaged by Framework team
on Jul 8, 2023 This issue is assigned but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!
Reacted by ImagineBoom- added⏳Bot is counting down the days until it unassigns the issueBot is counting down the days until it unassigns the issue
on Jul 30, 2023 This issue was assigned to @pdblasi-google but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.
- removed⏳Bot is counting down the days until it unassigns the issueBot is counting down the days until it unassigns the issue
on Sep 1, 2023 - added a commit that references this issue
on Oct 18, 2023 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Nov 1, 2023
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
The API to trigger semantics actions from tests right now is not very discoverable:
flutter/packages/flutter/test/widgets/gesture_detector_semantics_test.dart
Line 36 in 2aa348b
Instead of requiring developers to figure that out, we should provide an easier way. Similarly to
WidgetTester.tap[1] andWidgetTester.tapAt[2] we should provide a simple API onWidgetTesteritself to trigger semantics actions in tests based on finders. With such an API, people could be writing something like the following in their tests:[1] https://master-api.flutter.dev/flutter/flutter_test/WidgetController/tap.html
[2] https://master-api.flutter.dev/flutter/flutter_test/WidgetController/tapAt.html