1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.wm.flicker.activityembedding.open 18 19 import android.platform.test.annotations.Presubmit 20 import android.tools.flicker.junit.FlickerParametersRunnerFactory 21 import android.tools.flicker.legacy.FlickerBuilder 22 import android.tools.flicker.legacy.LegacyFlickerTest 23 import android.tools.flicker.legacy.LegacyFlickerTestFactory 24 import android.tools.traces.component.ComponentNameMatcher 25 import androidx.test.filters.RequiresDevice 26 import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase 27 import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper 28 import org.junit.FixMethodOrder 29 import org.junit.Test 30 import org.junit.runner.RunWith 31 import org.junit.runners.MethodSorters 32 import org.junit.runners.Parameterized 33 34 /** 35 * Test opening a secondary activity that will split with the main activity. 36 * 37 * To run this test: `atest FlickerTestsActivityEmbedding:OpenActivityEmbeddingSecondaryToSplitTest` 38 */ 39 @RequiresDevice 40 @RunWith(Parameterized::class) 41 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) 42 @FixMethodOrder(MethodSorters.NAME_ASCENDING) 43 class OpenActivityEmbeddingSecondaryToSplitTest(flicker: LegacyFlickerTest) : 44 ActivityEmbeddingTestBase(flicker) { 45 46 /** {@inheritDoc} */ <lambda>null47 override val transition: FlickerBuilder.() -> Unit = { 48 setup { 49 tapl.setExpectedRotationCheckEnabled(false) 50 testApp.launchViaIntent(wmHelper) 51 } 52 transitions { testApp.launchSecondaryActivity(wmHelper) } 53 teardown { 54 tapl.goHome() 55 testApp.exit(wmHelper) 56 } 57 } 58 59 /** Main activity should remain visible when enter split from fullscreen. */ 60 @Presubmit 61 @Test mainActivityWindowIsAlwaysVisiblenull62 fun mainActivityWindowIsAlwaysVisible() { 63 flicker.assertWm { isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) } 64 } 65 66 /** 67 * Main activity surface is animated from fullscreen to ActivityEmbedding split. During the 68 * transition, there is a period of time that it is covered by a snapshot of itself. 69 */ 70 @Presubmit 71 @Test mainActivityLayerIsAlwaysVisiblenull72 fun mainActivityLayerIsAlwaysVisible() { 73 flicker.assertLayers { 74 isVisible( 75 ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT.or( 76 ComponentNameMatcher.TRANSITION_SNAPSHOT 77 ) 78 ) 79 } 80 flicker.assertLayersEnd { 81 isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) 82 .isInvisible(ComponentNameMatcher.TRANSITION_SNAPSHOT) 83 } 84 } 85 86 /** Secondary activity should become visible after launching into split. */ 87 @Presubmit 88 @Test secondaryActivityWindowBecomesVisiblenull89 fun secondaryActivityWindowBecomesVisible() { 90 flicker.assertWm { 91 notContains(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) 92 .then() 93 .isAppWindowInvisible( 94 ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT, 95 isOptional = true 96 ) 97 .then() 98 .isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) 99 } 100 } 101 102 /** Secondary activity should become visible after launching into split. */ 103 @Presubmit 104 @Test secondaryActivityLayerBecomesVisiblenull105 fun secondaryActivityLayerBecomesVisible() { 106 flicker.assertLayers { 107 isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) 108 .then() 109 .isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) 110 } 111 } 112 113 companion object { 114 /** 115 * Creates the test configurations. 116 * 117 * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and 118 * navigation modes. 119 */ 120 @Parameterized.Parameters(name = "{0}") 121 @JvmStatic getParamsnull122 fun getParams() = LegacyFlickerTestFactory.nonRotationTests() 123 } 124 } 125