Add null check for scroll and fling
Bug: 298243251
Test: presubmit
Change-Id: I73fb3aa0d85460803fef28b32d2e067952d7f05e
diff --git a/test/uiautomator/uiautomator/src/main/java/androidx/test/uiautomator/UiObject2.java b/test/uiautomator/uiautomator/src/main/java/androidx/test/uiautomator/UiObject2.java
index 032cd8a..c4276b5 100644
--- a/test/uiautomator/uiautomator/src/main/java/androidx/test/uiautomator/UiObject2.java
+++ b/test/uiautomator/uiautomator/src/main/java/androidx/test/uiautomator/UiObject2.java
@@ -754,8 +754,12 @@
bounds, swipeDirection, segment, speed, getDisplayId()).pause(250);
// Perform the gesture and return early if we reached the end
- if (mGestureController.performGestureAndWait(
- Until.scrollFinished(direction), SCROLL_TIMEOUT, swipe)) {
+ Boolean scrollFinishedResult = mGestureController.performGestureAndWait(
+ Until.scrollFinished(direction), SCROLL_TIMEOUT, swipe);
+ if (!Boolean.FALSE.equals(scrollFinishedResult)) {
+ if (scrollFinishedResult == null) {
+ Log.i(TAG, "No scroll event received after scroll.");
+ }
return false;
}
}
@@ -919,8 +923,12 @@
// Perform the gesture and return true if we did not reach the end
Log.d(TAG, String.format("Flinging %s (bounds=%s) at %dpx/s.",
direction.name().toLowerCase(), bounds, speed));
- return !mGestureController.performGestureAndWait(
+ Boolean scrollFinishedResult = mGestureController.performGestureAndWait(
Until.scrollFinished(direction), FLING_TIMEOUT, swipe);
+ if (scrollFinishedResult == null) {
+ Log.i(TAG, "No scroll event received after fling.");
+ }
+ return Boolean.FALSE.equals(scrollFinishedResult);
}
/** Sets this object's text content if it is an editable field. */