Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/OpenTransparentActivityTest.kt 0 → 100644 +128 −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.appcompat import android.platform.test.annotations.Postsubmit import android.tools.common.Rotation import android.tools.common.flicker.assertions.FlickerTest import android.tools.common.traces.component.ComponentNameMatcher 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 androidx.test.filters.RequiresDevice import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized /** * Test launching app in size compat mode. * * To run this test: `atest WMShellFlickerTestsOther:OpenTransparentActivityTest` * * Actions: * ``` * Launch a letteboxed app and then a transparent activity from it. We test the bounds * are the same. * ``` * * Notes: * ``` * Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited [BaseTest] * ``` */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) class OpenTransparentActivityTest(flicker: LegacyFlickerTest) : TransparentBaseAppCompat(flicker) { /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { setup { letterboxTranslucentLauncherApp.launchViaIntent(wmHelper) } transitions { waitAndGetLaunchTransparent()?.click() ?: error("Launch Transparent not found") } teardown { letterboxTranslucentApp.exit(wmHelper) letterboxTranslucentLauncherApp.exit(wmHelper) } } /** * Checks the transparent activity is launched on top of the opaque one */ @Postsubmit @Test fun translucentActivityIsLaunchedOnTopOfOpaqueActivity() { flicker.assertWm { this.isAppWindowOnTop(letterboxTranslucentLauncherApp) .then() .isAppWindowOnTop(letterboxTranslucentApp) } } /** * Checks that the activity is letterboxed */ @Postsubmit @Test fun translucentActivityIsLetterboxed() { flicker.assertLayers { isVisible(ComponentNameMatcher.LETTERBOX) } } /** * Checks that the translucent activity inherits bounds from the opaque one. */ @Postsubmit @Test fun translucentActivityInheritsBoundsFromOpaqueActivity() { flicker.assertLayersEnd { this.visibleRegion(letterboxTranslucentApp) .coversExactly(visibleRegion(letterboxTranslucentLauncherApp).region) } } /** * Checks that the translucent activity has rounded corners */ @Postsubmit @Test fun translucentActivityHasRoundedCorners() { flicker.assertLayersEnd { this.hasRoundedCorners(letterboxTranslucentApp) } } companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.rotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return LegacyFlickerTestFactory .nonRotationTests(supportedRotations = listOf(Rotation.ROTATION_90)) } } } libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/TransparentBaseAppCompat.kt 0 → 100644 +63 −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.appcompat import android.content.Context import android.tools.device.flicker.legacy.FlickerTestData import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.helpers.FIND_TIMEOUT import android.tools.device.traces.parsers.toFlickerComponent import androidx.test.uiautomator.By import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.LetterboxAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.wm.shell.flicker.BaseTest import org.junit.Assume import org.junit.Before import org.junit.Rule abstract class TransparentBaseAppCompat(flicker: LegacyFlickerTest) : BaseTest(flicker) { protected val context: Context = instrumentation.context protected val letterboxTranslucentLauncherApp = LetterboxAppHelper( instrumentation, launcherName = ActivityOptions.LaunchTransparentActivity.LABEL, component = ActivityOptions.LaunchTransparentActivity.COMPONENT.toFlickerComponent() ) protected val letterboxTranslucentApp = LetterboxAppHelper( instrumentation, launcherName = ActivityOptions.TransparentActivity.LABEL, component = ActivityOptions.TransparentActivity.COMPONENT.toFlickerComponent() ) @JvmField @Rule val letterboxRule: LetterboxRule = LetterboxRule() @Before fun before() { Assume.assumeTrue(tapl.isTablet && letterboxRule.isIgnoreOrientationRequest) } protected fun FlickerTestData.waitAndGetLaunchTransparent(): UiObject2? = device.wait( Until.findObject(By.text("Launch Transparent")), FIND_TIMEOUT ) protected fun FlickerTestData.goBack() = device.pressBack() } tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml +18 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,24 @@ <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".LaunchTransparentActivity" android:resizeableActivity="false" android:screenOrientation="portrait" android:theme="@android:style/Theme" android:taskAffinity="com.android.server.wm.flicker.testapp.LaunchTransparentActivity" android:label="LaunchTransparentActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".TransparentActivity" android:theme="@style/TransparentTheme" android:taskAffinity="com.android.server.wm.flicker.testapp.TransparentActivity" android:label="TransparentActivity" android:exported="false"> </activity> <activity android:name=".LaunchNewActivity" android:taskAffinity="com.android.server.wm.flicker.testapp.LaunchNewActivity" android:theme="@style/CutoutShortEdges" Loading tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout> tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent_launch.xml 0 → 100644 +37 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@android:color/black"> <Button android:id="@+id/button_launch_transparent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Launch Transparent" /> <Button android:id="@+id/button_request_permission" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Request Permission" /> </LinearLayout> Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/OpenTransparentActivityTest.kt 0 → 100644 +128 −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.appcompat import android.platform.test.annotations.Postsubmit import android.tools.common.Rotation import android.tools.common.flicker.assertions.FlickerTest import android.tools.common.traces.component.ComponentNameMatcher 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 androidx.test.filters.RequiresDevice import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized /** * Test launching app in size compat mode. * * To run this test: `atest WMShellFlickerTestsOther:OpenTransparentActivityTest` * * Actions: * ``` * Launch a letteboxed app and then a transparent activity from it. We test the bounds * are the same. * ``` * * Notes: * ``` * Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited [BaseTest] * ``` */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) class OpenTransparentActivityTest(flicker: LegacyFlickerTest) : TransparentBaseAppCompat(flicker) { /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { setup { letterboxTranslucentLauncherApp.launchViaIntent(wmHelper) } transitions { waitAndGetLaunchTransparent()?.click() ?: error("Launch Transparent not found") } teardown { letterboxTranslucentApp.exit(wmHelper) letterboxTranslucentLauncherApp.exit(wmHelper) } } /** * Checks the transparent activity is launched on top of the opaque one */ @Postsubmit @Test fun translucentActivityIsLaunchedOnTopOfOpaqueActivity() { flicker.assertWm { this.isAppWindowOnTop(letterboxTranslucentLauncherApp) .then() .isAppWindowOnTop(letterboxTranslucentApp) } } /** * Checks that the activity is letterboxed */ @Postsubmit @Test fun translucentActivityIsLetterboxed() { flicker.assertLayers { isVisible(ComponentNameMatcher.LETTERBOX) } } /** * Checks that the translucent activity inherits bounds from the opaque one. */ @Postsubmit @Test fun translucentActivityInheritsBoundsFromOpaqueActivity() { flicker.assertLayersEnd { this.visibleRegion(letterboxTranslucentApp) .coversExactly(visibleRegion(letterboxTranslucentLauncherApp).region) } } /** * Checks that the translucent activity has rounded corners */ @Postsubmit @Test fun translucentActivityHasRoundedCorners() { flicker.assertLayersEnd { this.hasRoundedCorners(letterboxTranslucentApp) } } companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.rotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return LegacyFlickerTestFactory .nonRotationTests(supportedRotations = listOf(Rotation.ROTATION_90)) } } }
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/TransparentBaseAppCompat.kt 0 → 100644 +63 −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.appcompat import android.content.Context import android.tools.device.flicker.legacy.FlickerTestData import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.helpers.FIND_TIMEOUT import android.tools.device.traces.parsers.toFlickerComponent import androidx.test.uiautomator.By import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.LetterboxAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.wm.shell.flicker.BaseTest import org.junit.Assume import org.junit.Before import org.junit.Rule abstract class TransparentBaseAppCompat(flicker: LegacyFlickerTest) : BaseTest(flicker) { protected val context: Context = instrumentation.context protected val letterboxTranslucentLauncherApp = LetterboxAppHelper( instrumentation, launcherName = ActivityOptions.LaunchTransparentActivity.LABEL, component = ActivityOptions.LaunchTransparentActivity.COMPONENT.toFlickerComponent() ) protected val letterboxTranslucentApp = LetterboxAppHelper( instrumentation, launcherName = ActivityOptions.TransparentActivity.LABEL, component = ActivityOptions.TransparentActivity.COMPONENT.toFlickerComponent() ) @JvmField @Rule val letterboxRule: LetterboxRule = LetterboxRule() @Before fun before() { Assume.assumeTrue(tapl.isTablet && letterboxRule.isIgnoreOrientationRequest) } protected fun FlickerTestData.waitAndGetLaunchTransparent(): UiObject2? = device.wait( Until.findObject(By.text("Launch Transparent")), FIND_TIMEOUT ) protected fun FlickerTestData.goBack() = device.pressBack() }
tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml +18 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,24 @@ <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".LaunchTransparentActivity" android:resizeableActivity="false" android:screenOrientation="portrait" android:theme="@android:style/Theme" android:taskAffinity="com.android.server.wm.flicker.testapp.LaunchTransparentActivity" android:label="LaunchTransparentActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".TransparentActivity" android:theme="@style/TransparentTheme" android:taskAffinity="com.android.server.wm.flicker.testapp.TransparentActivity" android:label="TransparentActivity" android:exported="false"> </activity> <activity android:name=".LaunchNewActivity" android:taskAffinity="com.android.server.wm.flicker.testapp.LaunchNewActivity" android:theme="@style/CutoutShortEdges" Loading
tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout>
tests/FlickerTests/test-apps/flickerapp/res/layout/activity_transparent_launch.xml 0 → 100644 +37 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@android:color/black"> <Button android:id="@+id/button_launch_transparent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Launch Transparent" /> <Button android:id="@+id/button_request_permission" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Request Permission" /> </LinearLayout>