-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Create flutter_driver infra for testing the Android AccessibilityNodeInfo generated by Flutter #19700
Create flutter_driver infra for testing the Android AccessibilityNodeInfo generated by Flutter #19700
Conversation
// found in the LICENSE file. | ||
|
||
/// WARNING: These APIs are only supported internally for testing the flutter | ||
/// framework. |
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.
We either support it or we don't have it, we don't have a concept of half-public APIs.
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.
(This is because regardless of what we say, people will depend on whatever we publish.)
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.
Fair enough
add newline at eof
…ntics_integration_test
|
||
/// A Dart VM implementation of a Size. | ||
/// | ||
/// Created to mirror the implementation of `Size` from 'dart:ui' |
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.
here and elsewhere: you can use [ui.Size]
to get this to cross-reference correctly, I believe.
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.
(even though it's not in scope here - dartdocs doesn't care, it puts everything in scope)
I don't really understand how this works? There doesn't seem to be any actual logic to read anything from Android here. |
Ah, never mind, I see it in #19005. |
…oid_semantics_integration_test
I had misunderstood the purpose of this. This is for us to test our own SemanticsNode->AccessibilityNodeInfo logic. As such it probably belongs in dev/integration_tests or dev/devicelab or some such rather than flutter_driver. |
…oid_semantics_integration_test
…oid_semantics_integration_test
…oid_semantics_integration_test
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.
Overall looks good, left a few nits.
One more thing - right now under dev/integration_test we have a bunch of tests, I'm not sure that's the best path for this package (though the only thing that comes to mind is dev/integration_test/testing_utils and I think the team is scared of the name utils 😄 ).
I'd also consider calling a less generic name for the package, maybe something with semantics?
|
||
/// Deserializes a new [AndroidSemanticsNode] from a json map. | ||
factory AndroidSemanticsNode.deserialize(String value) { | ||
return new AndroidSemanticsNode._(json.decode(value)); |
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.
Where is the format of this json specified?
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.
Added a doc comment to describe the format
/// | ||
/// This is usually only applied to text fields, which map | ||
/// to "android.widget.EditText". | ||
bool get isEditable => _flags['isEditable']; |
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'm not sure about the json format but I guessed _flags are coming from SemanticsFlag, though I do not see any editable constant there...
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.
These come from the AndroidAccessibilityNodeInfos. The purpose of this test is to verify that our semantics information is correctly mapped to android accessibility. I've added this to the doc comment of the class.
bool get isEditable => _flags['isEditable']; | ||
|
||
/// Whether the node is enabled. | ||
bool get isEnabled => _flags['isEnabled']; |
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.
Is this SemanticFlag.isEnabled?
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.
No, see above.
bool get isFocusable => _flags['isFocusable']; | ||
|
||
/// Whether the node is focused. | ||
bool get isFocused => _flags['isFocused']; |
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.
same here
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.
No, see above.
bool get isEnabled => _flags['isEnabled']; | ||
|
||
/// Whether the node is focusable. | ||
bool get isFocusable => _flags['isFocusable']; |
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.
same here
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.
No, see above.
/// accessibility action. | ||
static AndroidSemanticsAction deserialize(int value) { | ||
final AndroidSemanticsAction action = new AndroidSemanticsAction._(value); | ||
action.toString(); |
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.
Is this here to make sure value is valid?
I'd try to be more explicit about the validation here, maybe keep a static int->string map of the values, and here validate that the value is contained in the map, and in toString just query the map?
/// | ||
/// This matcher is intended to compare the accessibility values generated by | ||
/// the Android accessibility bridge, and not the semantics object created by | ||
/// the Flutter framework. |
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.
Maybe mention that unspecified/null values are not matched against
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.
See previous sentence
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.
woops
return _failWithMessage('Expected actions: $actions', matchState); | ||
} | ||
final List<int> usedIds = <int>[]; | ||
outer: for (int i = 0; i < actions.length; i++) { |
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.
TIL continue outer 👍
} | ||
final List<int> usedIds = <int>[]; | ||
outer: for (int i = 0; i < actions.length; i++) { | ||
final AndroidSemanticsAction leftAction = actions[i]; |
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: I was a bit confused by the name, maybe call it expected Action?
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.
Removed by below
if (actions.length != itemActions.length) { | ||
return _failWithMessage('Expected actions: $actions', matchState); | ||
} | ||
final List<int> usedIds = <int>[]; |
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.
Is it possible to use unorderedEquals here?
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.
RIP continue outer, Fixed!
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
Just not completely sure about the package name/path
/// A semantics node created from Android accessibility information. | ||
/// | ||
/// This object represents Android accessibility information derived from an | ||
/// [AccessibilityNodeInfo] object. The purpose is to verify in integration |
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:
[AccessibilityNodeInfo](https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo)
/// | ||
/// This matcher is intended to compare the accessibility values generated by | ||
/// the Android accessibility bridge, and not the semantics object created by | ||
/// the Flutter framework. |
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.
woops
Forked from #19005