Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +5 −0 Original line number Diff line number Diff line Loading @@ -1880,6 +1880,11 @@ public class SizeCompatTests extends WindowTestsBase { final int dh = 2500; final int notchHeight = 200; setUpApp(new TestDisplayContent.Builder(mAtm, dw, dh).setNotch(notchHeight).build()); // The test assumes the notch will be at left side when the orientation is landscape. if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_reverseDefaultRotation)) { setReverseDefaultRotation(mActivity.mDisplayContent, false); } addStatusBar(mActivity.mDisplayContent); mActivity.setVisible(false); Loading services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +34 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; Loading @@ -59,6 +60,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import android.annotation.IntDef; Loading Loading @@ -956,6 +958,38 @@ class WindowTestsBase extends SystemServiceTestsBase { return testPlayer; } /** Overrides the behavior of config_reverseDefaultRotation for the given display. */ void setReverseDefaultRotation(DisplayContent dc, boolean reverse) { final DisplayRotation displayRotation = dc.getDisplayRotation(); if (!Mockito.mockingDetails(displayRotation).isSpy()) { spyOn(displayRotation); } doAnswer(invocation -> { invocation.callRealMethod(); final int w = invocation.getArgument(0); final int h = invocation.getArgument(1); if (w > h) { if (reverse) { displayRotation.mPortraitRotation = Surface.ROTATION_90; displayRotation.mUpsideDownRotation = Surface.ROTATION_270; } else { displayRotation.mPortraitRotation = Surface.ROTATION_270; displayRotation.mUpsideDownRotation = Surface.ROTATION_90; } } else { if (reverse) { displayRotation.mLandscapeRotation = Surface.ROTATION_270; displayRotation.mSeascapeRotation = Surface.ROTATION_90; } else { displayRotation.mLandscapeRotation = Surface.ROTATION_90; displayRotation.mSeascapeRotation = Surface.ROTATION_270; } } return null; }).when(displayRotation).configure(anyInt(), anyInt()); displayRotation.configure(dc.mBaseDisplayWidth, dc.mBaseDisplayHeight); } /** * Avoids rotating screen disturbed by some conditions. It is usually used for the default * display that is not the instance of {@link TestDisplayContent} (it bypasses the conditions). Loading Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +5 −0 Original line number Diff line number Diff line Loading @@ -1880,6 +1880,11 @@ public class SizeCompatTests extends WindowTestsBase { final int dh = 2500; final int notchHeight = 200; setUpApp(new TestDisplayContent.Builder(mAtm, dw, dh).setNotch(notchHeight).build()); // The test assumes the notch will be at left side when the orientation is landscape. if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_reverseDefaultRotation)) { setReverseDefaultRotation(mActivity.mDisplayContent, false); } addStatusBar(mActivity.mDisplayContent); mActivity.setVisible(false); Loading
services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +34 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; Loading @@ -59,6 +60,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import android.annotation.IntDef; Loading Loading @@ -956,6 +958,38 @@ class WindowTestsBase extends SystemServiceTestsBase { return testPlayer; } /** Overrides the behavior of config_reverseDefaultRotation for the given display. */ void setReverseDefaultRotation(DisplayContent dc, boolean reverse) { final DisplayRotation displayRotation = dc.getDisplayRotation(); if (!Mockito.mockingDetails(displayRotation).isSpy()) { spyOn(displayRotation); } doAnswer(invocation -> { invocation.callRealMethod(); final int w = invocation.getArgument(0); final int h = invocation.getArgument(1); if (w > h) { if (reverse) { displayRotation.mPortraitRotation = Surface.ROTATION_90; displayRotation.mUpsideDownRotation = Surface.ROTATION_270; } else { displayRotation.mPortraitRotation = Surface.ROTATION_270; displayRotation.mUpsideDownRotation = Surface.ROTATION_90; } } else { if (reverse) { displayRotation.mLandscapeRotation = Surface.ROTATION_270; displayRotation.mSeascapeRotation = Surface.ROTATION_90; } else { displayRotation.mLandscapeRotation = Surface.ROTATION_90; displayRotation.mSeascapeRotation = Surface.ROTATION_270; } } return null; }).when(displayRotation).configure(anyInt(), anyInt()); displayRotation.configure(dc.mBaseDisplayWidth, dc.mBaseDisplayHeight); } /** * Avoids rotating screen disturbed by some conditions. It is usually used for the default * display that is not the instance of {@link TestDisplayContent} (it bypasses the conditions). Loading