-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Add getSemanticsId command to flutter_driver #19047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getSemanticsId command to flutter_driver #19047
Conversation
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests?
| return new ByType(json['type']); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove one empty line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } | ||
|
|
||
|
|
||
| /// A Flutter driver command that retrieves a semantics id using a specified finder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mention here as well that it might be the semantics information from an ancestor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
Tests added |
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor nits.
| /// then the semantics node of the first ancestor is returned instead. | ||
| /// | ||
| /// If the finder returns multiple objects, or there are no semantics nodes then | ||
| /// a [StateError] is thrown by the extension. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we define anywhere what "the extension" is? Or is it just an implementation detail that the error is thrown by the extension and we should maybe omit that detail from documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An error thrown on the app side becomes an error thrown in the driver script, it isn't necessary to mention that is thrown on the device so i will omit this part
| return result.changedState; | ||
| } | ||
|
|
||
| /// Retrieves the semantics node id for the object returned by [finder], or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe arguments mentioned in doc comments should be enclosed in `` instead of [] unless the argument is also a field on the class.
(here and below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| /// Semantics must be enabled to use this method, either using a platform | ||
| /// specific shell command or [setSemantics]. | ||
| Future<int> getSemanticsId(SerializableFinder finder, { Duration timeout = _kShortTimeout}) async { | ||
| final GetSemanticsIdResult result = GetSemanticsIdResult.fromJson(await _sendCommand(new GetSemanticsId(finder, timeout: timeout))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe add some line breaks to this line to make it easier to read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| RenderObject renderObject = element.renderObject; | ||
| SemanticsNode node; | ||
| while (renderObject != null && node == null) { | ||
| node = renderObject.debugSemantics; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure: It's guaranteed that drive tests always run with asserts enabled? Otherwise debugSemantics would be null even when semantics are enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not always (microbenchmarks), but for these integration tests we'll always be using a debug build. Added doc comment to the command.
Forked from https://github.com/flutter/flutter/pull/19005/files