Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72964985 authored by Graciela Putri's avatar Graciela Putri Committed by Automerger Merge Worker
Browse files

Merge "Add test enabling OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION" into...

Merge "Add test enabling OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION" into 24D1-dev am: 45fbe780

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/27115177



Change-Id: Icc26b0385fe50d9c702849f1fc88471443bed691
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4ff9eb1e 45fbe780
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -4192,12 +4192,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");