Loading tests/FlickerTests/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ <uses-permission android:name="android.permission.READ_LOGS"/> <!-- ATM.removeRootTasksWithActivityTypes() --> <uses-permission android:name="android.permission.MANAGE_ACTIVITY_TASKS" /> <!-- ActivityOptions.makeCustomTaskAnimation() --> <uses-permission android:name="android.permission.START_TASKS_FROM_RECENTS" /> <!-- Allow the test to write directly to /sdcard/ --> <application android:requestLegacyExternalStorage="true"> <uses-library android:name="android.test.runner"/> Loading tests/FlickerTests/res/anim/show_2000ms.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright (C) 2022 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. --> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2000" android:fromXDelta="0" android:toXDelta="0" /> No newline at end of file tests/FlickerTests/src/com/android/server/wm/flicker/launch/OverrideTaskTransitionTest.kt 0 → 100644 +112 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.server.wm.flicker.launch import android.app.Instrumentation import android.os.Bundle import android.os.Handler import android.platform.test.annotations.Presubmit import androidx.test.filters.RequiresDevice import androidx.test.platform.app.InstrumentationRegistry import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.R import com.android.server.wm.flicker.annotation.Group4 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.helpers.StandardAppHelper import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen import com.android.server.wm.flicker.rules.RemoveAllTasksButHomeRule import com.android.server.wm.traces.common.ComponentNameMatcher import com.android.server.wm.traces.common.WindowManagerConditionsFactory import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.junit.runners.Parameterized /** * Test the [android.app.ActivityOptions.makeCustomTaskAnimation]. * * To run this test: `atest FlickerTests:OverrideTaskTransitionTest` * * Actions: * Launches SimpleActivity with alpha_2000ms animation */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 class OverrideTaskTransitionTest(val testSpec: FlickerTestParameter) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val testApp: StandardAppHelper = SimpleAppHelper(instrumentation) @FlickerBuilderProvider fun buildFlicker(): FlickerBuilder { return FlickerBuilder(instrumentation).apply { setup { device.wakeUpAndGoToHomeScreen() RemoveAllTasksButHomeRule.removeAllTasksButHome() setRotation(testSpec.startRotation) } transitions { instrumentation.context.startActivity( testApp.openAppIntent, createCustomTaskAnimation()) wmHelper.StateSyncBuilder() .add(WindowManagerConditionsFactory.isWMStateComplete()) .withAppTransitionIdle() .withWindowSurfaceAppeared(testApp) .waitForAndVerify() } teardown { testApp.exit() } } } @Presubmit @Test fun testSimpleActivityIsShownDirectly() { testSpec.assertLayers { isVisible(ComponentNameMatcher.LAUNCHER) .isInvisible(ComponentNameMatcher.SPLASH_SCREEN) .isInvisible(testApp) .then() // The custom animation should block the entire launcher from the very beginning .isInvisible(ComponentNameMatcher.LAUNCHER) } } private fun createCustomTaskAnimation(): Bundle { return android.app.ActivityOptions.makeCustomTaskAnimation(instrumentation.context, R.anim.show_2000ms, 0, Handler.getMain(), null, null).toBundle() } companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTestParameter> { return FlickerTestParameterFactory.getInstance() .getConfigNonRotationTests() } } } Loading
tests/FlickerTests/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ <uses-permission android:name="android.permission.READ_LOGS"/> <!-- ATM.removeRootTasksWithActivityTypes() --> <uses-permission android:name="android.permission.MANAGE_ACTIVITY_TASKS" /> <!-- ActivityOptions.makeCustomTaskAnimation() --> <uses-permission android:name="android.permission.START_TASKS_FROM_RECENTS" /> <!-- Allow the test to write directly to /sdcard/ --> <application android:requestLegacyExternalStorage="true"> <uses-library android:name="android.test.runner"/> Loading
tests/FlickerTests/res/anim/show_2000ms.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright (C) 2022 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. --> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2000" android:fromXDelta="0" android:toXDelta="0" /> No newline at end of file
tests/FlickerTests/src/com/android/server/wm/flicker/launch/OverrideTaskTransitionTest.kt 0 → 100644 +112 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.server.wm.flicker.launch import android.app.Instrumentation import android.os.Bundle import android.os.Handler import android.platform.test.annotations.Presubmit import androidx.test.filters.RequiresDevice import androidx.test.platform.app.InstrumentationRegistry import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.R import com.android.server.wm.flicker.annotation.Group4 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.helpers.StandardAppHelper import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen import com.android.server.wm.flicker.rules.RemoveAllTasksButHomeRule import com.android.server.wm.traces.common.ComponentNameMatcher import com.android.server.wm.traces.common.WindowManagerConditionsFactory import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.junit.runners.Parameterized /** * Test the [android.app.ActivityOptions.makeCustomTaskAnimation]. * * To run this test: `atest FlickerTests:OverrideTaskTransitionTest` * * Actions: * Launches SimpleActivity with alpha_2000ms animation */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 class OverrideTaskTransitionTest(val testSpec: FlickerTestParameter) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val testApp: StandardAppHelper = SimpleAppHelper(instrumentation) @FlickerBuilderProvider fun buildFlicker(): FlickerBuilder { return FlickerBuilder(instrumentation).apply { setup { device.wakeUpAndGoToHomeScreen() RemoveAllTasksButHomeRule.removeAllTasksButHome() setRotation(testSpec.startRotation) } transitions { instrumentation.context.startActivity( testApp.openAppIntent, createCustomTaskAnimation()) wmHelper.StateSyncBuilder() .add(WindowManagerConditionsFactory.isWMStateComplete()) .withAppTransitionIdle() .withWindowSurfaceAppeared(testApp) .waitForAndVerify() } teardown { testApp.exit() } } } @Presubmit @Test fun testSimpleActivityIsShownDirectly() { testSpec.assertLayers { isVisible(ComponentNameMatcher.LAUNCHER) .isInvisible(ComponentNameMatcher.SPLASH_SCREEN) .isInvisible(testApp) .then() // The custom animation should block the entire launcher from the very beginning .isInvisible(ComponentNameMatcher.LAUNCHER) } } private fun createCustomTaskAnimation(): Bundle { return android.app.ActivityOptions.makeCustomTaskAnimation(instrumentation.context, R.anim.show_2000ms, 0, Handler.getMain(), null, null).toBundle() } companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTestParameter> { return FlickerTestParameterFactory.getInstance() .getConfigNonRotationTests() } } }