summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZemiao Zhu <zemiao@google.com>2021-01-22 18:45:58 -0800
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-01-27 21:03:26 +0000
commitaad73501dd4ccdbb437f7b9824e8ccafffcc89ac (patch)
tree739c91a7d8d58b5805922e93de32fedda379e4f2
parent0598204e6570fc9a0b4a3217db70fa4007489e7f (diff)
downloadcts-aad73501dd4ccdbb437f7b9824e8ccafffcc89ac.tar.gz
Fix findDocument not functioning.
Bug: 169530947 Test: atest DocumentsTest Change-Id: I28273bced608ac88f95788a8f79eaaefbf2cf3c5 (cherry picked from commit c94c6f893f97431fafe217abb1f62eea2709f976)
-rw-r--r--hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
index 106434f20f4..4c99693f979 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
+++ b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
@@ -100,9 +100,7 @@ public class DocumentsClientTest extends DocumentsClientTestCase {
}
private UiObject findDocument(String label) throws UiObjectNotFoundException {
- final UiSelector docList = new UiSelector().resourceId(
- getDocumentsUiPackageId() + ":id/container_directory").childSelector(
- new UiSelector().resourceId(getDocumentsUiPackageId() + ":id/dir_list"));
+ final UiSelector docList = new UiSelector().resourceId(getDocumentsUiPackageId() + ":id/dir_list");
// Wait for the first list item to appear
assertTrue("First list item",
@@ -117,9 +115,18 @@ public class DocumentsClientTest extends DocumentsClientTestCase {
//do nothing, already be in list mode.
}
- // Now scroll around to find our item
- new UiScrollable(docList).scrollIntoView(new UiSelector().text(label));
- return new UiObject(docList.childSelector(new UiSelector().text(label)));
+ // Repeat swipe gesture to find our item
+ // (UiScrollable#scrollIntoView does not seem to work well with SwipeRefreshLayout)
+ UiObject targetObject = new UiObject(docList.childSelector(new UiSelector().text(label)));
+ int stepLimit = 10;
+ while (!targetObject.exists() && stepLimit-- > 0) {
+ mDevice.swipe(/* startX= */ mDevice.getDisplayWidth() / 2,
+ /* startY= */ mDevice.getDisplayHeight() / 2,
+ /* endX= */ mDevice.getDisplayWidth() / 2,
+ /* endY= */ 0,
+ /* steps= */ 40);
+ }
+ return targetObject;
}
private UiObject findSaveButton() throws UiObjectNotFoundException {