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

Commit 4514c53a authored by Mina Granic's avatar Mina Granic Committed by Android (Google) Code Review
Browse files

Merge "Fix tests by specifying flag values." into main

parents 310aa0ce 9023a77a
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER;
import static android.content.pm.ActivityInfo.OVERRIDE_CAMERA_COMPAT_DISABLE_SIMULATE_REQUESTED_ORIENTATION;
import static android.content.pm.ActivityInfo.OVERRIDE_CAMERA_COMPAT_ENABLE_FREEFORM_WINDOWING_TREATMENT;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
@@ -133,6 +134,7 @@ import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.RemoteException;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
import android.provider.DeviceConfig;
@@ -736,6 +738,8 @@ public class ActivityRecordTests extends WindowTestsBase {
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING)
    @DisableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING_OPT_OUT)
    public void testOrientation_dontAllowFixedOrientationForCameraCompatFreeformIfNotEnabled() {
        final ActivityRecord activity = setupDisplayAndActivityForCameraCompat(
                /* isCameraRunning= */ true, WINDOWING_MODE_FREEFORM);
@@ -748,6 +752,22 @@ public class ActivityRecordTests extends WindowTestsBase {
                .isLetterboxedForFixedOrientationAndAspectRatio());
    }

    @Test
    @EnableFlags({Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING,
            Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING_OPT_OUT})
    @EnableCompatChanges({OVERRIDE_CAMERA_COMPAT_DISABLE_SIMULATE_REQUESTED_ORIENTATION})
    public void testOrientation_dontAllowFixedOrientationForCameraCompatFreeformIfOptedOut() {
        final ActivityRecord activity = setupDisplayAndActivityForCameraCompat(
                /* isCameraRunning= */ true, WINDOWING_MODE_FREEFORM);

        // Task in landscape.
        assertEquals(ORIENTATION_LANDSCAPE, activity.getTask().getConfiguration().orientation);
        // Activity is not letterboxed.
        assertEquals(ORIENTATION_LANDSCAPE, activity.getConfiguration().orientation);
        assertFalse(activity.mAppCompatController.getAspectRatioPolicy()
                .isLetterboxedForFixedOrientationAndAspectRatio());
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING)
    @EnableCompatChanges({OVERRIDE_CAMERA_COMPAT_ENABLE_FREEFORM_WINDOWING_TREATMENT})
+27 −1
Original line number Diff line number Diff line
@@ -192,7 +192,8 @@ public class CameraCompatFreeformPolicyTests extends WindowTestsBase {

    @Test
    @EnableFlags(FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING)
    public void testIsFreeformLetterboxingForCameraAllowed_overrideDisabled_returnsFalse() {
    @DisableFlags(FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING_OPT_OUT)
    public void testIsFreeformLetterboxingForCameraAllowed_optInMechanism_notOptedIn_retFalse() {
        configureActivity(SCREEN_ORIENTATION_PORTRAIT);

        onCameraOpened(CAMERA_ID_1, TEST_PACKAGE_1);
@@ -200,6 +201,17 @@ public class CameraCompatFreeformPolicyTests extends WindowTestsBase {
        assertFalse(mCameraCompatFreeformPolicy.isFreeformLetterboxingForCameraAllowed(mActivity));
    }

    @Test
    @EnableFlags({FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING,
            FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING_OPT_OUT})
    public void testIsFreeformLetterboxingForCameraAllowed_notOptedOut_returnsTrue() {
        configureActivity(SCREEN_ORIENTATION_PORTRAIT);

        onCameraOpened(CAMERA_ID_1, TEST_PACKAGE_1);

        assertTrue(mCameraCompatFreeformPolicy.isFreeformLetterboxingForCameraAllowed(mActivity));
    }

    @Test
    @EnableFlags(FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING)
    @EnableCompatChanges({OVERRIDE_CAMERA_COMPAT_ENABLE_FREEFORM_WINDOWING_TREATMENT})
@@ -222,6 +234,7 @@ public class CameraCompatFreeformPolicyTests extends WindowTestsBase {

    @Test
    @EnableFlags(FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING)
    @DisableFlags(FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING_OPT_OUT)
    @EnableCompatChanges({OVERRIDE_CAMERA_COMPAT_ENABLE_FREEFORM_WINDOWING_TREATMENT})
    public void testIsFreeformLetterboxingForCameraAllowed_optInFreeformCameraRunning_true() {
        configureActivity(SCREEN_ORIENTATION_PORTRAIT);
@@ -346,6 +359,7 @@ public class CameraCompatFreeformPolicyTests extends WindowTestsBase {

    @Test
    @EnableFlags(FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING)
    @DisableFlags(FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING_OPT_OUT)
    public void testShouldApplyCameraCompatFreeformTreatment_overrideNotEnabled_returnsFalse() {
        configureActivity(SCREEN_ORIENTATION_PORTRAIT);

@@ -355,6 +369,18 @@ public class CameraCompatFreeformPolicyTests extends WindowTestsBase {
                /* checkOrientation */ true));
    }

    @Test
    @EnableFlags({FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING,
            FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING_OPT_OUT})
    public void testShouldApplyCameraCompatFreeformTreatment_notOptedOut_returnsTrue() {
        configureActivity(SCREEN_ORIENTATION_PORTRAIT);

        onCameraOpened(CAMERA_ID_1, TEST_PACKAGE_1);

        assertTrue(mCameraCompatFreeformPolicy.isTreatmentEnabledForActivity(mActivity,
                /* checkOrientation */ true));
    }

    @Test
    @EnableFlags(FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING)
    @EnableCompatChanges(OVERRIDE_CAMERA_COMPAT_ENABLE_FREEFORM_WINDOWING_TREATMENT)