Skip to content

Commit

Permalink
chore: add am empty AccessibilityNodeInfo creation for future android…
Browse files Browse the repository at this point in the history
…x.test.uiautomator:uiautomator:2.3.0 update
  • Loading branch information
KazuCocoa committed Dec 31, 2023
1 parent 5ae65f9 commit 22f2a13
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,23 @@ public UiAutomation getUiAutomation() {
return getInstrumentation().getUiAutomation();
}

private UiObject2 toUiObject2(Object selector, AccessibilityNodeInfo 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");
}
if (node == null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
// 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;
// }
node = new AccessibilityNodeInfo();
}
Object[] constructorParams = {getUiDevice(), selector, node};
try {
return (UiObject2) uiObject2Constructor.newInstance(constructorParams);
Expand Down

0 comments on commit 22f2a13

Please sign in to comment.