Loading tests/common/com/android/documentsui/bots/DirectoryListBot.java +19 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package com.android.documentsui.bots; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled; import static junit.framework.Assert.assertEquals; Loading @@ -24,6 +30,8 @@ import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.hamcrest.Matchers.allOf; import android.app.UiAutomation; import android.content.Context; import android.graphics.Point; Loading @@ -44,6 +52,8 @@ import androidx.test.uiautomator.UiScrollable; import androidx.test.uiautomator.UiSelector; import androidx.test.uiautomator.Until; import com.android.documentsui.R; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -188,7 +198,7 @@ public class DirectoryListBot extends Bots.BaseBot { Configurator.getInstance().setToolType(toolType); } public void selectDocument(String label) throws UiObjectNotFoundException { private void selectDocument(String label) throws UiObjectNotFoundException { waitForDocument(label); UiObject2 selectionHotspot = findSelectionHotspot(label); selectionHotspot.click(); Loading Loading @@ -230,6 +240,14 @@ public class DirectoryListBot extends Bots.BaseBot { return selectionHotspot; } /** * Clicks the "X" cancel selection button. */ public void clearSelection() { onView(allOf(withContentDescription("Cancel"), isDescendantOfA(withId(R.id.toolbar)))).perform(click()); } public void pasteFilesFromClipboard() { mDevice.pressKeyCode(KeyEvent.KEYCODE_V, KeyEvent.META_CTRL_ON); } Loading tests/functional/com/android/documentsui/FileCopyUiTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -520,7 +520,7 @@ public class FileCopyUiTest extends ActivityTest<FilesActivity> { device.waitForIdle(); // Select Download folder. bots.directory.selectDocument("Download"); bots.directory.selectDocument("Download", 1); device.waitForIdle(); // Click copy button. Loading tests/functional/com/android/documentsui/FilesActivityUiTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ public class FilesActivityUiTest extends ActivityTestJunit4<FilesActivity> { } Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor( InspectorActivity.class.getName(), null, false); bots.directory.selectDocument("file0.log"); bots.directory.selectDocument("file0.log", 1); bots.main.clickActionItem("Get info"); monitor.waitForActivityWithTimeout(TIMEOUT); } Loading Loading @@ -274,7 +274,7 @@ public class FilesActivityUiTest extends ActivityTestJunit4<FilesActivity> { // Deselect the file and ensure the share menu disappears (this ensures the menu is // refreshed). bots.directory.selectDocument(fileName); bots.directory.clearSelection(); device.wait(Until.gone(By.desc("Share")), /* timeout= */ 5000); } finally { cleanupFile(fileName, primaryRoot.title); Loading tests/functional/com/android/documentsui/InternalStorageUiTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ public class InternalStorageUiTest extends ActivityTestJunit4<FilesActivity> { public void testRenameFile() throws Exception { createTestFiles(); bots.directory.selectDocument(fileName); bots.directory.selectDocument(fileName, 1); device.waitForIdle(); bots.main.clickRename(); Loading @@ -85,12 +85,12 @@ public class InternalStorageUiTest extends ActivityTestJunit4<FilesActivity> { boolean selected = false; // Delete the added file for not affect user and also avoid error on next test. if (bots.directory.hasDocuments(fileName)) { bots.directory.selectDocument(fileName); bots.directory.selectDocument(fileName, 1); device.waitForIdle(); selected = true; } if (bots.directory.hasDocuments(newFileName)) { bots.directory.selectDocument(newFileName); bots.directory.selectDocument(newFileName, 1); device.waitForIdle(); selected = true; } Loading tests/functional/com/android/documentsui/SearchViewUiTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ public class SearchViewUiTest extends ActivityTestJunit4<FilesActivity> { // Deselect the document and click the clear button on the search view (if the selection bar // at the top is visible this won't be possible). bots.directory.selectDocument(TestFilesRule.FILE_NAME_1); bots.directory.clearSelection(); bots.search.clickSearchViewClearButton(); device.wait(Until.findObject(By.res(pkg + ":id/history_list")), mTimeout); } Loading Loading
tests/common/com/android/documentsui/bots/DirectoryListBot.java +19 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package com.android.documentsui.bots; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled; import static junit.framework.Assert.assertEquals; Loading @@ -24,6 +30,8 @@ import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.hamcrest.Matchers.allOf; import android.app.UiAutomation; import android.content.Context; import android.graphics.Point; Loading @@ -44,6 +52,8 @@ import androidx.test.uiautomator.UiScrollable; import androidx.test.uiautomator.UiSelector; import androidx.test.uiautomator.Until; import com.android.documentsui.R; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -188,7 +198,7 @@ public class DirectoryListBot extends Bots.BaseBot { Configurator.getInstance().setToolType(toolType); } public void selectDocument(String label) throws UiObjectNotFoundException { private void selectDocument(String label) throws UiObjectNotFoundException { waitForDocument(label); UiObject2 selectionHotspot = findSelectionHotspot(label); selectionHotspot.click(); Loading Loading @@ -230,6 +240,14 @@ public class DirectoryListBot extends Bots.BaseBot { return selectionHotspot; } /** * Clicks the "X" cancel selection button. */ public void clearSelection() { onView(allOf(withContentDescription("Cancel"), isDescendantOfA(withId(R.id.toolbar)))).perform(click()); } public void pasteFilesFromClipboard() { mDevice.pressKeyCode(KeyEvent.KEYCODE_V, KeyEvent.META_CTRL_ON); } Loading
tests/functional/com/android/documentsui/FileCopyUiTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -520,7 +520,7 @@ public class FileCopyUiTest extends ActivityTest<FilesActivity> { device.waitForIdle(); // Select Download folder. bots.directory.selectDocument("Download"); bots.directory.selectDocument("Download", 1); device.waitForIdle(); // Click copy button. Loading
tests/functional/com/android/documentsui/FilesActivityUiTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ public class FilesActivityUiTest extends ActivityTestJunit4<FilesActivity> { } Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor( InspectorActivity.class.getName(), null, false); bots.directory.selectDocument("file0.log"); bots.directory.selectDocument("file0.log", 1); bots.main.clickActionItem("Get info"); monitor.waitForActivityWithTimeout(TIMEOUT); } Loading Loading @@ -274,7 +274,7 @@ public class FilesActivityUiTest extends ActivityTestJunit4<FilesActivity> { // Deselect the file and ensure the share menu disappears (this ensures the menu is // refreshed). bots.directory.selectDocument(fileName); bots.directory.clearSelection(); device.wait(Until.gone(By.desc("Share")), /* timeout= */ 5000); } finally { cleanupFile(fileName, primaryRoot.title); Loading
tests/functional/com/android/documentsui/InternalStorageUiTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ public class InternalStorageUiTest extends ActivityTestJunit4<FilesActivity> { public void testRenameFile() throws Exception { createTestFiles(); bots.directory.selectDocument(fileName); bots.directory.selectDocument(fileName, 1); device.waitForIdle(); bots.main.clickRename(); Loading @@ -85,12 +85,12 @@ public class InternalStorageUiTest extends ActivityTestJunit4<FilesActivity> { boolean selected = false; // Delete the added file for not affect user and also avoid error on next test. if (bots.directory.hasDocuments(fileName)) { bots.directory.selectDocument(fileName); bots.directory.selectDocument(fileName, 1); device.waitForIdle(); selected = true; } if (bots.directory.hasDocuments(newFileName)) { bots.directory.selectDocument(newFileName); bots.directory.selectDocument(newFileName, 1); device.waitForIdle(); selected = true; } Loading
tests/functional/com/android/documentsui/SearchViewUiTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ public class SearchViewUiTest extends ActivityTestJunit4<FilesActivity> { // Deselect the document and click the clear button on the search view (if the selection bar // at the top is visible this won't be possible). bots.directory.selectDocument(TestFilesRule.FILE_NAME_1); bots.directory.clearSelection(); bots.search.clickSearchViewClearButton(); device.wait(Until.findObject(By.res(pkg + ":id/history_list")), mTimeout); } Loading