Loading tests/src/com/android/documentsui/SearchViewUiTest.java +40 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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(); } } } tests/src/com/android/documentsui/bots/DirectoryListBot.java +12 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } Loading Loading
tests/src/com/android/documentsui/SearchViewUiTest.java +40 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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(); } } }
tests/src/com/android/documentsui/bots/DirectoryListBot.java +12 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } Loading