Loading ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java +4 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.launcher3.testing; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import android.app.Activity; import android.app.Application; Loading Loading @@ -248,6 +249,9 @@ public class DebugTestInformationHandler extends TestInformationHandler { return response; } case TestProtocol.REQUEST_MODEL_QUEUE_CLEARED: return getFromExecutorSync(MODEL_EXECUTOR, Bundle::new); default: return super.call(method, arg, extras); } Loading src/com/android/launcher3/testing/TestInformationHandler.java +20 −12 Original line number Diff line number Diff line Loading @@ -47,7 +47,9 @@ import com.android.launcher3.testing.shared.WorkspaceCellCenterRequest; import com.android.launcher3.util.ResourceBasedOverride; import com.android.launcher3.widget.picker.WidgetsFullSheet; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.function.Function; import java.util.function.Supplier; Loading Loading @@ -214,8 +216,7 @@ public class TestInformationHandler implements ResourceBasedOverride { } case TestProtocol.REQUEST_HAS_TIS: { response.putBoolean( TestProtocol.REQUEST_HAS_TIS, false); response.putBoolean(TestProtocol.REQUEST_HAS_TIS, false); return response; } Loading Loading @@ -266,8 +267,7 @@ public class TestInformationHandler implements ResourceBasedOverride { */ private static <S, T> Bundle getUIProperty( BundleSetter<T> bundleSetter, Function<S, T> provider, Supplier<S> targetSupplier) { try { return MAIN_EXECUTOR.submit(() -> { return getFromExecutorSync(MAIN_EXECUTOR, () -> { S target = targetSupplier.get(); if (target == null) { return null; Loading @@ -276,7 +276,15 @@ public class TestInformationHandler implements ResourceBasedOverride { Bundle response = new Bundle(); bundleSetter.set(response, TestProtocol.TEST_INFO_RESPONSE_FIELD, value); return response; }).get(); }); } /** * Executes the callback on the executor and waits for the result */ protected static <T> T getFromExecutorSync(ExecutorService executor, Callable<T> callback) { try { return executor.submit(callback).get(); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } Loading src/com/android/launcher3/testing/shared/TestProtocol.java +1 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ public final class TestProtocol { public static final String REQUEST_GET_OVERVIEW_PAGE_SPACING = "get-overview-page-spacing"; public static final String REQUEST_ENABLE_ROTATION = "enable_rotation"; public static final String REQUEST_ENABLE_SUGGESTION = "enable-suggestion"; public static final String REQUEST_MODEL_QUEUE_CLEARED = "model-queue-cleared"; public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; Loading tests/AndroidManifest-common.xml +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/> <uses-permission android:name="android.permission.READ_LOGS"/> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <application android:debuggable="true" android:extractNativeLibs="true"> <uses-library android:name="android.test.runner"/> Loading tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +14 −6 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import static org.junit.Assume.assumeTrue; import android.content.Intent; import android.graphics.Point; import android.os.SystemClock; import android.platform.test.annotations.IwTest; import androidx.test.filters.LargeTest; Loading Loading @@ -479,7 +478,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { @Test @PortraitLandscape public void testUninstallFromWorkspace() throws Exception { TestUtil.installDummyApp(); installDummyAppAndWaitForUIUpdate(); try { verifyAppUninstalledFromAllApps( createShortcutInCenterIfNotExist(DUMMY_APP_NAME).uninstall(), DUMMY_APP_NAME); Loading @@ -492,10 +491,8 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { @PortraitLandscape @ScreenRecord // (b/256659409) public void testUninstallFromAllApps() throws Exception { TestUtil.installDummyApp(); installDummyAppAndWaitForUIUpdate(); try { // b/256659409 SystemClock.sleep(5000); Workspace workspace = mLauncher.getWorkspace(); final HomeAllApps allApps = workspace.switchToAllApps(); allApps.freeze(); Loading Loading @@ -539,7 +536,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { Point[] gridPositions = getCornersAndCenterPositions(); createShortcutIfNotExist(STORE_APP_NAME, gridPositions[0]); createShortcutIfNotExist(MAPS_APP_NAME, gridPositions[1]); TestUtil.installDummyApp(); installDummyAppAndWaitForUIUpdate(); try { createShortcutIfNotExist(DUMMY_APP_NAME, gridPositions[2]); Map<String, Point> initialPositions = Loading Loading @@ -590,6 +587,17 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { mLauncher.getWorkspace().getHotseatAppIcon(APP_NAME)); } private void installDummyAppAndWaitForUIUpdate() throws IOException { TestUtil.installDummyApp(); // Wait for model thread completion as it may be processing // the install event from the SystemService mLauncher.waitForModelQueueCleared(); // Wait for Launcher UI thread completion, as it may be processing updating the UI in // response to the model update. Not that `waitForLauncherInitialized` is just a proxy // method, we can use any method which touches Launcher UI thread, mLauncher.waitForLauncherInitialized(); } /** * @return List of workspace grid coordinates. Those are not pixels. See {@link * Workspace#getIconGridDimensions()} Loading Loading
ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java +4 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.launcher3.testing; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import android.app.Activity; import android.app.Application; Loading Loading @@ -248,6 +249,9 @@ public class DebugTestInformationHandler extends TestInformationHandler { return response; } case TestProtocol.REQUEST_MODEL_QUEUE_CLEARED: return getFromExecutorSync(MODEL_EXECUTOR, Bundle::new); default: return super.call(method, arg, extras); } Loading
src/com/android/launcher3/testing/TestInformationHandler.java +20 −12 Original line number Diff line number Diff line Loading @@ -47,7 +47,9 @@ import com.android.launcher3.testing.shared.WorkspaceCellCenterRequest; import com.android.launcher3.util.ResourceBasedOverride; import com.android.launcher3.widget.picker.WidgetsFullSheet; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.function.Function; import java.util.function.Supplier; Loading Loading @@ -214,8 +216,7 @@ public class TestInformationHandler implements ResourceBasedOverride { } case TestProtocol.REQUEST_HAS_TIS: { response.putBoolean( TestProtocol.REQUEST_HAS_TIS, false); response.putBoolean(TestProtocol.REQUEST_HAS_TIS, false); return response; } Loading Loading @@ -266,8 +267,7 @@ public class TestInformationHandler implements ResourceBasedOverride { */ private static <S, T> Bundle getUIProperty( BundleSetter<T> bundleSetter, Function<S, T> provider, Supplier<S> targetSupplier) { try { return MAIN_EXECUTOR.submit(() -> { return getFromExecutorSync(MAIN_EXECUTOR, () -> { S target = targetSupplier.get(); if (target == null) { return null; Loading @@ -276,7 +276,15 @@ public class TestInformationHandler implements ResourceBasedOverride { Bundle response = new Bundle(); bundleSetter.set(response, TestProtocol.TEST_INFO_RESPONSE_FIELD, value); return response; }).get(); }); } /** * Executes the callback on the executor and waits for the result */ protected static <T> T getFromExecutorSync(ExecutorService executor, Callable<T> callback) { try { return executor.submit(callback).get(); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } Loading
src/com/android/launcher3/testing/shared/TestProtocol.java +1 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ public final class TestProtocol { public static final String REQUEST_GET_OVERVIEW_PAGE_SPACING = "get-overview-page-spacing"; public static final String REQUEST_ENABLE_ROTATION = "enable_rotation"; public static final String REQUEST_ENABLE_SUGGESTION = "enable-suggestion"; public static final String REQUEST_MODEL_QUEUE_CLEARED = "model-queue-cleared"; public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; Loading
tests/AndroidManifest-common.xml +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/> <uses-permission android:name="android.permission.READ_LOGS"/> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <application android:debuggable="true" android:extractNativeLibs="true"> <uses-library android:name="android.test.runner"/> Loading
tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +14 −6 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import static org.junit.Assume.assumeTrue; import android.content.Intent; import android.graphics.Point; import android.os.SystemClock; import android.platform.test.annotations.IwTest; import androidx.test.filters.LargeTest; Loading Loading @@ -479,7 +478,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { @Test @PortraitLandscape public void testUninstallFromWorkspace() throws Exception { TestUtil.installDummyApp(); installDummyAppAndWaitForUIUpdate(); try { verifyAppUninstalledFromAllApps( createShortcutInCenterIfNotExist(DUMMY_APP_NAME).uninstall(), DUMMY_APP_NAME); Loading @@ -492,10 +491,8 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { @PortraitLandscape @ScreenRecord // (b/256659409) public void testUninstallFromAllApps() throws Exception { TestUtil.installDummyApp(); installDummyAppAndWaitForUIUpdate(); try { // b/256659409 SystemClock.sleep(5000); Workspace workspace = mLauncher.getWorkspace(); final HomeAllApps allApps = workspace.switchToAllApps(); allApps.freeze(); Loading Loading @@ -539,7 +536,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { Point[] gridPositions = getCornersAndCenterPositions(); createShortcutIfNotExist(STORE_APP_NAME, gridPositions[0]); createShortcutIfNotExist(MAPS_APP_NAME, gridPositions[1]); TestUtil.installDummyApp(); installDummyAppAndWaitForUIUpdate(); try { createShortcutIfNotExist(DUMMY_APP_NAME, gridPositions[2]); Map<String, Point> initialPositions = Loading Loading @@ -590,6 +587,17 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { mLauncher.getWorkspace().getHotseatAppIcon(APP_NAME)); } private void installDummyAppAndWaitForUIUpdate() throws IOException { TestUtil.installDummyApp(); // Wait for model thread completion as it may be processing // the install event from the SystemService mLauncher.waitForModelQueueCleared(); // Wait for Launcher UI thread completion, as it may be processing updating the UI in // response to the model update. Not that `waitForLauncherInitialized` is just a proxy // method, we can use any method which touches Launcher UI thread, mLauncher.waitForLauncherInitialized(); } /** * @return List of workspace grid coordinates. Those are not pixels. See {@link * Workspace#getIconGridDimensions()} Loading