Debian Codegraph @

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

raw
1 /*
2 * Copyright (C) 2020 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 androidx.test.filters.FlakyTest
20 import android.platform.test.annotations.Presubmit
21 import android.platform.test.annotations.RequiresDevice
22 import android.view.Display
23 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
24 import com.android.server.wm.flicker.FlickerTestParameter
25 import com.android.server.wm.flicker.FlickerTestParameterFactory
26 import com.android.server.wm.flicker.LAUNCHER_COMPONENT
27 import com.android.server.wm.flicker.annotation.Group1
28 import com.android.server.wm.flicker.dsl.FlickerBuilder
29 import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled
30 import com.android.server.wm.flicker.helpers.reopenAppFromOverview
31 import com.android.server.wm.flicker.helpers.setRotation
32 import com.android.server.wm.traces.common.WindowManagerConditionsFactory
33 import org.junit.Assume
34 import org.junit.FixMethodOrder
35 import org.junit.Test
36 import org.junit.runner.RunWith
37 import org.junit.runners.MethodSorters
38 import org.junit.runners.Parameterized
39
40 /**
41 * Test launching an app from the recents app view (the overview)
42 *
43 * To run this test: `atest FlickerTests:OpenAppFromOverviewTest`
44 *
45 * Actions:
46 * Launch [testApp]
47 * Press recents
48 * Relaunch an app [testApp] by selecting it in the overview screen, and wait animation to
49 * complete (only this action is traced)
50 *
51 * Notes:
52 * 1. Some default assertions (e.g., nav bar, status bar and screen covered)
53 * are inherited [OpenAppTransition]
54 * 2. Part of the test setup occurs automatically via
55 * [com.android.server.wm.flicker.TransitionRunnerWithRules],
56 * including configuring navigation mode, initial orientation and ensuring no
57 * apps are running before setup
58 */
59 @RequiresDevice
60 @RunWith(Parameterized::class)
61 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
62 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
63 @Group1
64 open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter)
65 : OpenAppFromLauncherTransition(testSpec) {
66
67 /**
68 * Defines the transition used to run the test
69 */
70 override val transition: FlickerBuilder.() -> Unit
71 get() = {
72 super.transition(this)
73 setup {
74 test {
75 testApp.launchViaIntent(wmHelper)
76 }
77 eachRun {
78 device.pressHome()
79 wmHelper.waitForAppTransitionIdle()
80 device.pressRecentApps()
81 wmHelper.waitFor(
82 WindowManagerConditionsFactory
83 .isAppTransitionIdle(Display.DEFAULT_DISPLAY),
84 WindowManagerConditionsFactory.isActivityVisible(LAUNCHER_COMPONENT),
85 WindowManagerConditionsFactory.hasLayersAnimating().negate()
86 )
87 this.setRotation(testSpec.startRotation)
88 }
89 }
90 transitions {
91 device.reopenAppFromOverview(wmHelper)
92 wmHelper.waitFor(
93 WindowManagerConditionsFactory.hasLayersAnimating().negate(),
94 WindowManagerConditionsFactory.isWMStateComplete(),
95 WindowManagerConditionsFactory.isLayerVisible(LAUNCHER_COMPONENT).negate(),
96 WindowManagerConditionsFactory.isActivityVisible(LAUNCHER_COMPONENT).negate()
97 )
98 wmHelper.waitForFullScreenApp(testApp.component)
99 }
100 }
101
102 /** {@inheritDoc} */
103 @FlakyTest(bugId = 206753786)
104 @Test
105 override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()
106
107 /** {@inheritDoc} */
108 @Presubmit
109 @Test
110 override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()
111
112 /** {@inheritDoc} */
113 @FlakyTest
114 @Test
115 override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()
116
117 /** {@inheritDoc} */
118 @Presubmit
119 @Test
120 override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()
121
122 /** {@inheritDoc} */
123 @Presubmit
124 @Test
125 override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
126
127 /** {@inheritDoc} */
128 @Presubmit
129 @Test
130 override fun appLayerBecomesVisible() = super.appLayerBecomesVisible_warmStart()
131
132 /** {@inheritDoc} */
133 @Presubmit
134 @Test
135 override fun appWindowBecomesVisible() = super.appWindowBecomesVisible_warmStart()
136
137 /** {@inheritDoc} */
138 @FlakyTest(bugId = 229735718)
139 @Test
140 override fun entireScreenCovered() = super.entireScreenCovered()
141
142 /** {@inheritDoc} */
143 @Presubmit
144 @Test
145 override fun appWindowReplacesLauncherAsTopWindow() {
146 Assume.assumeFalse(isShellTransitionsEnabled)
147 super.appWindowReplacesLauncherAsTopWindow()
148 }
149
150 @FlakyTest(bugId = 229738092)
151 @Test
152 fun appWindowReplacesLauncherAsTopWindow_ShellTransit() {
153 Assume.assumeTrue(isShellTransitionsEnabled)
154 super.appWindowReplacesLauncherAsTopWindow()
155 }
156
157 /** {@inheritDoc} */
158 @Presubmit
159 @Test
160 override fun appWindowBecomesTopWindow() {
161 Assume.assumeFalse(isShellTransitionsEnabled)
162 super.appWindowBecomesTopWindow()
163 }
164
165 @FlakyTest(bugId = 229738092)
166 @Test
167 fun appWindowBecomesTopWindow_ShellTransit() {
168 Assume.assumeTrue(isShellTransitionsEnabled)
169 super.appWindowBecomesTopWindow()
170 }
171
172 companion object {
173 /**
174 * Creates the test configurations.
175 *
176 * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
177 * repetitions, screen orientation and navigation modes.
178 */
179 @Parameterized.Parameters(name = "{0}")
180 @JvmStatic
181 fun getParams(): Collection<FlickerTestParameter> {
182 return FlickerTestParameterFactory.getInstance()
183 .getConfigNonRotationTests(repetitions = 3)
184 }
185 }
186 }