diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 1ffa8891fd..c2e8658401 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -15,9 +15,6 @@ */ package com.android.launcher3; -import static android.app.WindowConfiguration.WINDOW_CONFIG_ROTATION; -import static android.content.pm.ActivityInfo.CONFIG_WINDOW_CONFIGURATION; - import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON; import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON; @@ -46,7 +43,6 @@ import android.app.ActivityOptions; import android.content.Context; import android.content.Intent; import android.content.IntentSender; -import android.content.res.Configuration; import android.hardware.SensorManager; import android.hardware.devicestate.DeviceStateManager; import android.os.Bundle; @@ -653,20 +649,6 @@ public abstract class BaseQuickstepLauncher extends Launcher { } } - @Override - protected boolean compareConfiguration(Configuration oldConfig, Configuration newConfig) { - int diff = newConfig.diff(oldConfig); - if ((diff & CONFIG_WINDOW_CONFIGURATION) != 0) { - long windowDiff = - newConfig.windowConfiguration.diff(oldConfig.windowConfiguration, false); - if ((windowDiff & WINDOW_CONFIG_ROTATION) != 0) { - return true; - } - } - - return super.compareConfiguration(oldConfig, newConfig); - } - @Override public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { super.dump(prefix, fd, writer, args); diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index 1a966e2516..3e3a43178c 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -15,11 +15,6 @@ */ package com.android.quickstep; -import static android.app.WindowConfiguration.WINDOW_CONFIG_ROTATION; -import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; -import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; -import static android.content.pm.ActivityInfo.CONFIG_WINDOW_CONFIGURATION; - import static com.android.launcher3.QuickstepTransitionManager.RECENTS_LAUNCH_DURATION; import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSITION_DURATION; import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSITION_PRE_DELAY; @@ -112,8 +107,6 @@ public final class RecentsActivity extends StatefulActivity { private @Nullable TaskbarManager mTaskbarManager; private @Nullable FallbackTaskbarUIController mTaskbarUIController; - private Configuration mOldConfig; - private StateManager mStateManager; // Strong refs to runners which are cleared when the activity is destroyed @@ -165,7 +158,7 @@ public final class RecentsActivity extends StatefulActivity { @Override public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) { - onHandleConfigChanged(); + onHandleConfigurationChanged(); super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig); } @@ -175,11 +168,8 @@ public final class RecentsActivity extends StatefulActivity { ACTIVITY_TRACKER.handleNewIntent(this); } - /** - * Logic for when device configuration changes (rotation, screen size change, multi-window, - * etc.) - */ - protected void onHandleConfigChanged() { + @Override + protected void onHandleConfigurationChanged() { initDeviceProfile(); AbstractFloatingView.closeOpenViews(this, true, @@ -340,7 +330,6 @@ public final class RecentsActivity extends StatefulActivity { mStateManager = new StateManager<>(this, RecentsState.BG_LAUNCHER); - mOldConfig = new Configuration(getResources().getConfiguration()); initDeviceProfile(); setupViews(); @@ -349,26 +338,6 @@ public final class RecentsActivity extends StatefulActivity { ACTIVITY_TRACKER.handleCreate(this); } - @Override - public void handleConfigurationChanged(Configuration newConfig) { - if (compareConfiguration(mOldConfig, newConfig)) { - onHandleConfigChanged(); - } - mOldConfig.setTo(newConfig); - super.handleConfigurationChanged(newConfig); - } - - private boolean compareConfiguration(Configuration oldConfig, Configuration newConfig) { - int diff = newConfig.diff(oldConfig); - if ((diff & CONFIG_WINDOW_CONFIGURATION) != 0) { - long windowDiff = - newConfig.windowConfiguration.diff(oldConfig.windowConfiguration, false); - return (windowDiff & WINDOW_CONFIG_ROTATION) != 0; - } - - return (diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0; - } - @Override public void onStateSetEnd(RecentsState state) { super.onStateSetEnd(state); diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index fa30b8f739..3bd72fe41d 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -389,10 +389,39 @@ public final class TaskViewUtils { * device is considered in multiWindowMode and things like insets and stuff change * and calculations have to be adjusted in the animations for that */ - public static void composeRecentsSplitLaunchAnimator(int initialTaskId, - @Nullable PendingIntent initialTaskPendingIntent, int secondTaskId, + public static void composeRecentsSplitLaunchAnimator(GroupedTaskView launchingTaskView, + @NonNull StateManager stateManager, @Nullable DepthController depthController, + int initialTaskId, @Nullable PendingIntent initialTaskPendingIntent, int secondTaskId, @NonNull TransitionInfo transitionInfo, SurfaceControl.Transaction t, @NonNull Runnable finishCallback) { + if (launchingTaskView != null) { + AnimatorSet animatorSet = new AnimatorSet(); + animatorSet.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + finishCallback.run(); + } + }); + + final RemoteAnimationTargetCompat[] appTargets = + RemoteAnimationTargetCompat.wrapApps(transitionInfo, t, null /* leashMap */); + final RemoteAnimationTargetCompat[] wallpaperTargets = + RemoteAnimationTargetCompat.wrapNonApps( + transitionInfo, true /* wallpapers */, t, null /* leashMap */); + final RemoteAnimationTargetCompat[] nonAppTargets = + RemoteAnimationTargetCompat.wrapNonApps( + transitionInfo, false /* wallpapers */, t, null /* leashMap */); + final RecentsView recentsView = launchingTaskView.getRecentsView(); + composeRecentsLaunchAnimator(animatorSet, launchingTaskView, + appTargets, wallpaperTargets, nonAppTargets, + true, stateManager, + recentsView, depthController); + + t.apply(); + animatorSet.start(); + return; + } + // TODO: consider initialTaskPendingIntent TransitionInfo.Change splitRoot1 = null; TransitionInfo.Change splitRoot2 = null; @@ -657,6 +686,7 @@ public final class TaskViewUtils { public void onAnimationStart(Animator animation) { if (shown) { for (SurfaceControl leash : auxiliarySurfaces) { + t.setLayer(leash, Integer.MAX_VALUE); t.setAlpha(leash, 0); t.show(leash); } diff --git a/quickstep/src/com/android/quickstep/ViewUtils.java b/quickstep/src/com/android/quickstep/ViewUtils.java index 1fef544e3e..1bb95b97f9 100644 --- a/quickstep/src/com/android/quickstep/ViewUtils.java +++ b/quickstep/src/com/android/quickstep/ViewUtils.java @@ -17,6 +17,7 @@ package com.android.quickstep; import android.graphics.HardwareRenderer; import android.os.Handler; +import android.view.SurfaceControl; import android.view.View; import android.view.ViewRootImpl; @@ -45,22 +46,42 @@ public class ViewUtils { return new FrameHandler(view, onFinishRunnable, canceled).schedule(); } - private static class FrameHandler implements HardwareRenderer.FrameDrawingCallback { + private static class FrameHandler implements HardwareRenderer.FrameDrawingCallback, + ViewRootImpl.SurfaceChangedCallback { final ViewRootImpl mViewRoot; final Runnable mFinishCallback; final BooleanSupplier mCancelled; final Handler mHandler; + boolean mFinished; int mDeferFrameCount = 1; FrameHandler(View view, Runnable finishCallback, BooleanSupplier cancelled) { mViewRoot = view.getViewRootImpl(); + mViewRoot.addSurfaceChangedCallback(this); mFinishCallback = finishCallback; mCancelled = cancelled; mHandler = new Handler(); } + @Override + public void surfaceCreated(SurfaceControl.Transaction t) { + // Do nothing + } + + @Override + public void surfaceReplaced(SurfaceControl.Transaction t) { + // Do nothing + } + + @Override + public void surfaceDestroyed() { + // If the root view is detached, then the app won't get any scheduled frames so we need + // to force-run any pending callbacks + finish(); + } + @Override public void onFrameDraw(long frame) { Utilities.postAsyncCallback(mHandler, this::onFrame); @@ -77,9 +98,7 @@ public class ViewUtils { return; } - if (mFinishCallback != null) { - mFinishCallback.run(); - } + finish(); } private boolean schedule() { @@ -90,5 +109,17 @@ public class ViewUtils { } return false; } + + private void finish() { + if (mFinished) { + return; + } + mFinished = true; + mDeferFrameCount = 0; + if (mFinishCallback != null) { + mFinishCallback.run(); + } + mViewRoot.removeSurfaceChangedCallback(this); + } } } diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index d2a2f36c36..0ca557443f 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -242,8 +242,9 @@ public class SplitSelectStateController { @Override public void startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction t, @NonNull Runnable finishCallback) { - TaskViewUtils.composeRecentsSplitLaunchAnimator(mInitialTaskId, - mInitialTaskPendingIntent, mSecondTaskId, info, t, () -> { + TaskViewUtils.composeRecentsSplitLaunchAnimator(mLaunchingTaskView, mStateManager, + mDepthController, mInitialTaskId, mInitialTaskPendingIntent, mSecondTaskId, + info, t, () -> { finishCallback.run(); if (mSuccessCallback != null) { mSuccessCallback.accept(true); diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 28d094b138..df1ca14de2 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -281,6 +281,8 @@ + + diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 21eba00ee2..cf2a3f8474 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -1004,7 +1004,9 @@ public class InvariantDeviceProfile { allAppsIconSizes[INDEX_DEFAULT] = a.getFloat( R.styleable.ProfileDisplayOption_allAppsIconSize, iconSizes[INDEX_DEFAULT]); - allAppsIconSizes[INDEX_LANDSCAPE] = allAppsIconSizes[INDEX_DEFAULT]; + allAppsIconSizes[INDEX_LANDSCAPE] = a.getFloat( + R.styleable.ProfileDisplayOption_allAppsIconSizeLandscape, + iconSizes[INDEX_DEFAULT]); allAppsIconSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelPortrait, allAppsIconSizes[INDEX_DEFAULT]); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 03ff146edf..e55321b2bf 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -18,8 +18,6 @@ package com.android.launcher3; import static android.app.PendingIntent.FLAG_IMMUTABLE; import static android.app.PendingIntent.FLAG_UPDATE_CURRENT; -import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; -import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; import static android.content.pm.ActivityInfo.CONFIG_UI_MODE; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO; import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; @@ -310,8 +308,6 @@ public class Launcher extends StatefulActivity private static final FloatProperty HOTSEAT_WIDGET_SCALE = HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WIDGET_TRANSITION); - private Configuration mOldConfig; - @Thunk Workspace mWorkspace; @Thunk @@ -466,7 +462,6 @@ public class Launcher extends StatefulActivity super.onCreate(savedInstanceState); LauncherAppState app = LauncherAppState.getInstance(this); - mOldConfig = new Configuration(getResources().getConfiguration()); mModel = app.getModel(); mRotationHelper = new RotationHelper(this); @@ -614,21 +609,6 @@ public class Launcher extends StatefulActivity dispatchDeviceProfileChanged(); } - @Override - public void handleConfigurationChanged(Configuration newConfig) { - if (compareConfiguration(mOldConfig, newConfig)) { - onIdpChanged(false); - } - - mOldConfig.setTo(newConfig); - super.handleConfigurationChanged(newConfig); - } - - protected boolean compareConfiguration(Configuration oldConfig, Configuration newConfig) { - int diff = newConfig.diff(oldConfig); - return (diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0; - } - /** * Initializes the drag controller. */ @@ -638,6 +618,11 @@ public class Launcher extends StatefulActivity @Override public void onIdpChanged(boolean modelPropertiesChanged) { + onHandleConfigurationChanged(); + } + + @Override + protected void onHandleConfigurationChanged() { if (!initDeviceProfile(mDeviceProfile.inv)) { return; } diff --git a/src/com/android/launcher3/statemanager/StatefulActivity.java b/src/com/android/launcher3/statemanager/StatefulActivity.java index eea90919ba..2a890c3d1f 100644 --- a/src/com/android/launcher3/statemanager/StatefulActivity.java +++ b/src/com/android/launcher3/statemanager/StatefulActivity.java @@ -15,10 +15,14 @@ */ package com.android.launcher3.statemanager; +import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; +import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; + import static com.android.launcher3.LauncherState.FLAG_CLOSE_POPUPS; import static com.android.launcher3.LauncherState.FLAG_NON_INTERACTIVE; import android.content.res.Configuration; +import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; @@ -31,6 +35,7 @@ import com.android.launcher3.LauncherRootView; import com.android.launcher3.Utilities; import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory; import com.android.launcher3.statemanager.StateManager.StateHandler; +import com.android.launcher3.util.window.WindowManagerProxy; import com.android.launcher3.views.BaseDragLayer; import java.util.List; @@ -48,6 +53,17 @@ public abstract class StatefulActivity> private LauncherRootView mRootView; + protected Configuration mOldConfig; + private int mOldRotation; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mOldConfig = new Configuration(getResources().getConfiguration()); + mOldRotation = WindowManagerProxy.INSTANCE.get(this).getRotation(this); + } + /** * Create handlers to control the property changes for this activity */ @@ -198,5 +214,21 @@ public abstract class StatefulActivity> * Handles configuration change when system calls {@link #onConfigurationChanged}, or on other * situations that configuration might change. */ - public void handleConfigurationChanged(Configuration newConfig) {} + public void handleConfigurationChanged(Configuration newConfig) { + int diff = newConfig.diff(mOldConfig); + int rotation = WindowManagerProxy.INSTANCE.get(this).getRotation(this); + if ((diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0 + || rotation != mOldRotation) { + onHandleConfigurationChanged(); + } + + mOldConfig.setTo(newConfig); + mOldRotation = rotation; + } + + /** + * Logic for when device configuration changes (rotation, screen size change, multi-window, + * etc.) + */ + protected abstract void onHandleConfigurationChanged(); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java index ff03a50fbc..1326389ab7 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java @@ -20,46 +20,65 @@ import android.graphics.Point; import java.util.Map; public class FullReorderCase { + + /** 5x5 Test + **/ private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "222mm\n" + "222mm\n" + "ad111\n" + "bc111"; - private static final Point MOVE_TO_5x5 = new Point(0, 4); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "222ad\n" + "222bc\n" + "mm111\n" + "mm111"; - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, MOVE_TO_5x5, END_BOARD_STR_5x5); + /** 6x5 Test + **/ private static final String START_BOARD_STR_6x5 = "" + "xxxxxx\n" + "2222mm\n" + "2222mm\n" + "ad1111\n" + "bc1111"; - private static final Point MOVE_TO_6x5 = new Point(0, 4); - private static final String END_BOARD_STR_6x5 = "" + "xxxxxx\n" + "2222ad\n" + "2222bc\n" + "mm1111\n" + "mm1111"; - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, MOVE_TO_6x5, END_BOARD_STR_6x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "22mm\n" + + "admm\n" + + "bc11"; + private static final Point MOVE_TO_4x4 = new Point(0, 3); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "22ad\n" + + "mmbc\n" + + "mm11"; + + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); + public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java index 32bf05a52c..1701390268 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java @@ -20,47 +20,64 @@ import android.graphics.Point; import java.util.Map; public class MoveOutReorderCase { + + /** 5x5 Test + **/ private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "34-m-\n" + "35111\n" + "32111\n" + "32111"; - private static final Point MOVE_TO_5x5 = new Point(1, 2); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "345--\n" + "3m111\n" + "32111\n" + "32111"; - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, MOVE_TO_5x5, END_BOARD_STR_5x5); - + /** 6x5 Test + **/ private static final String START_BOARD_STR_6x5 = "" + "xxxxxx\n" + "34-m--\n" + "351111\n" + "321111\n" + "321111"; - private static final Point MOVE_TO_6x5 = new Point(1, 2); - private static final String END_BOARD_STR_6x5 = "" + "xxxxxx\n" + "345---\n" + "3m1111\n" + "321111\n" + "321111"; - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, MOVE_TO_6x5, END_BOARD_STR_6x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "34-m\n" + + "3511\n" + + "3211"; + private static final Point MOVE_TO_4x4 = new Point(1, 2); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "345-\n" + + "3m11\n" + + "3211"; + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); + public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java index b386946176..bb8d5e9631 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java @@ -17,60 +17,68 @@ package com.android.launcher3.celllayout.testcases; import android.graphics.Point; -import com.android.launcher3.celllayout.CellLayoutBoard; - import java.util.Map; public class PushReorderCase { + + /** 5x5 Test + **/ private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "222m-\n" + "--111\n" + "--333\n" + "-----"; - private static final CellLayoutBoard START_BOARD_5x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR_5x5); - private static final Point MOVE_TO_5x5 = new Point(2, 1); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "--m--\n" + "222--\n" + "--111\n" + "--333"; - private static final CellLayoutBoard END_BOARD_5x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, + MOVE_TO_5x5, END_BOARD_STR_5x5); - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_5x5, - MOVE_TO_5x5, - END_BOARD_5x5); - + /** 6x5 Test + **/ private static final String START_BOARD_STR_6x5 = "" + "xxxxxx\n" + "2222m-\n" + "--111-\n" + "--333-\n" + "------"; - private static final CellLayoutBoard START_BOARD_6x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR_6x5); - private static final Point MOVE_TO_6x5 = new Point(2, 1); - private static final String END_BOARD_STR_6x5 = "" + "xxxxxx\n" + "--m---\n" + "2222--\n" + "--111-\n" + "--333-"; - private static final CellLayoutBoard END_BOARD_6x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, + MOVE_TO_6x5, END_BOARD_STR_6x5); - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_6x5, - MOVE_TO_6x5, - END_BOARD_6x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "222m\n" + + "-111\n" + + "----"; + private static final Point MOVE_TO_4x4 = new Point(2, 1); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "--m-\n" + + "222-\n" + + "-111"; + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java index 57e1398bd2..30269a0f5d 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java @@ -17,35 +17,47 @@ package com.android.launcher3.celllayout.testcases; import android.graphics.Point; -import com.android.launcher3.celllayout.CellLayoutBoard; - import java.util.Map; public class SimpleReorderCase { - private static final String START_BOARD_STR = "" + + /** 5x5 Test + **/ + private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "--mm-\n" + "--mm-\n" + "-----\n" + "-----"; - private static final CellLayoutBoard START_BOARD_5x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR); - private static final Point MOVE_TO_5x5 = new Point(4, 4); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "-----\n" + "-----\n" + "---mm\n" + "---mm"; - private static final CellLayoutBoard END_BOARD_5x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, + MOVE_TO_5x5, END_BOARD_STR_5x5); - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_5x5, - MOVE_TO_5x5, - END_BOARD_5x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "--mm\n" + + "--mm\n" + + "----"; + private static final Point MOVE_TO_4x4 = new Point(3, 3); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "----\n" + + "--mm\n" + + "--mm"; + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(4, 4), TEST_CASE_4x4); }