Loading tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java +13 −35 Original line number Diff line number Diff line package com.android.launcher3.ui; import static org.junit.Assert.assertTrue; import android.content.pm.LauncherActivityInfo; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; import com.android.launcher3.util.Condition; import com.android.launcher3.util.Wait; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -24,37 +16,23 @@ import org.junit.runner.RunWith; public class AllAppsIconToHomeTest extends AbstractLauncherUiTest { @Test @Ignore public void testDragIcon_portrait() throws Throwable { lockRotation(true); performTest(); } @Test @Ignore public void testDragIcon_landscape() throws Throwable { lockRotation(false); performTest(); } private void performTest() throws Throwable { @PortraitLandscape public void testDragIcon() throws Throwable { LauncherActivityInfo settingsApp = getSettingsApp(); clearHomescreen(); mDevice.pressHome(); mDevice.waitForIdle(); // Open all apps and wait for load complete. final UiObject2 appsContainer = TestViewHelpers.openAllApps(); Wait.atMost(null, Condition.minChildCount(appsContainer, 2), DEFAULT_UI_TIMEOUT); // Drag icon to homescreen. UiObject2 icon = scrollAndFind(appsContainer, By.text(settingsApp.getLabel().toString())); TestViewHelpers.dragToWorkspace(icon, true); // Verify that the icon works on homescreen. mDevice.findObject(By.text(settingsApp.getLabel().toString())).click(); assertTrue(mDevice.wait(Until.hasObject(By.pkg( settingsApp.getComponentName().getPackageName()).depth(0)), DEFAULT_UI_TIMEOUT)); final String appName = settingsApp.getLabel().toString(); // 1. Open all apps and wait for load complete. // 2. Drag icon to homescreen. // 3. Verify that the icon works on homescreen. mLauncher.getWorkspace(). switchToAllApps(). getAppIcon(appName). dragToWorkspace(). getWorkspaceAppIcon(appName). launch(settingsApp.getComponentName().getPackageName()); } } tests/src/com/android/launcher3/ui/ShortcutsLaunchTest.java +1 −6 Original line number Diff line number Diff line Loading @@ -6,8 +6,6 @@ import android.content.pm.LauncherActivityInfo; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.Until; import com.android.launcher3.Launcher; import com.android.launcher3.popup.ArrowPopup; Loading Loading @@ -49,9 +47,6 @@ public class ShortcutsLaunchTest extends AbstractLauncherUiTest { final AppIconMenuItem menuItem = menu.getMenuItem(1); final String itemName = menuItem.getText(); menuItem.launch(); assertTrue(mDevice.wait(Until.hasObject(By.pkg( testApp.getComponentName().getPackageName()) .text(itemName)), DEFAULT_UI_TIMEOUT)); menuItem.launch(testApp.getComponentName().getPackageName(), itemName); } } tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java +24 −55 Original line number Diff line number Diff line package com.android.launcher3.ui; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.content.pm.LauncherActivityInfo; import android.graphics.Point; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; import android.view.MotionEvent; import com.android.launcher3.R; import com.android.launcher3.util.Condition; import com.android.launcher3.util.Wait; import com.android.launcher3.tapl.AppIconMenuItem; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -28,51 +18,30 @@ import org.junit.runner.RunWith; public class ShortcutsToHomeTest extends AbstractLauncherUiTest { @Test @Ignore public void testDragIcon_portrait() throws Throwable { lockRotation(true); performTest(); } @Test @Ignore public void testDragIcon_landscape() throws Throwable { lockRotation(false); performTest(); } private void performTest() throws Throwable { @PortraitLandscape public void testDragIcon() throws Throwable { clearHomescreen(); mActivityMonitor.startLauncher(); LauncherActivityInfo testApp = getSettingsApp(); // Open all apps and wait for load complete. final UiObject2 appsContainer = TestViewHelpers.openAllApps(); Wait.atMost(null, Condition.minChildCount(appsContainer, 2), DEFAULT_UI_TIMEOUT); // Find the app and long press it to show shortcuts. UiObject2 icon = scrollAndFind(appsContainer, By.text(testApp.getLabel().toString())); // Press icon center until shortcuts appear Point iconCenter = icon.getVisibleCenter(); TestViewHelpers.sendPointer(MotionEvent.ACTION_DOWN, iconCenter); UiObject2 deepShortcutsContainer = TestViewHelpers.findViewById( R.id.deep_shortcuts_container); assertNotNull(deepShortcutsContainer); TestViewHelpers.sendPointer(MotionEvent.ACTION_UP, iconCenter); // Drag the first shortcut to the home screen. assertTrue(deepShortcutsContainer.getChildCount() > 0); UiObject2 shortcut = deepShortcutsContainer.getChildren().get(1) .findObject(TestViewHelpers.getSelectorForId(R.id.bubble_text)); String shortcutName = shortcut.getText(); TestViewHelpers.dragToWorkspace(shortcut, false); // Verify that the shortcut works on home screen // 1. Open all apps and wait for load complete. // 2. Find the app and long press it to show shortcuts. // 3. Press icon center until shortcuts appear final AppIconMenuItem menuItem = mLauncher. getWorkspace(). switchToAllApps(). getAppIcon(testApp.getLabel().toString()). openMenu(). getMenuItem(0); final String shortcutName = menuItem.getText(); // 4. Drag the first shortcut to the home screen. // 5. Verify that the shortcut works on home screen // (the app opens and has the same text as the shortcut). mDevice.findObject(By.text(shortcutName)).click(); assertTrue(mDevice.wait(Until.hasObject(By.pkg( testApp.getComponentName().getPackageName()) .text(shortcutName)), DEFAULT_UI_TIMEOUT)); menuItem. dragToWorkspace(). getWorkspaceAppIcon(shortcutName). launch(testApp.getComponentName().getPackageName(), shortcutName); } } tests/tapl/com/android/launcher3/tapl/AppIcon.java +3 −26 Original line number Diff line number Diff line Loading @@ -22,47 +22,24 @@ import android.widget.TextView; import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; /** * App icon, whether in all apps or in workspace/ */ public final class AppIcon { private final LauncherInstrumentation mLauncher; private final UiObject2 mIcon; public final class AppIcon extends Launchable { AppIcon(LauncherInstrumentation launcher, UiObject2 icon) { mLauncher = launcher; mIcon = icon; super(launcher, icon); } static BySelector getAppIconSelector(String appName) { return By.clazz(TextView.class).text(appName).pkg(LauncherInstrumentation.LAUNCHER_PKG); } /** * Clicks the icon to launch its app. */ public Background launch(String packageName) { LauncherInstrumentation.log("AppIcon.launch before click " + mIcon.getVisibleCenter()); LauncherInstrumentation.assertTrue( "Launching an app didn't open a new window: " + mIcon.getText(), mIcon.clickAndWait(Until.newWindow(), LauncherInstrumentation.WAIT_TIME_MS)); LauncherInstrumentation.assertTrue( "App didn't start: " + packageName, mLauncher.getDevice().wait(Until.hasObject( By.pkg(packageName).depth(0)), LauncherInstrumentation.WAIT_TIME_MS)); return new Background(mLauncher); } UiObject2 getIcon() { return mIcon; } /** * Long-clicks the icon to open its menu. */ public AppIconMenu openMenu() { final Point iconCenter = mIcon.getVisibleCenter(); final Point iconCenter = mObject.getVisibleCenter(); mLauncher.longTap(iconCenter.x, iconCenter.y); final UiObject2 deepShortcutsContainer = mLauncher.waitForLauncherObject( "deep_shortcuts_container"); Loading tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java +4 −21 Original line number Diff line number Diff line Loading @@ -16,37 +16,20 @@ package com.android.launcher3.tapl; import static org.junit.Assert.assertTrue; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; /** * Menu item in an app icon menu. */ public class AppIconMenuItem { private final LauncherInstrumentation mLauncher; final UiObject2 mShortcut; AppIconMenuItem(LauncherInstrumentation launcher, UiObject2 shortcut) { mLauncher = launcher; mShortcut = shortcut; public class AppIconMenuItem extends Launchable { AppIconMenuItem(LauncherInstrumentation launcher, UiObject2 shortcut) { super(launcher, shortcut); } /** * Returns the visible text of the menu item. */ public String getText() { return mShortcut.getText(); } /** * Launches the action for the menu item. */ public Background launch() { assertTrue("Clicking a menu item didn't open a new window: " + mShortcut.getText(), mShortcut.clickAndWait(Until.newWindow(), LauncherInstrumentation.WAIT_TIME_MS)); return new Background(mLauncher); return mObject.getText(); } } Loading
tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java +13 −35 Original line number Diff line number Diff line package com.android.launcher3.ui; import static org.junit.Assert.assertTrue; import android.content.pm.LauncherActivityInfo; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; import com.android.launcher3.util.Condition; import com.android.launcher3.util.Wait; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -24,37 +16,23 @@ import org.junit.runner.RunWith; public class AllAppsIconToHomeTest extends AbstractLauncherUiTest { @Test @Ignore public void testDragIcon_portrait() throws Throwable { lockRotation(true); performTest(); } @Test @Ignore public void testDragIcon_landscape() throws Throwable { lockRotation(false); performTest(); } private void performTest() throws Throwable { @PortraitLandscape public void testDragIcon() throws Throwable { LauncherActivityInfo settingsApp = getSettingsApp(); clearHomescreen(); mDevice.pressHome(); mDevice.waitForIdle(); // Open all apps and wait for load complete. final UiObject2 appsContainer = TestViewHelpers.openAllApps(); Wait.atMost(null, Condition.minChildCount(appsContainer, 2), DEFAULT_UI_TIMEOUT); // Drag icon to homescreen. UiObject2 icon = scrollAndFind(appsContainer, By.text(settingsApp.getLabel().toString())); TestViewHelpers.dragToWorkspace(icon, true); // Verify that the icon works on homescreen. mDevice.findObject(By.text(settingsApp.getLabel().toString())).click(); assertTrue(mDevice.wait(Until.hasObject(By.pkg( settingsApp.getComponentName().getPackageName()).depth(0)), DEFAULT_UI_TIMEOUT)); final String appName = settingsApp.getLabel().toString(); // 1. Open all apps and wait for load complete. // 2. Drag icon to homescreen. // 3. Verify that the icon works on homescreen. mLauncher.getWorkspace(). switchToAllApps(). getAppIcon(appName). dragToWorkspace(). getWorkspaceAppIcon(appName). launch(settingsApp.getComponentName().getPackageName()); } }
tests/src/com/android/launcher3/ui/ShortcutsLaunchTest.java +1 −6 Original line number Diff line number Diff line Loading @@ -6,8 +6,6 @@ import android.content.pm.LauncherActivityInfo; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.Until; import com.android.launcher3.Launcher; import com.android.launcher3.popup.ArrowPopup; Loading Loading @@ -49,9 +47,6 @@ public class ShortcutsLaunchTest extends AbstractLauncherUiTest { final AppIconMenuItem menuItem = menu.getMenuItem(1); final String itemName = menuItem.getText(); menuItem.launch(); assertTrue(mDevice.wait(Until.hasObject(By.pkg( testApp.getComponentName().getPackageName()) .text(itemName)), DEFAULT_UI_TIMEOUT)); menuItem.launch(testApp.getComponentName().getPackageName(), itemName); } }
tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java +24 −55 Original line number Diff line number Diff line package com.android.launcher3.ui; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.content.pm.LauncherActivityInfo; import android.graphics.Point; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; import android.view.MotionEvent; import com.android.launcher3.R; import com.android.launcher3.util.Condition; import com.android.launcher3.util.Wait; import com.android.launcher3.tapl.AppIconMenuItem; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -28,51 +18,30 @@ import org.junit.runner.RunWith; public class ShortcutsToHomeTest extends AbstractLauncherUiTest { @Test @Ignore public void testDragIcon_portrait() throws Throwable { lockRotation(true); performTest(); } @Test @Ignore public void testDragIcon_landscape() throws Throwable { lockRotation(false); performTest(); } private void performTest() throws Throwable { @PortraitLandscape public void testDragIcon() throws Throwable { clearHomescreen(); mActivityMonitor.startLauncher(); LauncherActivityInfo testApp = getSettingsApp(); // Open all apps and wait for load complete. final UiObject2 appsContainer = TestViewHelpers.openAllApps(); Wait.atMost(null, Condition.minChildCount(appsContainer, 2), DEFAULT_UI_TIMEOUT); // Find the app and long press it to show shortcuts. UiObject2 icon = scrollAndFind(appsContainer, By.text(testApp.getLabel().toString())); // Press icon center until shortcuts appear Point iconCenter = icon.getVisibleCenter(); TestViewHelpers.sendPointer(MotionEvent.ACTION_DOWN, iconCenter); UiObject2 deepShortcutsContainer = TestViewHelpers.findViewById( R.id.deep_shortcuts_container); assertNotNull(deepShortcutsContainer); TestViewHelpers.sendPointer(MotionEvent.ACTION_UP, iconCenter); // Drag the first shortcut to the home screen. assertTrue(deepShortcutsContainer.getChildCount() > 0); UiObject2 shortcut = deepShortcutsContainer.getChildren().get(1) .findObject(TestViewHelpers.getSelectorForId(R.id.bubble_text)); String shortcutName = shortcut.getText(); TestViewHelpers.dragToWorkspace(shortcut, false); // Verify that the shortcut works on home screen // 1. Open all apps and wait for load complete. // 2. Find the app and long press it to show shortcuts. // 3. Press icon center until shortcuts appear final AppIconMenuItem menuItem = mLauncher. getWorkspace(). switchToAllApps(). getAppIcon(testApp.getLabel().toString()). openMenu(). getMenuItem(0); final String shortcutName = menuItem.getText(); // 4. Drag the first shortcut to the home screen. // 5. Verify that the shortcut works on home screen // (the app opens and has the same text as the shortcut). mDevice.findObject(By.text(shortcutName)).click(); assertTrue(mDevice.wait(Until.hasObject(By.pkg( testApp.getComponentName().getPackageName()) .text(shortcutName)), DEFAULT_UI_TIMEOUT)); menuItem. dragToWorkspace(). getWorkspaceAppIcon(shortcutName). launch(testApp.getComponentName().getPackageName(), shortcutName); } }
tests/tapl/com/android/launcher3/tapl/AppIcon.java +3 −26 Original line number Diff line number Diff line Loading @@ -22,47 +22,24 @@ import android.widget.TextView; import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; /** * App icon, whether in all apps or in workspace/ */ public final class AppIcon { private final LauncherInstrumentation mLauncher; private final UiObject2 mIcon; public final class AppIcon extends Launchable { AppIcon(LauncherInstrumentation launcher, UiObject2 icon) { mLauncher = launcher; mIcon = icon; super(launcher, icon); } static BySelector getAppIconSelector(String appName) { return By.clazz(TextView.class).text(appName).pkg(LauncherInstrumentation.LAUNCHER_PKG); } /** * Clicks the icon to launch its app. */ public Background launch(String packageName) { LauncherInstrumentation.log("AppIcon.launch before click " + mIcon.getVisibleCenter()); LauncherInstrumentation.assertTrue( "Launching an app didn't open a new window: " + mIcon.getText(), mIcon.clickAndWait(Until.newWindow(), LauncherInstrumentation.WAIT_TIME_MS)); LauncherInstrumentation.assertTrue( "App didn't start: " + packageName, mLauncher.getDevice().wait(Until.hasObject( By.pkg(packageName).depth(0)), LauncherInstrumentation.WAIT_TIME_MS)); return new Background(mLauncher); } UiObject2 getIcon() { return mIcon; } /** * Long-clicks the icon to open its menu. */ public AppIconMenu openMenu() { final Point iconCenter = mIcon.getVisibleCenter(); final Point iconCenter = mObject.getVisibleCenter(); mLauncher.longTap(iconCenter.x, iconCenter.y); final UiObject2 deepShortcutsContainer = mLauncher.waitForLauncherObject( "deep_shortcuts_container"); Loading
tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java +4 −21 Original line number Diff line number Diff line Loading @@ -16,37 +16,20 @@ package com.android.launcher3.tapl; import static org.junit.Assert.assertTrue; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; /** * Menu item in an app icon menu. */ public class AppIconMenuItem { private final LauncherInstrumentation mLauncher; final UiObject2 mShortcut; AppIconMenuItem(LauncherInstrumentation launcher, UiObject2 shortcut) { mLauncher = launcher; mShortcut = shortcut; public class AppIconMenuItem extends Launchable { AppIconMenuItem(LauncherInstrumentation launcher, UiObject2 shortcut) { super(launcher, shortcut); } /** * Returns the visible text of the menu item. */ public String getText() { return mShortcut.getText(); } /** * Launches the action for the menu item. */ public Background launch() { assertTrue("Clicking a menu item didn't open a new window: " + mShortcut.getText(), mShortcut.clickAndWait(Until.newWindow(), LauncherInstrumentation.WAIT_TIME_MS)); return new Background(mLauncher); return mObject.getText(); } }