summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ben Lin <linben@google.com> 2016-05-10 21:52:36 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-05-10 21:52:37 +0000
commitc81f68f6c2795fa961c4f2d43ddc4d5a1486b734 (patch)
tree1621a1ab8543e9ab768bd0593bfafd42197ebf0b
parent03329d5d4f83ee517eaae063e446dc40326476fc (diff)
parent515e51391722649479b6bac357fd363ea17de1f7 (diff)
Merge "Add support for search in DownloadManager." into nyc-andromeda-dev
-rw-r--r--tests/src/com/android/documentsui/SearchViewUiTest.java40
-rw-r--r--tests/src/com/android/documentsui/bots/DirectoryListBot.java12
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/src/com/android/documentsui/SearchViewUiTest.java b/tests/src/com/android/documentsui/SearchViewUiTest.java
index a9451a6e3..b6190821c 100644
--- a/tests/src/com/android/documentsui/SearchViewUiTest.java
+++ b/tests/src/com/android/documentsui/SearchViewUiTest.java
@@ -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();
+ }
+ }
}
diff --git a/tests/src/com/android/documentsui/bots/DirectoryListBot.java b/tests/src/com/android/documentsui/bots/DirectoryListBot.java
index 7c1e2196f..e2aabc7c2 100644
--- a/tests/src/com/android/documentsui/bots/DirectoryListBot.java
+++ b/tests/src/com/android/documentsui/bots/DirectoryListBot.java
@@ -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);
}