Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java +35 −53 Original line number Diff line number Diff line Loading @@ -77,7 +77,6 @@ import org.mockito.MockitoAnnotations; public class BackAnimationControllerTest { private static final String ANIMATION_ENABLED = "1"; private final TestShellExecutor mShellExecutor = new TestShellExecutor(); @Rule Loading Loading @@ -184,7 +183,8 @@ public class BackAnimationControllerTest { // b/207481538, we check that the surface is not moved for now, we can re-enable this once // we implement the animation verify(mTransaction, never()).setScale(eq(screenshotSurface), anyInt(), anyInt()); verify(mTransaction, never()).setPosition(animationTarget.leash, 100, 100); verify(mTransaction, never()).setPosition( animationTarget.leash, 100, 100); verify(mTransaction, atLeastOnce()).apply(); } Loading Loading @@ -218,11 +218,8 @@ public class BackAnimationControllerTest { // Check that back start and progress is dispatched when first move. doMotionEvent(MotionEvent.ACTION_MOVE, 100); verify(mIOnBackInvokedCallback).onBackStarted(); // Check that back progress is dispatched. doMotionEvent(MotionEvent.ACTION_MOVE, 100); ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class); verify(mIOnBackInvokedCallback, atLeastOnce()).onBackProgressed(backEventCaptor.capture()); verify(mIOnBackInvokedCallback).onBackProgressed(backEventCaptor.capture()); assertEquals(animationTarget, backEventCaptor.getValue().getDepartingAnimationTarget()); // Check that back invocation is dispatched. Loading @@ -231,6 +228,33 @@ public class BackAnimationControllerTest { verify(mIOnBackInvokedCallback).onBackInvoked(); } @Test public void animationDisabledFromSettings() throws RemoteException { // Toggle the setting off Settings.Global.putString(mContentResolver, Settings.Global.ENABLE_BACK_ANIMATION, "0"); mController = new BackAnimationController( mShellExecutor, new Handler(mTestableLooper.getLooper()), mTransaction, mActivityTaskManager, mContext, mContentResolver); mController.setBackToLauncherCallback(mIOnBackInvokedCallback); RemoteAnimationTarget animationTarget = createAnimationTarget(); IOnBackInvokedCallback appCallback = mock(IOnBackInvokedCallback.class); ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class); createNavigationInfo(animationTarget, null, null, BackNavigationInfo.TYPE_RETURN_TO_HOME, appCallback); triggerBackGesture(); verify(appCallback, never()).onBackStarted(); verify(appCallback, never()).onBackProgressed(backEventCaptor.capture()); verify(appCallback, times(1)).onBackInvoked(); verify(mIOnBackInvokedCallback, never()).onBackStarted(); verify(mIOnBackInvokedCallback, never()).onBackProgressed(backEventCaptor.capture()); verify(mIOnBackInvokedCallback, never()).onBackInvoked(); } @Test public void ignoresGesture_transitionInProgress() throws RemoteException { mController.setBackToLauncherCallback(mIOnBackInvokedCallback); Loading @@ -245,22 +269,13 @@ public class BackAnimationControllerTest { reset(mIOnBackInvokedCallback); // Verify that we prevent animation from restarting if another gestures happens before // the previous transition is finished. mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0), MotionEvent.ACTION_DOWN, BackEvent.EDGE_LEFT); doMotionEvent(MotionEvent.ACTION_DOWN, 0); verifyNoMoreInteractions(mIOnBackInvokedCallback); // Verify that we start accepting gestures again once transition finishes. mController.onBackToLauncherAnimationFinished(); mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0), MotionEvent.ACTION_DOWN, BackEvent.EDGE_LEFT); mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 100, 100, 0), MotionEvent.ACTION_MOVE, BackEvent.EDGE_LEFT); doMotionEvent(MotionEvent.ACTION_DOWN, 0); doMotionEvent(MotionEvent.ACTION_MOVE, 100); verify(mIOnBackInvokedCallback).onBackStarted(); } Loading @@ -276,44 +291,11 @@ public class BackAnimationControllerTest { // Simulate transition timeout. mShellExecutor.flushAll(); mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0), MotionEvent.ACTION_DOWN, BackEvent.EDGE_LEFT); mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 100, 100, 0), MotionEvent.ACTION_MOVE, BackEvent.EDGE_LEFT); doMotionEvent(MotionEvent.ACTION_DOWN, 0); doMotionEvent(MotionEvent.ACTION_MOVE, 100); verify(mIOnBackInvokedCallback).onBackStarted(); } @Test public void animationDisabledFromSettings() throws RemoteException { // Toggle the setting off Settings.Global.putString(mContentResolver, Settings.Global.ENABLE_BACK_ANIMATION, "0"); mController = new BackAnimationController( mShellExecutor, new Handler(mTestableLooper.getLooper()), mTransaction, mActivityTaskManager, mContext, mContentResolver); mController.setBackToLauncherCallback(mIOnBackInvokedCallback); RemoteAnimationTarget animationTarget = createAnimationTarget(); IOnBackInvokedCallback appCallback = mock(IOnBackInvokedCallback.class); ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class); createNavigationInfo(animationTarget, null, null, BackNavigationInfo.TYPE_RETURN_TO_HOME, appCallback); triggerBackGesture(); verify(appCallback, never()).onBackStarted(); verify(appCallback, never()).onBackProgressed(backEventCaptor.capture()); verify(appCallback, times(1)).onBackInvoked(); verify(mIOnBackInvokedCallback, never()).onBackStarted(); verify(mIOnBackInvokedCallback, never()).onBackProgressed(backEventCaptor.capture()); verify(mIOnBackInvokedCallback, never()).onBackInvoked(); } private void doMotionEvent(int actionDown, int coordinate) { mController.onMotionEvent( MotionEvent.obtain(0, mEventTime, actionDown, coordinate, coordinate, 0), Loading Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java +35 −53 Original line number Diff line number Diff line Loading @@ -77,7 +77,6 @@ import org.mockito.MockitoAnnotations; public class BackAnimationControllerTest { private static final String ANIMATION_ENABLED = "1"; private final TestShellExecutor mShellExecutor = new TestShellExecutor(); @Rule Loading Loading @@ -184,7 +183,8 @@ public class BackAnimationControllerTest { // b/207481538, we check that the surface is not moved for now, we can re-enable this once // we implement the animation verify(mTransaction, never()).setScale(eq(screenshotSurface), anyInt(), anyInt()); verify(mTransaction, never()).setPosition(animationTarget.leash, 100, 100); verify(mTransaction, never()).setPosition( animationTarget.leash, 100, 100); verify(mTransaction, atLeastOnce()).apply(); } Loading Loading @@ -218,11 +218,8 @@ public class BackAnimationControllerTest { // Check that back start and progress is dispatched when first move. doMotionEvent(MotionEvent.ACTION_MOVE, 100); verify(mIOnBackInvokedCallback).onBackStarted(); // Check that back progress is dispatched. doMotionEvent(MotionEvent.ACTION_MOVE, 100); ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class); verify(mIOnBackInvokedCallback, atLeastOnce()).onBackProgressed(backEventCaptor.capture()); verify(mIOnBackInvokedCallback).onBackProgressed(backEventCaptor.capture()); assertEquals(animationTarget, backEventCaptor.getValue().getDepartingAnimationTarget()); // Check that back invocation is dispatched. Loading @@ -231,6 +228,33 @@ public class BackAnimationControllerTest { verify(mIOnBackInvokedCallback).onBackInvoked(); } @Test public void animationDisabledFromSettings() throws RemoteException { // Toggle the setting off Settings.Global.putString(mContentResolver, Settings.Global.ENABLE_BACK_ANIMATION, "0"); mController = new BackAnimationController( mShellExecutor, new Handler(mTestableLooper.getLooper()), mTransaction, mActivityTaskManager, mContext, mContentResolver); mController.setBackToLauncherCallback(mIOnBackInvokedCallback); RemoteAnimationTarget animationTarget = createAnimationTarget(); IOnBackInvokedCallback appCallback = mock(IOnBackInvokedCallback.class); ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class); createNavigationInfo(animationTarget, null, null, BackNavigationInfo.TYPE_RETURN_TO_HOME, appCallback); triggerBackGesture(); verify(appCallback, never()).onBackStarted(); verify(appCallback, never()).onBackProgressed(backEventCaptor.capture()); verify(appCallback, times(1)).onBackInvoked(); verify(mIOnBackInvokedCallback, never()).onBackStarted(); verify(mIOnBackInvokedCallback, never()).onBackProgressed(backEventCaptor.capture()); verify(mIOnBackInvokedCallback, never()).onBackInvoked(); } @Test public void ignoresGesture_transitionInProgress() throws RemoteException { mController.setBackToLauncherCallback(mIOnBackInvokedCallback); Loading @@ -245,22 +269,13 @@ public class BackAnimationControllerTest { reset(mIOnBackInvokedCallback); // Verify that we prevent animation from restarting if another gestures happens before // the previous transition is finished. mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0), MotionEvent.ACTION_DOWN, BackEvent.EDGE_LEFT); doMotionEvent(MotionEvent.ACTION_DOWN, 0); verifyNoMoreInteractions(mIOnBackInvokedCallback); // Verify that we start accepting gestures again once transition finishes. mController.onBackToLauncherAnimationFinished(); mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0), MotionEvent.ACTION_DOWN, BackEvent.EDGE_LEFT); mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 100, 100, 0), MotionEvent.ACTION_MOVE, BackEvent.EDGE_LEFT); doMotionEvent(MotionEvent.ACTION_DOWN, 0); doMotionEvent(MotionEvent.ACTION_MOVE, 100); verify(mIOnBackInvokedCallback).onBackStarted(); } Loading @@ -276,44 +291,11 @@ public class BackAnimationControllerTest { // Simulate transition timeout. mShellExecutor.flushAll(); mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0), MotionEvent.ACTION_DOWN, BackEvent.EDGE_LEFT); mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 100, 100, 0), MotionEvent.ACTION_MOVE, BackEvent.EDGE_LEFT); doMotionEvent(MotionEvent.ACTION_DOWN, 0); doMotionEvent(MotionEvent.ACTION_MOVE, 100); verify(mIOnBackInvokedCallback).onBackStarted(); } @Test public void animationDisabledFromSettings() throws RemoteException { // Toggle the setting off Settings.Global.putString(mContentResolver, Settings.Global.ENABLE_BACK_ANIMATION, "0"); mController = new BackAnimationController( mShellExecutor, new Handler(mTestableLooper.getLooper()), mTransaction, mActivityTaskManager, mContext, mContentResolver); mController.setBackToLauncherCallback(mIOnBackInvokedCallback); RemoteAnimationTarget animationTarget = createAnimationTarget(); IOnBackInvokedCallback appCallback = mock(IOnBackInvokedCallback.class); ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class); createNavigationInfo(animationTarget, null, null, BackNavigationInfo.TYPE_RETURN_TO_HOME, appCallback); triggerBackGesture(); verify(appCallback, never()).onBackStarted(); verify(appCallback, never()).onBackProgressed(backEventCaptor.capture()); verify(appCallback, times(1)).onBackInvoked(); verify(mIOnBackInvokedCallback, never()).onBackStarted(); verify(mIOnBackInvokedCallback, never()).onBackProgressed(backEventCaptor.capture()); verify(mIOnBackInvokedCallback, never()).onBackInvoked(); } private void doMotionEvent(int actionDown, int coordinate) { mController.onMotionEvent( MotionEvent.obtain(0, mEventTime, actionDown, coordinate, coordinate, 0), Loading