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.launch 18 19 import android.platform.test.annotations.Presubmit 20 import android.tools.NavBar 21 import android.tools.Rotation 22 import android.tools.flicker.annotation.FlickerServiceCompatible 23 import android.tools.flicker.junit.FlickerParametersRunnerFactory 24 import android.tools.flicker.legacy.LegacyFlickerTest 25 import android.tools.flicker.legacy.LegacyFlickerTestFactory 26 import android.tools.traces.component.ComponentNameMatcher 27 import androidx.test.filters.FlakyTest 28 import androidx.test.filters.RequiresDevice 29 import com.android.server.wm.flicker.helpers.NonResizeableAppHelper 30 import com.android.server.wm.flicker.launch.common.OpenAppFromLockscreenTransition 31 import org.junit.Assume 32 import org.junit.FixMethodOrder 33 import org.junit.Ignore 34 import org.junit.Test 35 import org.junit.runner.RunWith 36 import org.junit.runners.MethodSorters 37 import org.junit.runners.Parameterized 38 39 /** 40 * Test launching an app while the device is locked 41 * 42 * This test assumes the device doesn't have AOD enabled 43 * 44 * To run this test: `atest FlickerTestsAppLaunch:OpenAppFromLockscreenViaIntentTest` 45 * 46 * Actions: 47 * ``` 48 * Lock the device. 49 * Launch an app on top of the lock screen [testApp] and wait animation to complete 50 * ``` 51 * 52 * Notes: 53 * ``` 54 * 1. Some default assertions (e.g., nav bar, status bar and screen covered) 55 * are inherited [OpenAppTransition] 56 * 2. Part of the test setup occurs automatically via 57 * [com.android.server.wm.flicker.TransitionRunnerWithRules], 58 * including configuring navigation mode, initial orientation and ensuring no 59 * apps are running before setup 60 * ``` 61 */ 62 @RequiresDevice 63 @FlickerServiceCompatible 64 @RunWith(Parameterized::class) 65 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) 66 @FixMethodOrder(MethodSorters.NAME_ASCENDING) 67 open class OpenAppFromLockscreenViaIntentTest(flicker: LegacyFlickerTest) : 68 OpenAppFromLockscreenTransition(flicker) { 69 override val testApp = NonResizeableAppHelper(instrumentation) 70 71 /** 72 * Checks that the [ComponentNameMatcher.NAV_BAR] layer starts invisible, becomes visible during 73 * unlocking animation and remains visible at the end 74 */ 75 @FlakyTest(bugId = 288341660) 76 @Test navBarLayerVisibilityChangesnull77 fun navBarLayerVisibilityChanges() { 78 Assume.assumeFalse(usesTaskbar) 79 flicker.assertLayers { 80 this.isInvisible(ComponentNameMatcher.NAV_BAR) 81 .then() 82 .isVisible(ComponentNameMatcher.NAV_BAR) 83 } 84 } 85 86 /** Checks if [testApp] is visible at the end of the transition */ 87 @Presubmit 88 @Test appWindowBecomesVisibleAtEndnull89 fun appWindowBecomesVisibleAtEnd() { 90 flicker.assertWmEnd { this.isAppWindowVisible(testApp) } 91 } 92 93 /** 94 * Checks that the [ComponentNameMatcher.NAV_BAR] starts the transition invisible, then becomes 95 * visible during the unlocking animation and remains visible at the end of the transition 96 */ 97 @FlakyTest(bugId = 293581770) 98 @Test navBarWindowsVisibilityChangesnull99 fun navBarWindowsVisibilityChanges() { 100 Assume.assumeFalse(usesTaskbar) 101 flicker.assertWm { 102 this.isNonAppWindowInvisible(ComponentNameMatcher.NAV_BAR) 103 .then() 104 .isAboveAppWindowVisible(ComponentNameMatcher.NAV_BAR) 105 } 106 } 107 108 /** 109 * Checks that the [ComponentNameMatcher.TASK_BAR] starts the transition invisible, then becomes 110 * visible during the unlocking animation and remains visible at the end of the transition 111 */ 112 @Presubmit 113 @Test taskBarLayerIsVisibleAtEndnull114 fun taskBarLayerIsVisibleAtEnd() { 115 Assume.assumeTrue(usesTaskbar) 116 flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.TASK_BAR) } 117 } 118 119 /** 120 * Checks that the [ComponentNameMatcher.STATUS_BAR] layer is visible at the end of the trace 121 * 122 * It is not possible to check at the start because the screen is off 123 */ 124 @Presubmit 125 @Test statusBarLayerIsVisibleAtStartAndEndnull126 override fun statusBarLayerIsVisibleAtStartAndEnd() { 127 flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.STATUS_BAR) } 128 } 129 130 /** {@inheritDoc} */ 131 @Test 132 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") taskBarLayerIsVisibleAtStartAndEndnull133 override fun taskBarLayerIsVisibleAtStartAndEnd() {} 134 135 /** {@inheritDoc} */ 136 @Test 137 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") navBarLayerIsVisibleAtStartAndEndnull138 override fun navBarLayerIsVisibleAtStartAndEnd() {} 139 140 /** {@inheritDoc} */ 141 @Test 142 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") taskBarWindowIsAlwaysVisiblenull143 override fun taskBarWindowIsAlwaysVisible() {} 144 145 /** {@inheritDoc} */ 146 @Test 147 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") navBarWindowIsAlwaysVisiblenull148 override fun navBarWindowIsAlwaysVisible() {} 149 150 /** {@inheritDoc} */ 151 @Test 152 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") navBarWindowIsVisibleAtStartAndEndnull153 override fun navBarWindowIsVisibleAtStartAndEnd() = super.navBarWindowIsVisibleAtStartAndEnd() 154 155 /** {@inheritDoc} */ 156 @Test 157 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") 158 override fun statusBarWindowIsAlwaysVisible() {} 159 160 /** {@inheritDoc} */ 161 @Presubmit 162 @Test appWindowBecomesFirstAndOnlyTopWindownull163 override fun appWindowBecomesFirstAndOnlyTopWindow() = 164 super.appWindowBecomesFirstAndOnlyTopWindow() 165 166 /** {@inheritDoc} */ 167 @Presubmit @Test override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() 168 169 /** Checks the [ComponentNameMatcher.NAV_BAR] is visible at the end of the transition */ 170 @Presubmit 171 @Test 172 fun navBarLayerIsVisibleAtEnd() { 173 Assume.assumeFalse(usesTaskbar) 174 flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.NAV_BAR) } 175 } 176 177 /** {@inheritDoc} */ 178 @FlakyTest 179 @Test visibleLayersShownMoreThanOneConsecutiveEntrynull180 override fun visibleLayersShownMoreThanOneConsecutiveEntry() = 181 super.visibleLayersShownMoreThanOneConsecutiveEntry() 182 183 /** {@inheritDoc} */ 184 @Presubmit 185 @Test 186 override fun appLayerBecomesVisible() { 187 Assume.assumeFalse(usesTaskbar) 188 super.appLayerBecomesVisible() 189 } 190 191 /** {@inheritDoc} */ 192 @FlakyTest(bugId = 227143265) 193 @Test appLayerBecomesVisibleTabletnull194 fun appLayerBecomesVisibleTablet() { 195 Assume.assumeTrue(usesTaskbar) 196 super.appLayerBecomesVisible() 197 } 198 199 @FlakyTest(bugId = 338296297) 200 @Test visibleWindowsShownMoreThanOneConsecutiveEntrynull201 override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = 202 super.visibleWindowsShownMoreThanOneConsecutiveEntry() 203 204 @FlakyTest(bugId = 285980483) 205 @Test 206 override fun focusChanges() { 207 super.focusChanges() 208 } 209 210 companion object { 211 /** 212 * Creates the test configurations. 213 * 214 * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and 215 * navigation modes. 216 */ 217 @Parameterized.Parameters(name = "{0}") 218 @JvmStatic getParamsnull219 fun getParams() = 220 LegacyFlickerTestFactory.nonRotationTests( 221 supportedNavigationModes = listOf(NavBar.MODE_GESTURAL), 222 supportedRotations = listOf(Rotation.ROTATION_0) 223 ) 224 } 225 } 226