Merge "Reducing tests flakiness." into ub-launcher3-master
diff --git a/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java b/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java
deleted file mode 100644
index fdf87be..0000000
--- a/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.android.launcher3.ui;
-
-import android.content.pm.LauncherActivityInfo;
-
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test for dragging an icon from all-apps to homescreen.
- */
-@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class AllAppsIconToHomeTest extends AbstractLauncherUiTest {
-
- @Test
- @PortraitLandscape
- public void testDragIcon() throws Throwable {
- LauncherActivityInfo settingsApp = getSettingsApp();
-
- clearHomescreen();
-
- 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.pressHome().
- switchToAllApps().
- getAppIcon(appName).
- dragToWorkspace().
- getWorkspaceAppIcon(appName).
- launch(settingsApp.getComponentName().getPackageName());
- }
-}
diff --git a/tests/src/com/android/launcher3/ui/ShortcutsLaunchTest.java b/tests/src/com/android/launcher3/ui/ShortcutsLaunchTest.java
deleted file mode 100644
index 1fea4d5..0000000
--- a/tests/src/com/android/launcher3/ui/ShortcutsLaunchTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-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 com.android.launcher3.Launcher;
-import com.android.launcher3.popup.ArrowPopup;
-import com.android.launcher3.tapl.AppIconMenu;
-import com.android.launcher3.tapl.AppIconMenuItem;
-import com.android.launcher3.views.OptionsPopupView;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test for verifying that shortcuts are shown and can be launched after long pressing an app
- */
-@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class ShortcutsLaunchTest extends AbstractLauncherUiTest {
-
- private boolean isOptionsPopupVisible(Launcher launcher) {
- final ArrowPopup popup = OptionsPopupView.getOptionsPopup(launcher);
- return popup != null && popup.isShown();
- }
-
- @Test
- @PortraitLandscape
- public void testAppLauncher() throws Exception {
- mActivityMonitor.startLauncher();
- final LauncherActivityInfo testApp = getSettingsApp();
-
- final AppIconMenu menu = mLauncher.
- pressHome().
- switchToAllApps().
- getAppIcon(testApp.getLabel().toString()).
- openMenu();
-
- executeOnLauncher(
- launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
- isOptionsPopupVisible(launcher)));
-
- final AppIconMenuItem menuItem = menu.getMenuItem(1);
- final String itemName = menuItem.getText();
-
- menuItem.launch(testApp.getComponentName().getPackageName(), itemName);
- }
-}
diff --git a/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java b/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java
deleted file mode 100644
index 4c2c959..0000000
--- a/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.android.launcher3.ui;
-
-import android.content.pm.LauncherActivityInfo;
-
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.launcher3.tapl.AppIconMenuItem;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test for dragging a deep shortcut to the home screen.
- */
-@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class ShortcutsToHomeTest extends AbstractLauncherUiTest {
-
- @Test
- @PortraitLandscape
- public void testDragIcon() throws Throwable {
- clearHomescreen();
- mActivityMonitor.startLauncher();
-
- LauncherActivityInfo testApp = getSettingsApp();
-
- // 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).
- menuItem.
- dragToWorkspace().
- getWorkspaceAppIcon(shortcutName).
- launch(testApp.getComponentName().getPackageName(), shortcutName);
- }
-}
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index ab5761d..47b98fb 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -25,6 +25,7 @@
import static org.junit.Assert.assertTrue;
import android.content.Intent;
+import android.content.pm.LauncherActivityInfo;
import android.util.Log;
import androidx.test.filters.LargeTest;
@@ -33,8 +34,11 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.tapl.AllApps;
import com.android.launcher3.tapl.AppIcon;
+import com.android.launcher3.tapl.AppIconMenu;
+import com.android.launcher3.tapl.AppIconMenuItem;
import com.android.launcher3.tapl.Widgets;
import com.android.launcher3.tapl.Workspace;
import com.android.launcher3.views.OptionsPopupView;
@@ -103,7 +107,8 @@
clearLauncherData();
- mLauncher.pressHome();
+ mDevice.pressHome();
+ waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
waitForResumed("Launcher internal state is still Background");
}
@@ -284,4 +289,72 @@
private int getWidgetsScroll(Launcher launcher) {
return getWidgetsView(launcher).getCurrentScrollY();
}
+
+ private boolean isOptionsPopupVisible(Launcher launcher) {
+ final ArrowPopup popup = OptionsPopupView.getOptionsPopup(launcher);
+ return popup != null && popup.isShown();
+ }
+
+ @Test
+ @PortraitLandscape
+ public void testLaunchMenuItem() throws Exception {
+ final LauncherActivityInfo testApp = getSettingsApp();
+
+ final AppIconMenu menu = mLauncher.
+ getWorkspace().
+ switchToAllApps().
+ getAppIcon(testApp.getLabel().toString()).
+ openMenu();
+
+ executeOnLauncher(
+ launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
+ isOptionsPopupVisible(launcher)));
+
+ final AppIconMenuItem menuItem = menu.getMenuItem(1);
+ final String itemName = menuItem.getText();
+
+ menuItem.launch(testApp.getComponentName().getPackageName(), itemName);
+ }
+
+ @Test
+ @PortraitLandscape
+ public void testDragAppIcon() throws Throwable {
+ LauncherActivityInfo settingsApp = getSettingsApp();
+
+ 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());
+ }
+
+ @Test
+ @PortraitLandscape
+ public void testDragShortcut() throws Throwable {
+ LauncherActivityInfo testApp = getSettingsApp();
+
+ // 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).
+ menuItem.
+ dragToWorkspace().
+ getWorkspaceAppIcon(shortcutName).
+ launch(testApp.getComponentName().getPackageName(), shortcutName);
+ }
}