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

fix: add an empty AccessibilityNodeInfo creation for future androidx.test.uiautomator:uiautomator:2.3.0 update #589

Merged
merged 5 commits into from
Dec 31, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,26 @@ public UiAutomation getUiAutomation() {
return getInstrumentation().getUiAutomation();
}

private UiObject2 toUiObject2(Object selector, AccessibilityNodeInfo node) {
Object[] constructorParams = {getUiDevice(), selector, node};
private UiObject2 toUiObject2(@Nullable Object selector, @Nullable AccessibilityNodeInfo node) {
if (selector == null) {
// FIXME: The 'selector' should be proper By instance as non-null in the interaction.
Logger.debug("FIXME: selector argument should not be null in androidx.test.uiautomator:uiautomator:2.3.0");
}

// TODO: remove this comment after upgrading to androidx.test.uiautomator:uiautomator:2.3.0
// UiObject2 with androidx.test.uiautomator:uiautomator:2.3.0 has below code to crate the instance,
// thus if the node was None, it should create an empty element for the AccessibilityNodeInfo.
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// AccessibilityWindowInfo window = UiObject2.Api21Impl.getWindow(cachedNode);
// mDisplayId = window == null ? Display.DEFAULT_DISPLAY : UiObject2.Api30Impl.getDisplayId(window);
// } else {
// mDisplayId = Display.DEFAULT_DISPLAY;
// }
AccessibilityNodeInfo accessibilityNodeInfo =
(node == null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
? new AccessibilityNodeInfo()
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Removed cd5692b
I used AS's config so it added these spaces automatically. I guess we could modify config file etc?

: node;
Object[] constructorParams = {getUiDevice(), selector, accessibilityNodeInfo};
try {
return (UiObject2) uiObject2Constructor.newInstance(constructorParams);
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
Expand Down
Loading