Wait for launcher state before proceeding next test step
Otherwise if scrollToAppIcon is called immediately, it could
interrupt the state that causes the test to be unable to drag
the icon into workspace.
Fix: 388510107
Flag: TEST_ONLY
Test: atest Launcher3Tests:ThemeIconsTest#testIconWithoutTheme
Change-Id: Ied77b3f8d2f19de18d054a80643f3d13c5641ac4
diff --git a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
index c852729..a123170 100644
--- a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
@@ -61,8 +61,7 @@
setThemeEnabled(false);
new FavoriteItemsTransaction(targetContext()).commit();
loadLauncherSync();
- goToState(LauncherState.ALL_APPS);
- freezeAllApps();
+ switchToAllApps();
scrollToAppIcon(APP_NAME);
BubbleTextView btv = getFromLauncher(
@@ -76,8 +75,7 @@
setThemeEnabled(false);
new FavoriteItemsTransaction(targetContext()).commit();
loadLauncherSync();
- goToState(LauncherState.ALL_APPS);
- freezeAllApps();
+ switchToAllApps();
scrollToAppIcon(TEST_APP_NAME);
BubbleTextView btv = getFromLauncher(l -> findBtv(TEST_APP_NAME, l.getAppsView()));
@@ -95,8 +93,7 @@
setThemeEnabled(true);
new FavoriteItemsTransaction(targetContext()).commit();
loadLauncherSync();
- goToState(LauncherState.ALL_APPS);
- freezeAllApps();
+ switchToAllApps();
scrollToAppIcon(APP_NAME);
BubbleTextView btv = getFromLauncher(l ->
@@ -109,8 +106,7 @@
public void testShortcutIconWithTheme() throws Exception {
setThemeEnabled(true);
loadLauncherSync();
- goToState(LauncherState.ALL_APPS);
- freezeAllApps();
+ switchToAllApps();
scrollToAppIcon(TEST_APP_NAME);
BubbleTextView btv = getFromLauncher(l -> findBtv(TEST_APP_NAME, l.getAppsView()));
@@ -158,6 +154,13 @@
}
}
+ private void switchToAllApps() {
+ goToState(LauncherState.ALL_APPS);
+ waitForState("Launcher internal state didn't switch to All Apps",
+ () -> LauncherState.ALL_APPS);
+ freezeAllApps();
+ }
+
private void scrollToAppIcon(String appName) {
executeOnLauncher(l -> {
l.hideKeyboard();