diff options
-rw-r--r-- | tests/src/com/android/documentsui/SearchViewUiTest.java | 40 | ||||
-rw-r--r-- | tests/src/com/android/documentsui/bots/DirectoryListBot.java | 12 |
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); } |