You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide testing extension API that matches widgets and returns matched widget information #29375
The API takes in a matcher (e.g. withText, withValueKey) and returns a serialized widget object, which contains information necessary (e.g. coordinates) for performing an action on the widget or making assertions on the widget properties in Espresso.
The semantics tree doesn't correspond 1-1 with Widgets though. And since a Widget is an arbitrary user defined class, we do not have the capability to reflect on or serialize them.
As discussed with @goderbauer yesterday, for the first version, the matching API will possibly be something like this:
WidgetInfo matchWidget(SerializableFinder finder), which finds a widget (RenderObject to be accurate?) that matches exactly with the finder, and returns an object containing its properties (we could even start with a minimum set of properties, e.g. runtimeType, valueKey, text, tooltip).
How does the matching work?
First version: it won't be able to match a composite widget. Rather it does exact matching on a widget.
For example, a Flutter button could be composed by an icon, a Text widget, and may also have multiple layers of widget containers, decorators. Users cannot express "matching a (composite) button widget for me" with the matching API, but could match the Text widget for example.
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 -v and a minimal reproduction of the issue.
Activity
jonahwilliams commentedon Mar 15, 2019
For testing, you likely want information from the semantics tree, this can tell you things such as where to tap/available actions/labels. Example:
The semantics tree doesn't correspond 1-1 with Widgets though. And since a Widget is an arbitrary user defined class, we do not have the capability to reflect on or serialize them.
Hixie commentedon Mar 19, 2019
@jacob314's inspector API exposes much of this, would it be sufficient?
adazh commentedon May 22, 2019
As discussed with @goderbauer yesterday, for the first version, the matching API will possibly be something like this:
WidgetInfo matchWidget(SerializableFinder finder), which finds a widget (RenderObject to be accurate?) that matches exactly with the finder, and returns an object containing its properties (we could even start with a minimum set of properties, e.g. runtimeType, valueKey, text, tooltip).
First version: it won't be able to match a composite widget. Rather it does exact matching on a widget.
For example, a Flutter button could be composed by an icon, a Text widget, and may also have multiple layers of widget containers, decorators. Users cannot express "matching a (composite) button widget for me" with the matching API, but could match the Text widget for example.
Michael, feel free to correct if I'm wrong.
github-actions commentedon Aug 29, 2021
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.