Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt

raw
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.launch
18
19 import android.platform.test.annotations.Postsubmit
20 import android.platform.test.annotations.RequiresDevice
21 import androidx.test.filters.FlakyTest
22 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
23 import com.android.server.wm.flicker.FlickerTestParameter
24 import com.android.server.wm.flicker.FlickerTestParameterFactory
25 import com.android.server.wm.flicker.annotation.Group1
26 import com.android.server.wm.flicker.dsl.FlickerBuilder
27 import com.android.server.wm.flicker.helpers.ShowWhenLockedAppHelper
28 import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
29 import com.android.server.wm.traces.common.FlickerComponentName
30 import org.junit.FixMethodOrder
31 import org.junit.Test
32 import org.junit.runner.RunWith
33 import org.junit.runners.MethodSorters
34 import org.junit.runners.Parameterized
35
36 /**
37 * Test cold launching an app from a notification from the lock screen when there is an app
38 * overlaid on the lock screen.
39 *
40 * To run this test: `atest FlickerTests:OpenAppFromLockNotificationWithLockOverlayApp`
41 */
42 @RequiresDevice
43 @RunWith(Parameterized::class)
44 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
45 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
46 @Group1
47 @Postsubmit
48 class OpenAppFromLockNotificationWithLockOverlayApp(testSpec: FlickerTestParameter)
49 : OpenAppFromLockNotificationCold(testSpec) {
50 private val showWhenLockedApp: ShowWhenLockedAppHelper =
51 ShowWhenLockedAppHelper(instrumentation)
52
53 // Although we are technically still locked here, the overlay app means we should open the
54 // notification shade as if we were unlocked.
55 override val openingNotificationsFromLockScreen = false
56
57 override val transition: FlickerBuilder.() -> Unit
58 get() = {
59 super.transition(this)
60
61 setup {
62 eachRun {
63 device.wakeUpAndGoToHomeScreen()
64
65 // Launch an activity that is shown when the device is locked
66 showWhenLockedApp.launchViaIntent(wmHelper)
67 wmHelper.waitForFullScreenApp(showWhenLockedApp.component)
68
69 device.sleep()
70 wmHelper.waitFor("noAppWindowsOnTop") {
71 it.wmState.topVisibleAppWindow.isEmpty()
72 }
73 }
74 }
75
76 teardown {
77 test {
78 showWhenLockedApp.exit(wmHelper)
79 }
80 }
81 }
82
83 @Test
84 @Postsubmit
85 fun showWhenLockedAppWindowBecomesVisible() {
86 testSpec.assertWm {
87 this.hasNoVisibleAppWindow()
88 .then()
89 .isAppWindowOnTop(FlickerComponentName.SNAPSHOT, isOptional = true)
90 .then()
91 .isAppWindowOnTop(showWhenLockedApp.component)
92 }
93 }
94
95 @Test
96 @Postsubmit
97 fun showWhenLockedAppLayerBecomesVisible() {
98 testSpec.assertLayers {
99 this.isInvisible(showWhenLockedApp.component)
100 .then()
101 .isVisible(FlickerComponentName.SNAPSHOT, isOptional = true)
102 .then()
103 .isVisible(showWhenLockedApp.component)
104 }
105 }
106
107 /** {@inheritDoc} */
108 @FlakyTest(bugId = 229735718)
109 @Test
110 override fun entireScreenCovered() = super.entireScreenCovered()
111
112 companion object {
113 /**
114 * Creates the test configurations.
115 *
116 * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
117 * repetitions, screen orientation and navigation modes.
118 */
119 @Parameterized.Parameters(name = "{0}")
120 @JvmStatic
121 fun getParams(): Collection<FlickerTestParameter> {
122 return FlickerTestParameterFactory.getInstance()
123 .getConfigNonRotationTests(repetitions = 3)
124 }
125 }
126 }