summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author Garfield Tan <xutan@google.com> 2022-08-11 13:02:18 -0700
committer Garfield Tan <xutan@google.com> 2022-08-11 13:06:23 -0700
commit4b1e9bc7e3772846ebccb93b6f61c26446b2d9a2 (patch)
treeb887d7d76187e0b2eee2130714e8bee3b18cc9c2 /libs
parentfcfe5eeccf819b252aa03a709a1098ed32a6cbde (diff)
Fix ShellTransitionTests on landscape devices
ShellTransitionTests uses the real primary display and DisplayController, and the upside down rotation is 90 degrees on some landscape devices. This CL changes it to a mock so we have better control on its behavior. Bug: 242207533 Test: atest ShellTransitionTests Change-Id: I4cacb79f5a9549f2ad62f42a92b4e01398879b5a
Diffstat (limited to 'libs')
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java33
1 files changed, 8 insertions, 25 deletions
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
index 388792b63db3..764c3cb8eb3c 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
@@ -59,8 +59,6 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
-import android.view.IDisplayWindowListener;
-import android.view.IWindowManager;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.WindowManager;
@@ -82,6 +80,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.common.DisplayController;
+import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.sysui.ShellInit;
@@ -834,16 +833,13 @@ public class ShellTransitionTests extends ShellTestCase {
}
private DisplayController createTestDisplayController() {
- IWindowManager mockWM = mock(IWindowManager.class);
- final IDisplayWindowListener[] displayListener = new IDisplayWindowListener[1];
- try {
- doReturn(new int[]{DEFAULT_DISPLAY}).when(mockWM).registerDisplayWindowListener(any());
- } catch (RemoteException e) {
- // No remote stuff happening, so this can't be hit
- }
- ShellInit shellInit = new ShellInit(mMainExecutor);
- DisplayController out = new DisplayController(mContext, mockWM, shellInit, mMainExecutor);
- shellInit.init();
+ DisplayLayout displayLayout = mock(DisplayLayout.class);
+ doReturn(Surface.ROTATION_180).when(displayLayout).getUpsideDownRotation();
+ // By default we ignore nav bar in deciding if a seamless rotation is allowed.
+ doReturn(true).when(displayLayout).allowSeamlessRotationDespiteNavBarMoving();
+
+ DisplayController out = mock(DisplayController.class);
+ doReturn(displayLayout).when(out).getDisplayLayout(DEFAULT_DISPLAY);
return out;
}
@@ -854,17 +850,4 @@ public class ShellTransitionTests extends ShellTestCase {
shellInit.init();
return t;
}
-//
-// private class TestDisplayController extends DisplayController {
-// private final DisplayLayout mTestDisplayLayout;
-// TestDisplayController() {
-// super(mContext, mock(IWindowManager.class), mMainExecutor);
-// mTestDisplayLayout = new DisplayLayout();
-// mTestDisplayLayout.
-// }
-//
-// @Override
-// DisplayLayout
-// }
-
}