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

Commit e5edf047 authored by Ben Lin's avatar Ben Lin
Browse files

Fix ContextMenuTest and RenameUiTest on Angler.

When doing consecutive selections, due the fact we are using
GestureDetector, consecutive selections that happen too close to each
other can result it being recognized as double-clicking. By making sure
"1 selected" appears first, we can wait a bit longer to make sure
onSingleTapConfirmed() gets called in the code as opposed to
onDoubleTap().

Bug: 31568862
Change-Id: I639b1854766d1a338b3ab397a4e6309885dba5a9
parent eea1434b
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -134,10 +134,18 @@ public class DirectoryListBot extends Bots.BaseBot {
        findDocument(label).click();
    }

    public void selectDocument(String label) throws UiObjectNotFoundException {
    /**
     * @param label The filename of the document
     * @param number Which nth document it is. The number corresponding to "n selected"
     */
    public void selectDocument(String label, int number) throws UiObjectNotFoundException {
        waitForDocument(label);
        UiObject2 selectionHotspot = findSelectionHotspot(label);
        selectionHotspot.click();

        // wait until selection is fully done to avoid future click being registered as double
        // clicking
        assertSelection(number);
    }

    public UiObject2 findSelectionHotspot(String label) {
+3 −3
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class ContextMenuUiTest extends ActivityTest<ManageActivity> {
    public void setUp() throws Exception {
        super.setUp();
        initTestFiles();
        bots.roots.closeDrawer();
        menuItems = new HashMap<>();

        menuItems.put("Share", false);
@@ -96,9 +97,8 @@ public class ContextMenuUiTest extends ActivityTest<ManageActivity> {
        menuItems.put("Cut", true);
        menuItems.put("Copy", true);
        menuItems.put("Delete", true);
        bots.directory.selectDocument("file1.png");
        bots.directory.selectDocument("Dir1");
        bots.directory.assertSelection(2); //wait until selection is fully done
        bots.directory.selectDocument("file1.png", 1);
        bots.directory.selectDocument("Dir1", 2);
        bots.directory.rightClickDocument("Dir1");
        bots.menu.assertPresentMenuItems(menuItems);
    }
+11 −12
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.documentsui;

import android.support.test.uiautomator.UiObjectNotFoundException;
import android.test.suitebuilder.annotation.LargeTest;

import com.android.documentsui.R;
import com.android.documentsui.R.string;
import com.android.documentsui.manager.ManageActivity;
@@ -41,7 +40,7 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {

    // TODO: Move this over to the FilesMenuManagerTest.
    public void testRenameEnabled_SingleSelection() throws Exception {
        bots.directory.selectDocument(fileName1);
        bots.directory.selectDocument(fileName1, 1);
        bots.main.openOverflowMenu();
        bots.main.assertMenuEnabled(R.string.menu_rename, true);

@@ -51,7 +50,7 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {

    // TODO: Move this over to the FilesMenuManagerTest.
    public void testNoRenameSupport_SingleSelection() throws Exception {
        bots.directory.selectDocument(fileNameNoRename);
        bots.directory.selectDocument(fileNameNoRename, 1);
        bots.main.openOverflowMenu();
        bots.main.assertMenuEnabled(R.string.menu_rename, false);

@@ -61,8 +60,8 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {

    // TODO: Move this over to the FilesMenuManagerTest.
    public void testOneHasRenameSupport_MultipleSelection() throws Exception {
        bots.directory.selectDocument(fileName1);
        bots.directory.selectDocument(fileNameNoRename);
        bots.directory.selectDocument(fileName1, 1);
        bots.directory.selectDocument(fileNameNoRename, 2);
        bots.main.openOverflowMenu();
        bots.main.assertMenuEnabled(R.string.menu_rename, false);

@@ -72,8 +71,8 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {

    // TODO: Move this over to the FilesMenuManagerTest.
    public void testRenameDisabled_MultipleSelection() throws Exception {
        bots.directory.selectDocument(fileName1);
        bots.directory.selectDocument(fileName2);
        bots.directory.selectDocument(fileName1, 1);
        bots.directory.selectDocument(fileName2, 2);
        bots.main.openOverflowMenu();
        bots.main.assertMenuEnabled(R.string.menu_rename, false);

@@ -82,7 +81,7 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {
    }

    public void testRenameFile_OkButton() throws Exception {
        bots.directory.selectDocument(fileName1);
        bots.directory.selectDocument(fileName1, 1);

        clickRename();

@@ -98,7 +97,7 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {
    }

    public void testRenameFile_Enter() throws Exception {
        bots.directory.selectDocument(fileName1);
        bots.directory.selectDocument(fileName1, 1);

        clickRename();

@@ -114,7 +113,7 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {
    }

    public void testRenameFile_Cancel() throws Exception {
        bots.directory.selectDocument(fileName1);
        bots.directory.selectDocument(fileName1, 1);

        clickRename();

@@ -130,7 +129,7 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {
    public void testRenameDir() throws Exception {
        String oldName = "Dir1";
        String newName = "Dir123";
        bots.directory.selectDocument(oldName);
        bots.directory.selectDocument(oldName, 1);

        clickRename();

@@ -146,7 +145,7 @@ public class RenameDocumentUiTest extends ActivityTest<ManageActivity> {
    public void testRename_NameExists() throws Exception {
        // Check that document with the new name exists
        bots.directory.assertDocumentsPresent(fileName2);
        bots.directory.selectDocument(fileName1);
        bots.directory.selectDocument(fileName1, 1);

        clickRename();

+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public class SidebarUiTest extends ActivityTest<ManageActivity> {

    @Suppress
    public void testRootChanged_ClearSelection() throws Exception {
        bots.directory.selectDocument(fileName1);
        bots.directory.selectDocument(fileName1, 1);
        bots.main.assertInActionMode(true);

        bots.roots.openRoot(ROOT_1_ID);