summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2019-06-07 01:34:30 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-06-07 01:34:30 +0000
commit9d14e5520e56049bf88cedfda59a1de53845ea95 (patch)
treeda815c17ec12929c99c51b5fd2dc2b97a719dda9 /tests
parent51d2cf913c18787ec28334737c29ad36f4f7a815 (diff)
parentd4c90e12e9b6b61d3c0374ee5899425c84ffe65b (diff)
downloadandroid_packages_apps_Trebuchet-9d14e5520e56049bf88cedfda59a1de53845ea95.tar.gz
android_packages_apps_Trebuchet-9d14e5520e56049bf88cedfda59a1de53845ea95.tar.bz2
android_packages_apps_Trebuchet-9d14e5520e56049bf88cedfda59a1de53845ea95.zip
Merge "Freezing all apps updates during certain tests" into ub-launcher3-qt-r1-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java184
-rw-r--r--tests/tapl/com/android/launcher3/tapl/AllApps.java22
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java6
3 files changed, 138 insertions, 74 deletions
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 4f8b87c51..d171004fc 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -108,47 +108,63 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
@Test
@Ignore
public void testPressHomeOnAllAppsContextMenu() throws Exception {
- mLauncher.getWorkspace().switchToAllApps().getAppIcon("TestActivity7").openMenu();
+ final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
+ allApps.freeze();
+ try {
+ allApps.getAppIcon("TestActivity7").openMenu();
+ } finally {
+ allApps.unfreeze();
+ }
mLauncher.pressHome();
}
public static void runAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) {
- assertNotNull("allApps parameter is null", allApps);
-
- assertTrue(
- "Launcher internal state is not All Apps", test.isInState(LauncherState.ALL_APPS));
-
- // Test flinging forward and backward.
- test.executeOnLauncher(launcher -> assertEquals(
- "All Apps started in already scrolled state", 0, test.getAllAppsScroll(launcher)));
-
- allApps.flingForward();
- assertTrue("Launcher internal state is not All Apps",
- test.isInState(LauncherState.ALL_APPS));
- final Integer flingForwardY = test.getFromLauncher(
- launcher -> test.getAllAppsScroll(launcher));
- test.executeOnLauncher(
- launcher -> assertTrue("flingForward() didn't scroll App Apps", flingForwardY > 0));
-
- allApps.flingBackward();
- assertTrue(
- "Launcher internal state is not All Apps", test.isInState(LauncherState.ALL_APPS));
- final Integer flingBackwardY = test.getFromLauncher(
- launcher -> test.getAllAppsScroll(launcher));
- test.executeOnLauncher(launcher -> assertTrue("flingBackward() didn't scroll App Apps",
- flingBackwardY < flingForwardY));
-
- // Test scrolling down to YouTube.
- assertNotNull("All apps: can't fine YouTube", allApps.getAppIcon("YouTube"));
- // Test scrolling up to Camera.
- assertNotNull("All apps: can't fine Camera", allApps.getAppIcon("Camera"));
- // Test failing to find a non-existing app.
- final AllApps allAppsFinal = allApps;
- expectFail("All apps: could find a non-existing app",
- () -> allAppsFinal.getAppIcon("NO APP"));
-
- assertTrue(
- "Launcher internal state is not All Apps", test.isInState(LauncherState.ALL_APPS));
+ allApps.freeze();
+ try {
+ assertNotNull("allApps parameter is null", allApps);
+
+ assertTrue(
+ "Launcher internal state is not All Apps",
+ test.isInState(LauncherState.ALL_APPS));
+
+ // Test flinging forward and backward.
+ test.executeOnLauncher(launcher -> assertEquals(
+ "All Apps started in already scrolled state", 0,
+ test.getAllAppsScroll(launcher)));
+
+ allApps.flingForward();
+ assertTrue("Launcher internal state is not All Apps",
+ test.isInState(LauncherState.ALL_APPS));
+ final Integer flingForwardY = test.getFromLauncher(
+ launcher -> test.getAllAppsScroll(launcher));
+ test.executeOnLauncher(
+ launcher -> assertTrue("flingForward() didn't scroll App Apps",
+ flingForwardY > 0));
+
+ allApps.flingBackward();
+ assertTrue(
+ "Launcher internal state is not All Apps",
+ test.isInState(LauncherState.ALL_APPS));
+ final Integer flingBackwardY = test.getFromLauncher(
+ launcher -> test.getAllAppsScroll(launcher));
+ test.executeOnLauncher(launcher -> assertTrue("flingBackward() didn't scroll App Apps",
+ flingBackwardY < flingForwardY));
+
+ // Test scrolling down to YouTube.
+ assertNotNull("All apps: can't fine YouTube", allApps.getAppIcon("YouTube"));
+ // Test scrolling up to Camera.
+ assertNotNull("All apps: can't fine Camera", allApps.getAppIcon("Camera"));
+ // Test failing to find a non-existing app.
+ final AllApps allAppsFinal = allApps;
+ expectFail("All apps: could find a non-existing app",
+ () -> allAppsFinal.getAppIcon("NO APP"));
+
+ assertTrue(
+ "Launcher internal state is not All Apps",
+ test.isInState(LauncherState.ALL_APPS));
+ } finally {
+ allApps.unfreeze();
+ }
}
@Test
@@ -199,12 +215,17 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
}
public static void runIconLaunchFromAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) {
- final AppIcon app = allApps.getAppIcon("TestActivity7");
- assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
- test.executeOnLauncher(launcher -> assertTrue(
- "Launcher activity is the top activity; expecting another activity to be the top "
- + "one",
- test.isInBackground(launcher)));
+ allApps.freeze();
+ try {
+ final AppIcon app = allApps.getAppIcon("TestActivity7");
+ assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
+ test.executeOnLauncher(launcher -> assertTrue(
+ "Launcher activity is the top activity; expecting another activity to be the top "
+ + "one",
+ test.isInBackground(launcher)));
+ } finally {
+ allApps.unfreeze();
+ }
}
@Test
@@ -260,20 +281,23 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
public void testLaunchMenuItem() throws Exception {
if (!TestHelpers.isInLauncherProcess()) return;
- final AppIconMenu menu = mLauncher.
+ final AllApps allApps = mLauncher.
getWorkspace().
- switchToAllApps().
- getAppIcon(APP_NAME).
- openMenu();
-
- executeOnLauncher(
- launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
- isOptionsPopupVisible(launcher)));
+ switchToAllApps();
+ allApps.freeze();
+ try {
+ final AppIconMenu menu = allApps.
+ getAppIcon(APP_NAME).
+ openMenu();
- final AppIconMenuItem menuItem = menu.getMenuItem(1);
- final String itemName = menuItem.getText();
+ executeOnLauncher(
+ launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
+ isOptionsPopupVisible(launcher)));
- menuItem.launch(getAppPackageName());
+ menu.getMenuItem(1).launch(getAppPackageName());
+ } finally {
+ allApps.unfreeze();
+ }
}
@Test
@@ -282,12 +306,18 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
// 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(APP_NAME).
- dragToWorkspace().
- getWorkspaceAppIcon(APP_NAME).
- launch(getAppPackageName());
+ final AllApps allApps = mLauncher.getWorkspace().
+ switchToAllApps();
+ allApps.freeze();
+ try {
+ allApps.
+ getAppIcon(APP_NAME).
+ dragToWorkspace().
+ getWorkspaceAppIcon(APP_NAME).
+ launch(getAppPackageName());
+ } finally {
+ allApps.unfreeze();
+ }
executeOnLauncher(launcher -> assertTrue(
"Launcher activity is the top activity; expecting another activity to be the top "
+ "one",
@@ -302,21 +332,27 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
// 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.
+ final AllApps allApps = mLauncher.
getWorkspace().
- switchToAllApps().
- getAppIcon(APP_NAME).
- 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(getAppPackageName());
+ switchToAllApps();
+ allApps.freeze();
+ try {
+ final AppIconMenuItem menuItem = allApps.
+ getAppIcon(APP_NAME).
+ 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(getAppPackageName());
+ } finally {
+ allApps.unfreeze();
+ }
}
public static String getAppPackageName() {
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index d03035a87..21d763e30 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -48,6 +48,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
"apps_list_view");
// Wait for the recycler to populate.
mLauncher.waitForObjectInContainer(appListRecycler, By.clazz(TextView.class));
+ verifyNotFrozen("All apps freeze flags upon opening all apps");
}
@Override
@@ -210,4 +211,25 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
verifyActiveContainer();
}
}
+
+ /**
+ * Freezes updating app list upon app install/uninstall/update.
+ */
+ public void freeze() {
+ mLauncher.getTestInfo(TestProtocol.REQUEST_FREEZE_APP_LIST);
+ }
+
+ /**
+ * Resumes updating app list upon app install/uninstall/update.
+ */
+ public void unfreeze() {
+ mLauncher.getTestInfo(TestProtocol.REQUEST_UNFREEZE_APP_LIST);
+ verifyNotFrozen("All apps freeze flags upon unfreezing");
+ }
+
+ private void verifyNotFrozen(String message) {
+ mLauncher.assertEquals(message, 0, mLauncher.getTestInfo(
+ TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS).
+ getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD));
+ }
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index e45fca8c0..8ebe52565 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -292,6 +292,12 @@ public final class LauncherInstrumentation {
}
}
+ void assertEquals(String message, long expected, long actual) {
+ if (expected != actual) {
+ fail(message + " expected: " + expected + " but was: " + actual);
+ }
+ }
+
void assertNotEquals(String message, int unexpected, int actual) {
if (unexpected == actual) {
failEquals(message, actual);