Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +38 −0 Original line number Diff line number Diff line Loading @@ -4153,12 +4153,50 @@ public class SizeCompatTests extends WindowTestsBase { assertEquals(sizeCompatScaled, mActivity.getBounds()); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION}) public void testPortraitCloseToSquareDisplayWithTaskbar_insetsOverridden_notLetterboxed() { // Set up portrait close to square display. setUpDisplaySizeWithApp(2200, 2280); final DisplayContent display = mActivity.mDisplayContent; display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Simulate insets, final app bounds are (0, 0, 2200, 2130) - landscape. final WindowState navbar = createWindow(null, TYPE_NAVIGATION_BAR, mDisplayContent, "navbar"); final Binder owner = new Binder(); navbar.mAttrs.providedInsets = new InsetsFrameProvider[] { new InsetsFrameProvider(owner, 0, WindowInsets.Type.navigationBars()) .setInsetsSize(Insets.of(0, 0, 0, 150)) }; display.getDisplayPolicy().addWindowLw(navbar, navbar.mAttrs); assertTrue(display.getDisplayPolicy().updateDecorInsetsInfo()); display.sendNewConfiguration(); final ActivityRecord activity = new ActivityBuilder(mAtm) .setTask(mTask) .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) .setComponent(ComponentName.createRelative(mContext, SizeCompatTests.class.getName())) .setUid(android.os.Process.myUid()) .build(); // Activity should not be letterboxed and should have portrait app bounds even though // orientation is not respected with insets as insets have been decoupled. final Rect appBounds = activity.getWindowConfiguration().getAppBounds(); final Rect displayBounds = display.getBounds(); assertFalse(activity.isLetterboxedForFixedOrientationAndAspectRatio()); assertNotNull(appBounds); assertEquals(displayBounds.width(), appBounds.width()); assertEquals(displayBounds.height(), appBounds.height()); } @Test @DisableCompatChanges({ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED}) public void testPortraitCloseToSquareDisplayWithTaskbar_letterboxed() { // Set up portrait close to square display setUpDisplaySizeWithApp(2200, 2280); final DisplayContent display = mActivity.mDisplayContent; display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Simulate taskbar, final app bounds are (0, 0, 2200, 2130) - landscape final WindowState navbar = createWindow(null, TYPE_NAVIGATION_BAR, mDisplayContent, "navbar"); Loading Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +38 −0 Original line number Diff line number Diff line Loading @@ -4153,12 +4153,50 @@ public class SizeCompatTests extends WindowTestsBase { assertEquals(sizeCompatScaled, mActivity.getBounds()); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION}) public void testPortraitCloseToSquareDisplayWithTaskbar_insetsOverridden_notLetterboxed() { // Set up portrait close to square display. setUpDisplaySizeWithApp(2200, 2280); final DisplayContent display = mActivity.mDisplayContent; display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Simulate insets, final app bounds are (0, 0, 2200, 2130) - landscape. final WindowState navbar = createWindow(null, TYPE_NAVIGATION_BAR, mDisplayContent, "navbar"); final Binder owner = new Binder(); navbar.mAttrs.providedInsets = new InsetsFrameProvider[] { new InsetsFrameProvider(owner, 0, WindowInsets.Type.navigationBars()) .setInsetsSize(Insets.of(0, 0, 0, 150)) }; display.getDisplayPolicy().addWindowLw(navbar, navbar.mAttrs); assertTrue(display.getDisplayPolicy().updateDecorInsetsInfo()); display.sendNewConfiguration(); final ActivityRecord activity = new ActivityBuilder(mAtm) .setTask(mTask) .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) .setComponent(ComponentName.createRelative(mContext, SizeCompatTests.class.getName())) .setUid(android.os.Process.myUid()) .build(); // Activity should not be letterboxed and should have portrait app bounds even though // orientation is not respected with insets as insets have been decoupled. final Rect appBounds = activity.getWindowConfiguration().getAppBounds(); final Rect displayBounds = display.getBounds(); assertFalse(activity.isLetterboxedForFixedOrientationAndAspectRatio()); assertNotNull(appBounds); assertEquals(displayBounds.width(), appBounds.width()); assertEquals(displayBounds.height(), appBounds.height()); } @Test @DisableCompatChanges({ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED}) public void testPortraitCloseToSquareDisplayWithTaskbar_letterboxed() { // Set up portrait close to square display setUpDisplaySizeWithApp(2200, 2280); final DisplayContent display = mActivity.mDisplayContent; display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Simulate taskbar, final app bounds are (0, 0, 2200, 2130) - landscape final WindowState navbar = createWindow(null, TYPE_NAVIGATION_BAR, mDisplayContent, "navbar"); Loading