Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipAspectRatioChangeTest.kt 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.flicker.pip import android.platform.test.annotations.Presubmit import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import com.android.wm.shell.flicker.pip.common.PipTransition import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.junit.runners.Parameterized /** Test changing aspect ratio of pip. */ @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) class PipAspectRatioChangeTest(flicker: LegacyFlickerTest) : PipTransition(flicker) { override val thisTransition: FlickerBuilder.() -> Unit = { transitions { pipApp.changeAspectRatio() } } @Presubmit @Test fun pipAspectRatioChangesProperly() { flicker.assertLayersStart { this.visibleRegion(pipApp).isSameAspectRatio(16, 9) } flicker.assertLayersEnd { this.visibleRegion(pipApp).isSameAspectRatio(1, 2) } } companion object { /** * Creates the test configurations. * * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams() = LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) } } tests/FlickerTests/src/com/android/server/wm/flicker/helpers/PipAppHelper.kt +6 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.wm.flicker.helpers import android.app.Instrumentation import android.content.Intent import android.media.session.MediaController import android.media.session.MediaSessionManager import android.tools.common.datatypes.Rect Loading Loading @@ -267,6 +268,11 @@ open class PipAppHelper(instrumentation: Instrumentation) : fun exitPipToFullScreenViaIntent(wmHelper: WindowManagerStateHelper) = launchViaIntent(wmHelper) fun changeAspectRatio() { val intent = Intent("com.android.wm.shell.flicker.testapp.ASPECT_RATIO") context.sendBroadcast(intent) } fun clickEnterPipButton(wmHelper: WindowManagerStateHelper) { clickObject(ENTER_PIP_BUTTON_ID) Loading tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/PipActivity.java +6 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,8 @@ public class PipActivity extends Activity { "com.android.wm.shell.flicker.testapp.SWITCH_OFF"; private static final String ACTION_SWITCH_ON = "com.android.wm.shell.flicker.testapp.SWITCH_ON"; private static final String ACTION_CLEAR = "com.android.wm.shell.flicker.testapp.CLEAR"; private static final String ACTION_ASPECT_RATIO = "com.android.wm.shell.flicker.testapp.ASPECT_RATIO"; private final PictureInPictureParams.Builder mPipParamsBuilder = new PictureInPictureParams.Builder() Loading Loading @@ -109,6 +111,9 @@ public class PipActivity extends Activity { case ACTION_CLEAR: mPipParamsBuilder.setActions(Collections.emptyList()); break; case ACTION_ASPECT_RATIO: mPipParamsBuilder.setAspectRatio(RATIO_TALL); break; case ACTION_NO_OP: return; default: Loading Loading @@ -190,6 +195,7 @@ public class PipActivity extends Activity { filter.addAction(ACTION_CLEAR); filter.addAction(ACTION_SET_REQUESTED_ORIENTATION); filter.addAction(ACTION_ENTER_PIP); filter.addAction(ACTION_ASPECT_RATIO); registerReceiver(mBroadcastReceiver, filter); handleIntentExtra(getIntent()); Loading Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipAspectRatioChangeTest.kt 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.flicker.pip import android.platform.test.annotations.Presubmit import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import com.android.wm.shell.flicker.pip.common.PipTransition import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.junit.runners.Parameterized /** Test changing aspect ratio of pip. */ @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) class PipAspectRatioChangeTest(flicker: LegacyFlickerTest) : PipTransition(flicker) { override val thisTransition: FlickerBuilder.() -> Unit = { transitions { pipApp.changeAspectRatio() } } @Presubmit @Test fun pipAspectRatioChangesProperly() { flicker.assertLayersStart { this.visibleRegion(pipApp).isSameAspectRatio(16, 9) } flicker.assertLayersEnd { this.visibleRegion(pipApp).isSameAspectRatio(1, 2) } } companion object { /** * Creates the test configurations. * * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams() = LegacyFlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_0) ) } }
tests/FlickerTests/src/com/android/server/wm/flicker/helpers/PipAppHelper.kt +6 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.wm.flicker.helpers import android.app.Instrumentation import android.content.Intent import android.media.session.MediaController import android.media.session.MediaSessionManager import android.tools.common.datatypes.Rect Loading Loading @@ -267,6 +268,11 @@ open class PipAppHelper(instrumentation: Instrumentation) : fun exitPipToFullScreenViaIntent(wmHelper: WindowManagerStateHelper) = launchViaIntent(wmHelper) fun changeAspectRatio() { val intent = Intent("com.android.wm.shell.flicker.testapp.ASPECT_RATIO") context.sendBroadcast(intent) } fun clickEnterPipButton(wmHelper: WindowManagerStateHelper) { clickObject(ENTER_PIP_BUTTON_ID) Loading
tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/PipActivity.java +6 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,8 @@ public class PipActivity extends Activity { "com.android.wm.shell.flicker.testapp.SWITCH_OFF"; private static final String ACTION_SWITCH_ON = "com.android.wm.shell.flicker.testapp.SWITCH_ON"; private static final String ACTION_CLEAR = "com.android.wm.shell.flicker.testapp.CLEAR"; private static final String ACTION_ASPECT_RATIO = "com.android.wm.shell.flicker.testapp.ASPECT_RATIO"; private final PictureInPictureParams.Builder mPipParamsBuilder = new PictureInPictureParams.Builder() Loading Loading @@ -109,6 +111,9 @@ public class PipActivity extends Activity { case ACTION_CLEAR: mPipParamsBuilder.setActions(Collections.emptyList()); break; case ACTION_ASPECT_RATIO: mPipParamsBuilder.setAspectRatio(RATIO_TALL); break; case ACTION_NO_OP: return; default: Loading Loading @@ -190,6 +195,7 @@ public class PipActivity extends Activity { filter.addAction(ACTION_CLEAR); filter.addAction(ACTION_SET_REQUESTED_ORIENTATION); filter.addAction(ACTION_ENTER_PIP); filter.addAction(ACTION_ASPECT_RATIO); registerReceiver(mBroadcastReceiver, filter); handleIntentExtra(getIntent()); Loading