diff options
| author | 2024-04-30 09:43:05 +0000 | |
|---|---|---|
| committer | 2024-04-30 09:43:05 +0000 | |
| commit | 45fbe7800c405e6c06ef38318f8354e2e14aa4a6 (patch) | |
| tree | ba57c6c29af1c75c624f3fad145388c2330c4d1f | |
| parent | 0e2a08779ffc1808b5e2c7c3df4e6061d76d5540 (diff) | |
| parent | 23c688255bc8515de857bd99cded7e37f60b6422 (diff) | |
Merge "Add test enabling OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION" into 24D1-dev
| -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 21c16eb6d3e7..606070c64a2a 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"); |