1 /* 2 * Copyright (C) 2022 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 androidx.test.filters.RequiresDevice 25 import com.android.server.wm.flicker.activityembedding.ActivityEmbeddingTestBase 26 import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper 27 import org.junit.FixMethodOrder 28 import org.junit.Test 29 import org.junit.runner.RunWith 30 import org.junit.runners.MethodSorters 31 import org.junit.runners.Parameterized 32 33 /** 34 * Test opening an activity that will launch another activity as ActivityEmbedding placeholder in 35 * split. 36 * 37 * To run this test: `atest FlickerTestsActivityEmbedding:OpenActivityEmbeddingPlaceholderSplitTest` 38 */ 39 @RequiresDevice 40 @RunWith(Parameterized::class) 41 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) 42 @FixMethodOrder(MethodSorters.NAME_ASCENDING) 43 class OpenActivityEmbeddingPlaceholderSplitTest(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.launchPlaceholderSplit(wmHelper) } 53 teardown { 54 tapl.goHome() 55 testApp.exit(wmHelper) 56 } 57 } 58 59 /** Main activity should become invisible after launching the placeholder primary activity. */ 60 @Presubmit 61 @Test mainActivityWindowBecomesInvisiblenull62 fun mainActivityWindowBecomesInvisible() { 63 flicker.assertWm { 64 isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) 65 .then() 66 .isAppWindowInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) 67 } 68 } 69 70 /** Main activity should become invisible after launching the placeholder primary activity. */ 71 @Presubmit 72 @Test mainActivityLayerBecomesInvisiblenull73 fun mainActivityLayerBecomesInvisible() { 74 flicker.assertLayers { 75 isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) 76 .then() 77 .isInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) 78 } 79 } 80 81 /** 82 * Placeholder primary and secondary should become visible after launch. The windows are not 83 * necessarily to become visible at the same time. 84 */ 85 @Presubmit 86 @Test placeholderSplitWindowsBecomeVisiblenull87 fun placeholderSplitWindowsBecomeVisible() { 88 flicker.assertWm { 89 notContains(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) 90 .then() 91 .isAppWindowInvisible( 92 ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT, 93 isOptional = true 94 ) 95 .then() 96 .isAppWindowVisible(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) 97 } 98 flicker.assertWm { 99 notContains(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) 100 .then() 101 .isAppWindowInvisible( 102 ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT, 103 isOptional = true 104 ) 105 .then() 106 .isAppWindowVisible(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) 107 } 108 } 109 110 /** Placeholder primary and secondary should become visible together after launch. */ 111 @Presubmit 112 @Test placeholderSplitLayersBecomeVisiblenull113 fun placeholderSplitLayersBecomeVisible() { 114 flicker.assertLayers { 115 isInvisible(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) 116 isInvisible(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) 117 .then() 118 .isVisible(ActivityEmbeddingAppHelper.PLACEHOLDER_PRIMARY_COMPONENT) 119 .isVisible(ActivityEmbeddingAppHelper.PLACEHOLDER_SECONDARY_COMPONENT) 120 } 121 } 122 123 companion object { 124 /** 125 * Creates the test configurations. 126 * 127 * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and 128 * navigation modes. 129 */ 130 @Parameterized.Parameters(name = "{0}") 131 @JvmStatic getParamsnull132 fun getParams() = LegacyFlickerTestFactory.nonRotationTests() 133 } 134 } 135