Loading quickstep/robolectric_tests/src/com/android/quickstep/util/RecentsOrientedStateTest.java 0 → 100644 +89 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.quickstep.util; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_90; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import android.content.Context; import com.android.quickstep.FallbackActivityInterface; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.LooperMode; import org.robolectric.annotation.LooperMode.Mode; /** * Tests for {@link RecentsOrientedState} */ @RunWith(RobolectricTestRunner.class) @LooperMode(Mode.PAUSED) public class RecentsOrientedStateTest { private RecentsOrientedState mR1, mR2; @Before public void setup() { Context context = RuntimeEnvironment.application; mR1 = new RecentsOrientedState(context, FallbackActivityInterface.INSTANCE, i -> { }); mR2 = new RecentsOrientedState(context, FallbackActivityInterface.INSTANCE, i -> { }); assertEquals(mR1.getStateId(), mR2.getStateId()); } @Test public void stateId_changesWithFlags() { mR1.setGestureActive(true); mR2.setGestureActive(false); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.setGestureActive(true); assertEquals(mR1.getStateId(), mR2.getStateId()); } @Test public void stateId_changesWithRecentsRotation() { mR1.setRecentsRotation(ROTATION_90); mR2.setRecentsRotation(ROTATION_180); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.setRecentsRotation(ROTATION_90); assertEquals(mR1.getStateId(), mR2.getStateId()); } @Test public void stateId_changesWithDisplayRotation() { mR1.update(ROTATION_0, ROTATION_90); mR2.update(ROTATION_0, ROTATION_180); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.update(ROTATION_90, ROTATION_90); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.update(ROTATION_90, ROTATION_0); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.update(ROTATION_0, ROTATION_90); assertEquals(mR1.getStateId(), mR2.getStateId()); } } quickstep/robolectric_tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class TaskViewSimulatorTest { if (mAppRotation < 0) { mAppRotation = launcherRotation; } tvs.setLayoutRotation(launcherRotation, mAppRotation); tvs.getOrientationState().update(launcherRotation, mAppRotation); if (mAppInsets == null) { mAppInsets = new Rect(mLauncherInsets); } Loading quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +2 −1 Original line number Diff line number Diff line Loading @@ -378,7 +378,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) { return; } mTaskViewSimulator.setRecentsRotation(mActivity.getDisplay().getRotation()); mTaskViewSimulator.setOrientationState(mRecentsView.getPagedViewOrientedState()); // If we've already ended the gesture and are going home, don't prepare recents UI, // as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL. Loading Loading @@ -686,6 +686,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends dp.updateInsets(targets.homeContentInsets); dp.updateIsSeascape(mContext); initTransitionEndpoints(dp); mTaskViewSimulator.getOrientationState().setMultiWindowMode(dp.isMultiWindowMode); } // Notify when the animation starts Loading quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java +1 −2 Original line number Diff line number Diff line Loading @@ -132,9 +132,8 @@ final class AppToOverviewAnimationProvider<T extends StatefulActivity<?>> extend TaskViewSimulator tsv = new TaskViewSimulator(mActivity, mRecentsView.getSizeStrategy()); tsv.setDp(mActivity.getDeviceProfile()); tsv.setOrientationState(mRecentsView.getPagedViewOrientedState()); tsv.setPreview(runningTaskTarget); tsv.setLayoutRotation(mRecentsView.getPagedViewOrientedState().getTouchRotation(), mRecentsView.getPagedViewOrientedState().getDisplayRotation()); TransformParams params = new TransformParams() .setTargetSet(targets) Loading quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public abstract class SwipeUpAnimationLogic { mTaskViewSimulator = new TaskViewSimulator(context, gestureState.getActivityInterface()); mTransformParams = transformParams; mTaskViewSimulator.setLayoutRotation( mTaskViewSimulator.getOrientationState().update( mDeviceState.getRotationTouchHelper().getCurrentActiveRotation(), mDeviceState.getRotationTouchHelper().getDisplayRotation()); mTaskViewSimulator.setDrawsBelowRecents(true); Loading Loading
quickstep/robolectric_tests/src/com/android/quickstep/util/RecentsOrientedStateTest.java 0 → 100644 +89 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.quickstep.util; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_90; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import android.content.Context; import com.android.quickstep.FallbackActivityInterface; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.LooperMode; import org.robolectric.annotation.LooperMode.Mode; /** * Tests for {@link RecentsOrientedState} */ @RunWith(RobolectricTestRunner.class) @LooperMode(Mode.PAUSED) public class RecentsOrientedStateTest { private RecentsOrientedState mR1, mR2; @Before public void setup() { Context context = RuntimeEnvironment.application; mR1 = new RecentsOrientedState(context, FallbackActivityInterface.INSTANCE, i -> { }); mR2 = new RecentsOrientedState(context, FallbackActivityInterface.INSTANCE, i -> { }); assertEquals(mR1.getStateId(), mR2.getStateId()); } @Test public void stateId_changesWithFlags() { mR1.setGestureActive(true); mR2.setGestureActive(false); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.setGestureActive(true); assertEquals(mR1.getStateId(), mR2.getStateId()); } @Test public void stateId_changesWithRecentsRotation() { mR1.setRecentsRotation(ROTATION_90); mR2.setRecentsRotation(ROTATION_180); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.setRecentsRotation(ROTATION_90); assertEquals(mR1.getStateId(), mR2.getStateId()); } @Test public void stateId_changesWithDisplayRotation() { mR1.update(ROTATION_0, ROTATION_90); mR2.update(ROTATION_0, ROTATION_180); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.update(ROTATION_90, ROTATION_90); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.update(ROTATION_90, ROTATION_0); assertNotEquals(mR1.getStateId(), mR2.getStateId()); mR2.update(ROTATION_0, ROTATION_90); assertEquals(mR1.getStateId(), mR2.getStateId()); } }
quickstep/robolectric_tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class TaskViewSimulatorTest { if (mAppRotation < 0) { mAppRotation = launcherRotation; } tvs.setLayoutRotation(launcherRotation, mAppRotation); tvs.getOrientationState().update(launcherRotation, mAppRotation); if (mAppInsets == null) { mAppInsets = new Rect(mLauncherInsets); } Loading
quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +2 −1 Original line number Diff line number Diff line Loading @@ -378,7 +378,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) { return; } mTaskViewSimulator.setRecentsRotation(mActivity.getDisplay().getRotation()); mTaskViewSimulator.setOrientationState(mRecentsView.getPagedViewOrientedState()); // If we've already ended the gesture and are going home, don't prepare recents UI, // as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL. Loading Loading @@ -686,6 +686,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends dp.updateInsets(targets.homeContentInsets); dp.updateIsSeascape(mContext); initTransitionEndpoints(dp); mTaskViewSimulator.getOrientationState().setMultiWindowMode(dp.isMultiWindowMode); } // Notify when the animation starts Loading
quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java +1 −2 Original line number Diff line number Diff line Loading @@ -132,9 +132,8 @@ final class AppToOverviewAnimationProvider<T extends StatefulActivity<?>> extend TaskViewSimulator tsv = new TaskViewSimulator(mActivity, mRecentsView.getSizeStrategy()); tsv.setDp(mActivity.getDeviceProfile()); tsv.setOrientationState(mRecentsView.getPagedViewOrientedState()); tsv.setPreview(runningTaskTarget); tsv.setLayoutRotation(mRecentsView.getPagedViewOrientedState().getTouchRotation(), mRecentsView.getPagedViewOrientedState().getDisplayRotation()); TransformParams params = new TransformParams() .setTargetSet(targets) Loading
quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public abstract class SwipeUpAnimationLogic { mTaskViewSimulator = new TaskViewSimulator(context, gestureState.getActivityInterface()); mTransformParams = transformParams; mTaskViewSimulator.setLayoutRotation( mTaskViewSimulator.getOrientationState().update( mDeviceState.getRotationTouchHelper().getCurrentActiveRotation(), mDeviceState.getRotationTouchHelper().getDisplayRotation()); mTaskViewSimulator.setDrawsBelowRecents(true); Loading