diff options
| author | 2024-04-26 15:18:02 +0000 | |
|---|---|---|
| committer | 2024-04-30 08:27:24 +0000 | |
| commit | 23c688255bc8515de857bd99cded7e37f60b6422 (patch) | |
| tree | a013da20a9470f9b8285b57ad7527085778891fe | |
| parent | 44925d14d1a638ee77f482d09a9bc8260b205f56 (diff) | |
Add test enabling OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION
Fix: 336760087
Test: atest SizeCompatTests
Change-Id: I6a44d18f1a21cb4d4dbb93564fd3615d7861a566
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 8641267be2cb..6befd714bda3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -4154,11 +4154,49 @@ public class SizeCompatTests extends WindowTestsBase { } @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"); |