Skip to content
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

Merged

Conversation

jonahwilliams
Copy link
Member

Forked from #19005

// found in the LICENSE file.

/// WARNING: These APIs are only supported internally for testing the flutter
/// framework.
Copy link
Contributor

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.

Copy link
Contributor

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.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

@jonahwilliams jonahwilliams requested review from Hixie and removed request for goderbauer August 6, 2018 20:17

/// A Dart VM implementation of a Size.
///
/// Created to mirror the implementation of `Size` from 'dart:ui'
Copy link
Contributor

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.

Copy link
Contributor

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)

@Hixie
Copy link
Contributor

Hixie commented Aug 7, 2018

I don't really understand how this works? There doesn't seem to be any actual logic to read anything from Android here.

@Hixie
Copy link
Contributor

Hixie commented Aug 7, 2018

Ah, never mind, I see it in #19005.

@Hixie
Copy link
Contributor

Hixie commented Aug 8, 2018

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.

Copy link
Contributor

@amirh amirh left a 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));
Copy link
Contributor

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?

Copy link
Member Author

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'];
Copy link
Contributor

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...

Copy link
Member Author

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'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this SemanticFlag.isEnabled?

Copy link
Member Author

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'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member Author

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'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member Author

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();
Copy link
Contributor

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.
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous sentence

Copy link
Contributor

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++) {
Copy link
Contributor

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];
Copy link
Contributor

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?

Copy link
Member Author

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>[];
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RIP continue outer, Fixed!

Copy link
Contributor

@amirh amirh left a 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
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops

@jonahwilliams jonahwilliams merged commit 99b3829 into flutter:master Aug 23, 2018
@jonahwilliams jonahwilliams deleted the android_semantics_integration_test branch August 23, 2018 05:56
Hixie added a commit that referenced this pull request Aug 23, 2018
…lityNodeInfo generated by Flutter (#19700)"

This reverts commit 99b3829.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants