Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d02c8a2a authored by Tony Huang's avatar Tony Huang
Browse files

Fix rename test and re-enable it

Bug: 138560025
Test: atest DocumentsUIGoogleTests
Change-Id: I0205290098e0ed9fe2b2c9b242f4f4cc50f32ab8
parent 7a990adb
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -273,18 +273,19 @@ public class UiBot extends Bots.BaseBot {
    }

    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) {
+37 −37
Original line number Diff line number Diff line
@@ -38,43 +38,43 @@ public class RenameDocumentUiTest extends ActivityTest<FilesActivity> {
        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);