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

Commit b100b4a3 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix missing test condition of TransparentPolicy

These code should be included in [1], but it was dropped accidentally
when rebasing patchset. This simply restores the changes. Otherwise
the tests will fail when enabling the flag.
[1]: Id9861c908420961efb945e36fb50a13ea4de7e8f

Bug: 278097747
Flag: com.android.window.flags.respect_non_top_visible_fixed_orientation
Test: atest TransparentPolicyTest
Change-Id: I168e72bfbe3727b0420ae5cb77c9ae63488bd387
parent ef5d30ac
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -335,6 +335,8 @@ class TransparentPolicy {
            // Do not enable the policy if the activity can affect display orientation.
            final int orientation = mActivityRecord.getOverrideOrientation();
            return orientation == SCREEN_ORIENTATION_UNSPECIFIED
                    // This "!condition" is true if the activity is multi-window mode or the
                    // display ignores requested orientation.
                    || !mActivityRecord.handlesOrientationChangeFromDescendant(orientation);
        }

+0 −5
Original line number Diff line number Diff line
@@ -134,11 +134,6 @@ class AppCompatActivityRobot {
                isUnresizable);
    }

    void configureTopActivityIgnoreOrientationRequest(boolean ignoreOrientationRequest) {
        mActivityStack.top().mDisplayContent
                .setIgnoreOrientationRequest(ignoreOrientationRequest);
    }

    void configureUnresizableTopActivity(@ActivityInfo.ScreenOrientation int screenOrientation) {
        configureTopActivity(/* minAspect */ -1, /* maxAspect */ -1, screenOrientation,
                /* isUnresizable */ true);
+13 −7
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
    public void testPolicyRunningWhenTransparentIsUsed() {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.activity().setIgnoreOrientationRequest(true);
                ta.launchTransparentActivityInTask();

                ta.checkTopActivityTransparentPolicyStartNotInvoked();
@@ -85,6 +86,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
    public void testCleanLetterboxConfigListenerWhenTranslucentIsDestroyed() {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.activity().setIgnoreOrientationRequest(true);
                ta.launchTransparentActivityInTask();
                ta.checkTopActivityTransparentPolicyStartNotInvoked();
                ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ true);
@@ -102,6 +104,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
    public void testApplyStrategyAgainWhenOpaqueIsDestroyed() {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.activity().setIgnoreOrientationRequest(true);
                ta.launchOpaqueActivityInTask();
                ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ false);

@@ -133,6 +136,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
    public void testNotApplyStrategyAgainWhenOpaqueIsNotDestroyed() {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.activity().setIgnoreOrientationRequest(true);
                ta.launchOpaqueActivityInTask();
                ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ false);

@@ -152,7 +156,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
                ta.applyOnActivity((a) -> {
                    a.configureTopActivity(/* minAspect */ 1.2f, /* maxAspect */ 1.5f,
                            SCREEN_ORIENTATION_PORTRAIT, /* isUnresizable */ true);
                    a.configureTopActivityIgnoreOrientationRequest(true);
                    a.setIgnoreOrientationRequest(true);
                    a.launchActivity(/* minAspect */ 1.1f, /* maxAspect */ 3f,
                            SCREEN_ORIENTATION_LANDSCAPE, /* transparent */true,
                            /* withComponent */ false, /* addToTask */true);
@@ -172,6 +176,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
    public void testApplyStrategyToTransparentActivitiesRetainsWindowConfigurationProperties() {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.activity().setIgnoreOrientationRequest(true);
                ta.launchTransparentActivity();

                ta.forceChangeInTopActivityConfiguration();
@@ -186,6 +191,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
    public void testApplyStrategyToMultipleTranslucentActivities() {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.activity().setIgnoreOrientationRequest(true);
                ta.launchTransparentActivityInTask();
                ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ true);
                ta.checkTopActivityHasInheritedBoundsFrom(/* fromTop */ 1);
@@ -214,7 +220,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
    @Test
    public void testNotRunStrategyToTranslucentActivitiesIfRespectOrientation() {
        runTestScenario(robot -> robot.transparentActivity(ta -> ta.applyOnActivity((a) -> {
            a.configureTopActivityIgnoreOrientationRequest(false);
            a.setIgnoreOrientationRequest(false);
            // The translucent activity is SCREEN_ORIENTATION_PORTRAIT.
            ta.launchTransparentActivityInTask();
            // Though TransparentPolicyState will be started, it won't be considered as running.
@@ -222,7 +228,7 @@ public class TransparentPolicyTest extends WindowTestsBase {

            // If the display changes to ignore orientation request, e.g. unfold, the policy should
            // take effect.
            a.configureTopActivityIgnoreOrientationRequest(true);
            a.setIgnoreOrientationRequest(true);
            ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ true);
            ta.setDisplayContentBounds(0, 0, 900, 1800);
            ta.checkTopActivityHasInheritedBoundsFrom(/* fromTop */ 1);
@@ -234,7 +240,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.applyOnActivity((a) -> {
                    a.configureTopActivityIgnoreOrientationRequest(true);
                    a.setIgnoreOrientationRequest(true);
                    a.configureUnresizableTopActivity(SCREEN_ORIENTATION_PORTRAIT);
                    a.rotateDisplayForTopActivity(ROTATION_90);
                    a.checkTopActivityInSizeCompatMode(/* inScm */ true);
@@ -257,7 +263,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
            robot.transparentActivity((ta) -> {
                ta.applyOnActivity((a) -> {
                    a.configureUnresizableTopActivity(SCREEN_ORIENTATION_PORTRAIT);
                    a.configureTopActivityIgnoreOrientationRequest(true);
                    a.setIgnoreOrientationRequest(true);
                    ta.launchTransparentActivity();

                    a.assertFalseOnTopActivity(ActivityRecord::fillsParent);
@@ -284,7 +290,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
                                .setLetterboxHorizontalPositionMultiplier(1.0f);
                    });
                    a.configureUnresizableTopActivity(SCREEN_ORIENTATION_PORTRAIT);
                    a.configureTopActivityIgnoreOrientationRequest(true);
                    a.setIgnoreOrientationRequest(true);
                    ta.launchTransparentActivityInTask();
                    ta.checkTopActivityHasInheritedBoundsFrom(/* fromTop */ 1);

@@ -309,7 +315,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.applyOnActivity((a) -> {
                    a.configureTopActivityIgnoreOrientationRequest(true);
                    a.setIgnoreOrientationRequest(true);
                    a.configureUnresizableTopActivity(SCREEN_ORIENTATION_PORTRAIT);
                    // Rotate to put activity in size compat mode.
                    a.rotateDisplayForTopActivity(ROTATION_90);