diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 4c9a8e7c3d..6f47df06a6 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -334,20 +334,31 @@ 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 AllApps allApps = mLauncher. - getWorkspace(). - switchToAllApps(); + final AllApps allApps = mLauncher + .getWorkspace() + .switchToAllApps(); allApps.freeze(); try { - final AppIconMenuItem menuItem = allApps. - getAppIcon(APP_NAME). - openMenu(). - getMenuItem(0); - final String shortcutName = menuItem.getText(); - assertEquals("Wrong menu item", "Shortcut 3", shortcutName); + final AppIconMenu menu = allApps + .getAppIcon(APP_NAME) + .openMenu(); + final AppIconMenuItem menuItem0 = menu.getMenuItem(0); + final AppIconMenuItem menuItem2 = menu.getMenuItem(2); + + final AppIconMenuItem menuItem; + + final String expectedShortcutName = "Shortcut 3"; + if (menuItem0.getText().equals(expectedShortcutName)) { + menuItem = menuItem0; + } else { + final String shortcutName2 = menuItem2.getText(); + assertEquals("Wrong menu item", expectedShortcutName, shortcutName2); + menuItem = menuItem2; + } menuItem.dragToWorkspace(false, false); - mLauncher.getWorkspace().getWorkspaceAppIcon(shortcutName).launch(getAppPackageName()); + mLauncher.getWorkspace().getWorkspaceAppIcon(expectedShortcutName) + .launch(getAppPackageName()); } finally { allApps.unfreeze(); }