Loading quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java +27 −9 Original line number Diff line number Diff line Loading @@ -5,16 +5,18 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.content.Context; import android.os.Bundle; import com.android.launcher3.compat.UserManagerCompat; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.uioverrides.states.OverviewState; import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController; import com.android.launcher3.util.DefaultDisplay; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.model.Task; import java.util.ArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; public class QuickstepTestInformationHandler extends TestInformationHandler { Loading Loading @@ -54,10 +56,8 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { final int leftMargin = MAIN_EXECUTOR.submit(() -> getRecentsView().getLeftGestureMargin()).get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, leftMargin); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } return response; } Loading @@ -67,11 +67,29 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { final int rightMargin = MAIN_EXECUTOR.submit(() -> getRecentsView().getRightGestureMargin()).get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, rightMargin); } catch (ExecutionException e) { e.printStackTrace(); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } return response; } case TestProtocol.REQUEST_RECENT_TASKS_LIST: { ArrayList<String> taskBaseIntentComponents = new ArrayList<>(); CountDownLatch latch = new CountDownLatch(1); RecentsModel.INSTANCE.get(mContext).getTasks((tasks) -> { for (Task t : tasks) { taskBaseIntentComponents.add( t.key.baseIntent.getComponent().flattenToString()); } latch.countDown(); }); try { latch.await(2, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); throw new RuntimeException(e); } response.putStringArrayList(TestProtocol.TEST_INFO_RESPONSE_FIELD, taskBaseIntentComponents); return response; } } Loading quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java +30 −11 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static androidx.test.InstrumentationRegistry.getInstrumentation; import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS; import static com.android.launcher3.tapl.TestHelpers.getHomeIntentInPackage; import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess; import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_ACTIVITY_TIMEOUT; import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_UI_TIMEOUT; import static com.android.launcher3.ui.AbstractLauncherUiTest.resolveSystemApp; import static com.android.launcher3.ui.AbstractLauncherUiTest.startAppFast; Loading @@ -36,6 +37,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.app.Instrumentation; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; Loading @@ -55,7 +57,6 @@ import com.android.launcher3.tapl.TestHelpers; import com.android.launcher3.testcomponent.TestCommandReceiver; import com.android.launcher3.util.Wait; import com.android.launcher3.util.rule.FailureWatcher; import com.android.launcher3.util.rule.SimpleActivityRule; import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch; import com.android.quickstep.views.RecentsView; Loading Loading @@ -86,10 +87,6 @@ public class FallbackRecentsTest { @Rule public final TestRule mOrderSensitiveRules; @Rule public final SimpleActivityRule<RecentsActivity> mActivityMonitor = new SimpleActivityRule(RecentsActivity.class); public FallbackRecentsTest() throws RemoteException { Instrumentation instrumentation = getInstrumentation(); Context context = instrumentation.getContext(); Loading Loading @@ -143,7 +140,7 @@ public class FallbackRecentsTest { @NavigationModeSwitch @Test public void goToOverviewFromApp() { startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); mLauncher.getBackground().switchToOverview(); } Loading @@ -159,7 +156,7 @@ public class FallbackRecentsTest { if (!TestHelpers.isInLauncherProcess()) return null; Object[] result = new Object[1]; Wait.atMost("Failed to get from recents", () -> MAIN_EXECUTOR.submit(() -> { RecentsActivity activity = mActivityMonitor.getActivity(); RecentsActivity activity = RecentsActivity.ACTIVITY_TRACKER.getCreatedActivity(); if (activity == null) { return false; } Loading @@ -177,13 +174,15 @@ public class FallbackRecentsTest { @NavigationModeSwitch @Test public void testOverview() { startAppFast(getAppPackageName()); startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); startAppFastAndWaitForRecentTask(getAppPackageName()); startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); startTestActivity(2); Wait.atMost("Expected three apps in the task list", () -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT); BaseOverview overview = mLauncher.getBackground().switchToOverview(); executeOnRecents( recents -> assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3)); executeOnRecents(recents -> assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3)); // Test flinging forward and backward. overview.flingForward(); Loading Loading @@ -229,4 +228,24 @@ public class FallbackRecentsTest { private int getTaskCount(RecentsActivity recents) { return recents.<RecentsView>getOverviewPanel().getTaskViewCount(); } /** * Workaround for b/141580748, there was an issue where the recent task is only updated when the * activity starting the task is resumed. In this case, we should wait until the task is in * the recents task list before continuing. */ private void startAppFastAndWaitForRecentTask(String packageName) { startAppFast(packageName); Wait.atMost("Expected app in task list", () -> containsRecentTaskWithPackage(packageName), DEFAULT_ACTIVITY_TIMEOUT); } private boolean containsRecentTaskWithPackage(String packageName) { for (ComponentName cn : mLauncher.getRecentTasks()) { if (cn.getPackageName().equals(packageName)) { return true; } } return false; } } src/com/android/launcher3/testing/TestInformationHandler.java +2 −6 Original line number Diff line number Diff line Loading @@ -115,9 +115,7 @@ public class TestInformationHandler implements ResourceBasedOverride { mLauncher.getAppsView().getAppsStore().getDeferUpdatesFlags()).get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, deferUpdatesFlags); } catch (ExecutionException e) { throw new RuntimeException(e); } catch (InterruptedException e) { } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } break; Loading @@ -130,9 +128,7 @@ public class TestInformationHandler implements ResourceBasedOverride { .get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, deferUpdatesFlags); } catch (ExecutionException e) { throw new RuntimeException(e); } catch (InterruptedException e) { } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } break; Loading src/com/android/launcher3/testing/TestProtocol.java +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public final class TestProtocol { public static final String REQUEST_JAVA_LEAK = "java-leak"; public static final String REQUEST_NATIVE_LEAK = "native-leak"; public static final String REQUEST_VIEW_LEAK = "view-leak"; public static final String REQUEST_RECENT_TASKS_LIST = "recent-tasks-list"; public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; Loading tests/tapl/com/android/launcher3/tapl/BaseOverview.java +2 −2 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { final int leftMargin = mLauncher.getTestInfo( TestProtocol.REQUEST_OVERVIEW_LEFT_GESTURE_MARGIN). getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin, 0, 0, 0), 20); mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin + 1, 0, 0, 0), 20); verifyActiveContainer(); } } Loading Loading @@ -89,7 +89,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { final int rightMargin = mLauncher.getTestInfo( TestProtocol.REQUEST_OVERVIEW_RIGHT_GESTURE_MARGIN). getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); mLauncher.scroll(overview, Direction.RIGHT, new Rect(0, 0, rightMargin, 0), 20); mLauncher.scroll(overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20); verifyActiveContainer(); } } Loading Loading
quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java +27 −9 Original line number Diff line number Diff line Loading @@ -5,16 +5,18 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.content.Context; import android.os.Bundle; import com.android.launcher3.compat.UserManagerCompat; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.uioverrides.states.OverviewState; import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController; import com.android.launcher3.util.DefaultDisplay; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.model.Task; import java.util.ArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; public class QuickstepTestInformationHandler extends TestInformationHandler { Loading Loading @@ -54,10 +56,8 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { final int leftMargin = MAIN_EXECUTOR.submit(() -> getRecentsView().getLeftGestureMargin()).get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, leftMargin); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } return response; } Loading @@ -67,11 +67,29 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { final int rightMargin = MAIN_EXECUTOR.submit(() -> getRecentsView().getRightGestureMargin()).get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, rightMargin); } catch (ExecutionException e) { e.printStackTrace(); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } return response; } case TestProtocol.REQUEST_RECENT_TASKS_LIST: { ArrayList<String> taskBaseIntentComponents = new ArrayList<>(); CountDownLatch latch = new CountDownLatch(1); RecentsModel.INSTANCE.get(mContext).getTasks((tasks) -> { for (Task t : tasks) { taskBaseIntentComponents.add( t.key.baseIntent.getComponent().flattenToString()); } latch.countDown(); }); try { latch.await(2, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); throw new RuntimeException(e); } response.putStringArrayList(TestProtocol.TEST_INFO_RESPONSE_FIELD, taskBaseIntentComponents); return response; } } Loading
quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java +30 −11 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static androidx.test.InstrumentationRegistry.getInstrumentation; import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS; import static com.android.launcher3.tapl.TestHelpers.getHomeIntentInPackage; import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess; import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_ACTIVITY_TIMEOUT; import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_UI_TIMEOUT; import static com.android.launcher3.ui.AbstractLauncherUiTest.resolveSystemApp; import static com.android.launcher3.ui.AbstractLauncherUiTest.startAppFast; Loading @@ -36,6 +37,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.app.Instrumentation; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; Loading @@ -55,7 +57,6 @@ import com.android.launcher3.tapl.TestHelpers; import com.android.launcher3.testcomponent.TestCommandReceiver; import com.android.launcher3.util.Wait; import com.android.launcher3.util.rule.FailureWatcher; import com.android.launcher3.util.rule.SimpleActivityRule; import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch; import com.android.quickstep.views.RecentsView; Loading Loading @@ -86,10 +87,6 @@ public class FallbackRecentsTest { @Rule public final TestRule mOrderSensitiveRules; @Rule public final SimpleActivityRule<RecentsActivity> mActivityMonitor = new SimpleActivityRule(RecentsActivity.class); public FallbackRecentsTest() throws RemoteException { Instrumentation instrumentation = getInstrumentation(); Context context = instrumentation.getContext(); Loading Loading @@ -143,7 +140,7 @@ public class FallbackRecentsTest { @NavigationModeSwitch @Test public void goToOverviewFromApp() { startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); mLauncher.getBackground().switchToOverview(); } Loading @@ -159,7 +156,7 @@ public class FallbackRecentsTest { if (!TestHelpers.isInLauncherProcess()) return null; Object[] result = new Object[1]; Wait.atMost("Failed to get from recents", () -> MAIN_EXECUTOR.submit(() -> { RecentsActivity activity = mActivityMonitor.getActivity(); RecentsActivity activity = RecentsActivity.ACTIVITY_TRACKER.getCreatedActivity(); if (activity == null) { return false; } Loading @@ -177,13 +174,15 @@ public class FallbackRecentsTest { @NavigationModeSwitch @Test public void testOverview() { startAppFast(getAppPackageName()); startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); startAppFastAndWaitForRecentTask(getAppPackageName()); startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); startTestActivity(2); Wait.atMost("Expected three apps in the task list", () -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT); BaseOverview overview = mLauncher.getBackground().switchToOverview(); executeOnRecents( recents -> assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3)); executeOnRecents(recents -> assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3)); // Test flinging forward and backward. overview.flingForward(); Loading Loading @@ -229,4 +228,24 @@ public class FallbackRecentsTest { private int getTaskCount(RecentsActivity recents) { return recents.<RecentsView>getOverviewPanel().getTaskViewCount(); } /** * Workaround for b/141580748, there was an issue where the recent task is only updated when the * activity starting the task is resumed. In this case, we should wait until the task is in * the recents task list before continuing. */ private void startAppFastAndWaitForRecentTask(String packageName) { startAppFast(packageName); Wait.atMost("Expected app in task list", () -> containsRecentTaskWithPackage(packageName), DEFAULT_ACTIVITY_TIMEOUT); } private boolean containsRecentTaskWithPackage(String packageName) { for (ComponentName cn : mLauncher.getRecentTasks()) { if (cn.getPackageName().equals(packageName)) { return true; } } return false; } }
src/com/android/launcher3/testing/TestInformationHandler.java +2 −6 Original line number Diff line number Diff line Loading @@ -115,9 +115,7 @@ public class TestInformationHandler implements ResourceBasedOverride { mLauncher.getAppsView().getAppsStore().getDeferUpdatesFlags()).get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, deferUpdatesFlags); } catch (ExecutionException e) { throw new RuntimeException(e); } catch (InterruptedException e) { } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } break; Loading @@ -130,9 +128,7 @@ public class TestInformationHandler implements ResourceBasedOverride { .get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, deferUpdatesFlags); } catch (ExecutionException e) { throw new RuntimeException(e); } catch (InterruptedException e) { } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } break; Loading
src/com/android/launcher3/testing/TestProtocol.java +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public final class TestProtocol { public static final String REQUEST_JAVA_LEAK = "java-leak"; public static final String REQUEST_NATIVE_LEAK = "native-leak"; public static final String REQUEST_VIEW_LEAK = "view-leak"; public static final String REQUEST_RECENT_TASKS_LIST = "recent-tasks-list"; public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; Loading
tests/tapl/com/android/launcher3/tapl/BaseOverview.java +2 −2 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { final int leftMargin = mLauncher.getTestInfo( TestProtocol.REQUEST_OVERVIEW_LEFT_GESTURE_MARGIN). getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin, 0, 0, 0), 20); mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin + 1, 0, 0, 0), 20); verifyActiveContainer(); } } Loading Loading @@ -89,7 +89,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { final int rightMargin = mLauncher.getTestInfo( TestProtocol.REQUEST_OVERVIEW_RIGHT_GESTURE_MARGIN). getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); mLauncher.scroll(overview, Direction.RIGHT, new Rect(0, 0, rightMargin, 0), 20); mLauncher.scroll(overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20); verifyActiveContainer(); } } Loading