Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ android_library { "tests/tapl/**/*.java", "src/com/android/launcher3/ResourceUtils.java", "src/com/android/launcher3/testing/TestProtocol.java", "src/com/android/launcher3/testing/*Request.java", ], resource_dirs: [ ], manifest: "tests/tapl/AndroidManifest.xml", Loading ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java +3 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.system.Os; import android.view.View; import androidx.annotation.Keep; import androidx.annotation.Nullable; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; Loading Loading @@ -124,7 +125,7 @@ public class DebugTestInformationHandler extends TestInformationHandler { } @Override public Bundle call(String method, String arg) { public Bundle call(String method, String arg, @Nullable Bundle extras) { final Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS: { Loading Loading @@ -219,7 +220,7 @@ public class DebugTestInformationHandler extends TestInformationHandler { } default: return super.call(method, arg); return super.call(method, arg, extras); } } } quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +4 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ import android.content.Context; import android.graphics.Rect; import android.os.Bundle; import androidx.annotation.Nullable; import com.android.launcher3.LauncherState; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.TestProtocol; Loading @@ -21,7 +23,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { } @Override public Bundle call(String method, String arg) { public Bundle call(String method, String arg, @Nullable Bundle extras) { final Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: { Loading Loading @@ -82,7 +84,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { } } return super.call(method, arg); return super.call(method, arg, extras); } @Override Loading src/com/android/launcher3/testing/TestInformationHandler.java +55 −5 Original line number Diff line number Diff line Loading @@ -23,16 +23,23 @@ import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; import android.os.Build; import android.os.Bundle; import android.view.WindowInsets; import androidx.annotation.Nullable; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.Workspace; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.util.ResourceBasedOverride; import com.android.launcher3.widget.picker.WidgetsFullSheet; Loading Loading @@ -62,12 +69,18 @@ public class TestInformationHandler implements ResourceBasedOverride { mLauncherAppState = LauncherAppState.getInstanceNoCreate(); } public Bundle call(String method) { return call(method, /*arg=*/ null); } public Bundle call(String method, String arg) { /** * handle a request and return result Bundle. * * @param method request name. * @param arg optional single string argument. * @param extra extra request payload. */ public Bundle call(String method, String arg, @Nullable Bundle extra) { final Bundle response = new Bundle(); if (extra != null && extra.getClassLoader() == null) { extra.setClassLoader(getClass().getClassLoader()); } switch (method) { case TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT: { return getLauncherUIProperty(Bundle::putInt, l -> { Loading Loading @@ -163,11 +176,48 @@ public class TestInformationHandler implements ResourceBasedOverride { .forceAllowRotationForTesting(Boolean.parseBoolean(arg))); return null; case TestProtocol.REQUEST_WORKSPACE_CELL_LAYOUT_SIZE: return getLauncherUIProperty(Bundle::putIntArray, launcher -> { final Workspace workspace = launcher.getWorkspace(); final int screenId = workspace.getScreenIdForPageIndex( workspace.getCurrentPage()); final CellLayout cellLayout = workspace.getScreenWithId(screenId); return new int[]{cellLayout.getCountX(), cellLayout.getCountY()}; }); case TestProtocol.REQUEST_WORKSPACE_CELL_CENTER: final WorkspaceCellCenterRequest request = extra.getParcelable( TestProtocol.TEST_INFO_REQUEST_FIELD); return getLauncherUIProperty(Bundle::putParcelable, launcher -> { final Workspace workspace = launcher.getWorkspace(); // TODO(b/216387249): allow caller selecting different pages. CellLayout cellLayout = (CellLayout) workspace.getPageAt( workspace.getCurrentPage()); final Rect cellRect = getDescendantRectRelativeToDragLayerForCell(launcher, cellLayout, request.cellX, request.cellY, request.spanX, request.spanY); return new Point(cellRect.centerX(), cellRect.centerY()); }); default: return null; } } private static Rect getDescendantRectRelativeToDragLayerForCell(Launcher launcher, CellLayout cellLayout, int cellX, int cellY, int spanX, int spanY) { final DragLayer dragLayer = launcher.getDragLayer(); final Rect target = new Rect(); cellLayout.cellToRect(cellX, cellY, spanX, spanY, target); int[] leftTop = {target.left, target.top}; int[] rightBottom = {target.right, target.bottom}; dragLayer.getDescendantCoordRelativeToSelf(cellLayout, leftTop); dragLayer.getDescendantCoordRelativeToSelf(cellLayout, rightBottom); target.set(leftTop[0], leftTop[1], rightBottom[0], rightBottom[1]); return target; } protected boolean isLauncherInitialized() { return Launcher.ACTIVITY_TRACKER.getCreatedActivity() == null || LauncherAppState.getInstance(mContext).getModel().isModelLoaded(); Loading src/com/android/launcher3/testing/TestInformationProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class TestInformationProvider extends ContentProvider { if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { TestInformationHandler handler = TestInformationHandler.newInstance(getContext()); handler.init(getContext()); return handler.call(method, arg); return handler.call(method, arg, extras); } return null; } Loading Loading
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ android_library { "tests/tapl/**/*.java", "src/com/android/launcher3/ResourceUtils.java", "src/com/android/launcher3/testing/TestProtocol.java", "src/com/android/launcher3/testing/*Request.java", ], resource_dirs: [ ], manifest: "tests/tapl/AndroidManifest.xml", Loading
ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java +3 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.system.Os; import android.view.View; import androidx.annotation.Keep; import androidx.annotation.Nullable; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; Loading Loading @@ -124,7 +125,7 @@ public class DebugTestInformationHandler extends TestInformationHandler { } @Override public Bundle call(String method, String arg) { public Bundle call(String method, String arg, @Nullable Bundle extras) { final Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS: { Loading Loading @@ -219,7 +220,7 @@ public class DebugTestInformationHandler extends TestInformationHandler { } default: return super.call(method, arg); return super.call(method, arg, extras); } } }
quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +4 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ import android.content.Context; import android.graphics.Rect; import android.os.Bundle; import androidx.annotation.Nullable; import com.android.launcher3.LauncherState; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.TestProtocol; Loading @@ -21,7 +23,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { } @Override public Bundle call(String method, String arg) { public Bundle call(String method, String arg, @Nullable Bundle extras) { final Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: { Loading Loading @@ -82,7 +84,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { } } return super.call(method, arg); return super.call(method, arg, extras); } @Override Loading
src/com/android/launcher3/testing/TestInformationHandler.java +55 −5 Original line number Diff line number Diff line Loading @@ -23,16 +23,23 @@ import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; import android.os.Build; import android.os.Bundle; import android.view.WindowInsets; import androidx.annotation.Nullable; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.Workspace; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.util.ResourceBasedOverride; import com.android.launcher3.widget.picker.WidgetsFullSheet; Loading Loading @@ -62,12 +69,18 @@ public class TestInformationHandler implements ResourceBasedOverride { mLauncherAppState = LauncherAppState.getInstanceNoCreate(); } public Bundle call(String method) { return call(method, /*arg=*/ null); } public Bundle call(String method, String arg) { /** * handle a request and return result Bundle. * * @param method request name. * @param arg optional single string argument. * @param extra extra request payload. */ public Bundle call(String method, String arg, @Nullable Bundle extra) { final Bundle response = new Bundle(); if (extra != null && extra.getClassLoader() == null) { extra.setClassLoader(getClass().getClassLoader()); } switch (method) { case TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT: { return getLauncherUIProperty(Bundle::putInt, l -> { Loading Loading @@ -163,11 +176,48 @@ public class TestInformationHandler implements ResourceBasedOverride { .forceAllowRotationForTesting(Boolean.parseBoolean(arg))); return null; case TestProtocol.REQUEST_WORKSPACE_CELL_LAYOUT_SIZE: return getLauncherUIProperty(Bundle::putIntArray, launcher -> { final Workspace workspace = launcher.getWorkspace(); final int screenId = workspace.getScreenIdForPageIndex( workspace.getCurrentPage()); final CellLayout cellLayout = workspace.getScreenWithId(screenId); return new int[]{cellLayout.getCountX(), cellLayout.getCountY()}; }); case TestProtocol.REQUEST_WORKSPACE_CELL_CENTER: final WorkspaceCellCenterRequest request = extra.getParcelable( TestProtocol.TEST_INFO_REQUEST_FIELD); return getLauncherUIProperty(Bundle::putParcelable, launcher -> { final Workspace workspace = launcher.getWorkspace(); // TODO(b/216387249): allow caller selecting different pages. CellLayout cellLayout = (CellLayout) workspace.getPageAt( workspace.getCurrentPage()); final Rect cellRect = getDescendantRectRelativeToDragLayerForCell(launcher, cellLayout, request.cellX, request.cellY, request.spanX, request.spanY); return new Point(cellRect.centerX(), cellRect.centerY()); }); default: return null; } } private static Rect getDescendantRectRelativeToDragLayerForCell(Launcher launcher, CellLayout cellLayout, int cellX, int cellY, int spanX, int spanY) { final DragLayer dragLayer = launcher.getDragLayer(); final Rect target = new Rect(); cellLayout.cellToRect(cellX, cellY, spanX, spanY, target); int[] leftTop = {target.left, target.top}; int[] rightBottom = {target.right, target.bottom}; dragLayer.getDescendantCoordRelativeToSelf(cellLayout, leftTop); dragLayer.getDescendantCoordRelativeToSelf(cellLayout, rightBottom); target.set(leftTop[0], leftTop[1], rightBottom[0], rightBottom[1]); return target; } protected boolean isLauncherInitialized() { return Launcher.ACTIVITY_TRACKER.getCreatedActivity() == null || LauncherAppState.getInstance(mContext).getModel().isModelLoaded(); Loading
src/com/android/launcher3/testing/TestInformationProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class TestInformationProvider extends ContentProvider { if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { TestInformationHandler handler = TestInformationHandler.newInstance(getContext()); handler.init(getContext()); return handler.call(method, arg); return handler.call(method, arg, extras); } return null; } Loading