Merge "Fix app crash when testing"
diff --git a/tests/common/com/android/documentsui/bots/UiBot.java b/tests/common/com/android/documentsui/bots/UiBot.java
index 0043bf7..4885b6d 100644
--- a/tests/common/com/android/documentsui/bots/UiBot.java
+++ b/tests/common/com/android/documentsui/bots/UiBot.java
@@ -273,18 +273,19 @@
}
UiObject2 findMenuWithName(String label) {
- List<UiObject2> menuItems = mDevice.findObjects(By.clazz("android.widget.LinearLayout"));
+ UiObject2 list = mDevice.findObject(By.clazz("android.widget.ListView"));
+ List<UiObject2> menuItems = list.getChildren();
Iterator<UiObject2> it = menuItems.iterator();
UiObject2 menuItem = null;
while (it.hasNext()) {
menuItem = it.next();
UiObject2 text = menuItem.findObject(By.text(label));
- if (text != null && menuItem.isClickable()) {
- break;
+ if (text != null) {
+ return menuItem;
}
}
- return menuItem;
+ return null;
}
boolean hasMenuWithName(String label) {
diff --git a/tests/functional/com/android/documentsui/RenameDocumentUiTest.java b/tests/functional/com/android/documentsui/RenameDocumentUiTest.java
index 863cdd0..2e66117 100644
--- a/tests/functional/com/android/documentsui/RenameDocumentUiTest.java
+++ b/tests/functional/com/android/documentsui/RenameDocumentUiTest.java
@@ -38,43 +38,43 @@
bots.roots.closeDrawer();
}
-// public void testRenameEnabled_SingleSelection() throws Exception {
-// bots.directory.selectDocument(fileName1, 1);
-// bots.main.openOverflowMenu();
-// bots.main.assertMenuEnabled(R.string.menu_rename, true);
-//
-// // Dismiss more options window
-// device.pressBack();
-// }
-//
-// public void testNoRenameSupport_SingleSelection() throws Exception {
-// bots.directory.selectDocument(fileNameNoRename, 1);
-// bots.main.openOverflowMenu();
-// bots.main.assertMenuEnabled(R.string.menu_rename, false);
-//
-// // Dismiss more options window
-// device.pressBack();
-// }
-//
-// public void testOneHasRenameSupport_MultipleSelection() throws Exception {
-// bots.directory.selectDocument(fileName1, 1);
-// bots.directory.selectDocument(fileNameNoRename, 2);
-// bots.main.openOverflowMenu();
-// bots.main.assertMenuEnabled(R.string.menu_rename, false);
-//
-// // Dismiss more options window
-// device.pressBack();
-// }
-//
-// public void testRenameDisabled_MultipleSelection() throws Exception {
-// bots.directory.selectDocument(fileName1, 1);
-// bots.directory.selectDocument(fileName2, 2);
-// bots.main.openOverflowMenu();
-// bots.main.assertMenuEnabled(R.string.menu_rename, false);
-//
-// // Dismiss more options window
-// device.pressBack();
-// }
+ public void testRenameEnabled_SingleSelection() throws Exception {
+ bots.directory.selectDocument(fileName1, 1);
+ bots.main.openOverflowMenu();
+ bots.main.assertMenuEnabled(R.string.menu_rename, true);
+
+ // Dismiss more options window
+ device.pressBack();
+ }
+
+ public void testNoRenameSupport_SingleSelection() throws Exception {
+ bots.directory.selectDocument(fileNameNoRename, 1);
+ bots.main.openOverflowMenu();
+ bots.main.assertMenuEnabled(R.string.menu_rename, false);
+
+ // Dismiss more options window
+ device.pressBack();
+ }
+
+ public void testOneHasRenameSupport_MultipleSelection() throws Exception {
+ bots.directory.selectDocument(fileName1, 1);
+ bots.directory.selectDocument(fileNameNoRename, 2);
+ bots.main.openOverflowMenu();
+ bots.main.assertMenuEnabled(R.string.menu_rename, false);
+
+ // Dismiss more options window
+ device.pressBack();
+ }
+
+ public void testRenameDisabled_MultipleSelection() throws Exception {
+ bots.directory.selectDocument(fileName1, 1);
+ bots.directory.selectDocument(fileName2, 2);
+ bots.main.openOverflowMenu();
+ bots.main.assertMenuEnabled(R.string.menu_rename, false);
+
+ // Dismiss more options window
+ device.pressBack();
+ }
public void testRenameFile_OkButton() throws Exception {
bots.directory.selectDocument(fileName1, 1);