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

Commit c81f68f6 authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "Add support for search in DownloadManager." into nyc-andromeda-dev

parents 03329d5d 515e5139
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -72,6 +72,32 @@ public class SearchViewUiTest extends ActivityTest<FilesActivity> {
        bots.main.assertSearchTextField(false, query);
    }

    public void testSearchDownloads() throws Exception {
        initTestFiles();
        bots.roots.openRoot(ROOT_0_ID);

        bots.directory.copyFilesToClipboard(fileName1, fileName2);
        device.waitForIdle();

        bots.roots.openRoot("Downloads");
        bots.directory.pasteFilesFromClipboard();

        //TODO: linben Why do we need to click on Downloads again so this will work?
        bots.roots.openRoot("Downloads");
        device.waitForIdle();

        String query = "file12";
        bots.main.openSearchView();
        bots.main.setSearchQuery(query);

        device.pressEnter();

        bots.directory.assertDocumentsCountOnList(true, 1);
        bots.directory.assertDocumentsPresent(fileName2);

        device.pressBack();
    }

    @Suppress
    public void testSearchResultsFound_ClearsOnBack() throws Exception {
        initTestFiles();
@@ -151,4 +177,18 @@ public class SearchViewUiTest extends ActivityTest<FilesActivity> {
        bots.main.assertSearchTextFiledAndIcon(false, false);
    }

    @Override
    public void tearDown() throws Exception {
        try {
            // Proper clean up of #testSearchDownloads
            bots.directory.clickDocument(fileName1 + ".txt");
            bots.directory.clickDocument(fileName2);
            device.waitForIdle();
            bots.main.menuDelete().click();
            bots.main.findDialogOkButton().click();
        } catch (Exception e) {
        } finally {
            super.tearDown();
        }
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;
import android.view.KeyEvent;
import android.view.MotionEvent;

import junit.framework.Assert;
@@ -129,6 +130,17 @@ public class DirectoryListBot extends BaseBot {
        return doc;
    }

    public void copyFilesToClipboard(String...labels) throws UiObjectNotFoundException {
        for (String label: labels) {
            clickDocument(label);
        }
        mDevice.pressKeyCode(KeyEvent.KEYCODE_C, KeyEvent.META_CTRL_ON);
    }

    public void pasteFilesFromClipboard() {
        mDevice.pressKeyCode(KeyEvent.KEYCODE_V, KeyEvent.META_CTRL_ON);
    }

    public UiObject2 getSnackbar(String message) {
        return mDevice.wait(Until.findObject(By.text(message)), mTimeout);
    }