Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.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.ime
18
19 import android.app.Instrumentation
20 import android.platform.test.annotations.Presubmit
21 import android.view.Display
22 import android.view.Surface
23 import androidx.test.filters.FlakyTest
24 import androidx.test.filters.RequiresDevice
25 import androidx.test.platform.app.InstrumentationRegistry
26 import com.android.server.wm.flicker.FlickerBuilderProvider
27 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
28 import com.android.server.wm.flicker.FlickerTestParameter
29 import com.android.server.wm.flicker.FlickerTestParameterFactory
30 import com.android.server.wm.flicker.LAUNCHER_COMPONENT
31 import com.android.server.wm.flicker.annotation.Group2
32 import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper
33 import com.android.server.wm.flicker.helpers.reopenAppFromOverview
34 import com.android.server.wm.flicker.helpers.setRotation
35 import com.android.server.wm.flicker.navBarLayerIsVisible
36 import com.android.server.wm.flicker.navBarLayerRotatesAndScales
37 import com.android.server.wm.flicker.navBarWindowIsVisible
38 import com.android.server.wm.flicker.dsl.FlickerBuilder
39 import com.android.server.wm.flicker.entireScreenCovered
40 import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled
41 import com.android.server.wm.flicker.statusBarLayerIsVisible
42 import com.android.server.wm.flicker.statusBarLayerRotatesScales
43 import com.android.server.wm.flicker.statusBarWindowIsVisible
44 import com.android.server.wm.traces.common.ConditionList
45 import com.android.server.wm.traces.common.FlickerComponentName
46 import com.android.server.wm.traces.common.WindowManagerConditionsFactory
47 import org.junit.Assume.assumeFalse
48 import org.junit.Assume.assumeTrue
49 import org.junit.Before
50 import org.junit.FixMethodOrder
51 import org.junit.Test
52 import org.junit.runner.RunWith
53 import org.junit.runners.MethodSorters
54 import org.junit.runners.Parameterized
55
56 /**
57 * Test IME window opening transitions.
58 * To run this test: `atest FlickerTests:ReOpenImeWindowTest`
59 */
60 @RequiresDevice
61 @RunWith(Parameterized::class)
62 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
63 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
64 @Group2
65 open class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {
66 private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
67 private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation)
68
69 private val waitConditionSetup = ConditionList(listOf(
70 WindowManagerConditionsFactory.isAppTransitionIdle(Display.DEFAULT_DISPLAY),
71 WindowManagerConditionsFactory.hasLayersAnimating().negate(),
72 WindowManagerConditionsFactory.isHomeActivityVisible()
73 ))
74
75 @Before
76 open fun before() {
77 assumeFalse(isShellTransitionsEnabled)
78 }
79
80 @FlickerBuilderProvider
81 fun buildFlicker(): FlickerBuilder {
82 return FlickerBuilder(instrumentation).apply {
83 setup {
84 test {
85 testApp.launchViaIntent(wmHelper)
86 testApp.openIME(device, wmHelper)
87 }
88 eachRun {
89 device.pressRecentApps()
90 wmHelper.waitFor(waitConditionSetup)
91 this.setRotation(testSpec.startRotation)
92 }
93 }
94 transitions {
95 device.reopenAppFromOverview(wmHelper)
96 wmHelper.waitImeShown()
97 }
98 teardown {
99 test {
100 testApp.exit()
101 }
102 }
103 }
104 }
105
106 @Presubmit
107 @Test
108 fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible()
109
110 @Presubmit
111 @Test
112 fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible()
113
114 @Presubmit
115 @Test
116 fun visibleWindowsShownMoreThanOneConsecutiveEntry() {
117 val component = FlickerComponentName("", "RecentTaskScreenshotSurface")
118 testSpec.assertWm {
119 this.visibleWindowsShownMoreThanOneConsecutiveEntry(
120 ignoreWindows = listOf(FlickerComponentName.SPLASH_SCREEN,
121 FlickerComponentName.SNAPSHOT,
122 component)
123 )
124 }
125 }
126
127 @Presubmit
128 @Test
129 fun launcherWindowBecomesInvisible() {
130 testSpec.assertWm {
131 this.isAppWindowVisible(LAUNCHER_COMPONENT)
132 .then()
133 .isAppWindowInvisible(LAUNCHER_COMPONENT)
134 }
135 }
136
137 @Presubmit
138 @Test
139 fun imeWindowIsAlwaysVisible() = testSpec.imeWindowIsAlwaysVisible(!isShellTransitionsEnabled)
140
141 @Presubmit
142 @Test
143 fun imeAppWindowVisibilityLegacy() {
144 assumeFalse(isShellTransitionsEnabled)
145 // the app starts visible in live tile, and stays visible for the duration of entering
146 // and exiting overview. However, legacy transitions seem to have a bug which causes
147 // everything to restart during the test, so expect the app to disappear and come back.
148 // Since we log 1x per frame, sometimes the activity visibility and the app visibility
149 // are updated together, sometimes not, thus ignore activity check at the start
150 testSpec.assertWm {
151 this.isAppWindowVisible(testApp.component)
152 .then()
153 .isAppWindowInvisible(testApp.component)
154 .then()
155 .isAppWindowVisible(testApp.component)
156 }
157 }
158
159 @FlakyTest(bugId = 204570898)
160 @Test
161 fun imeAppWindowVisibility() {
162 assumeTrue(isShellTransitionsEnabled)
163 // the app starts visible in live tile, and stays visible for the duration of entering
164 // and exiting overview. Since we log 1x per frame, sometimes the activity visibility
165 // and the app visibility are updated together, sometimes not, thus ignore activity
166 // check at the start
167 testSpec.assertWm {
168 this.isAppWindowVisible(testApp.component)
169 }
170 }
171
172 @Presubmit
173 @Test
174 // During testing the launcher is always in portrait mode
175 fun entireScreenCovered() = testSpec.entireScreenCovered()
176
177 @Presubmit
178 @Test
179 fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible()
180
181 @Presubmit
182 @Test
183 fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible()
184
185 @Presubmit
186 @Test
187 fun imeLayerIsBecomesVisibleLegacy() {
188 assumeFalse(isShellTransitionsEnabled)
189 testSpec.assertLayers {
190 this.isVisible(FlickerComponentName.IME)
191 .then()
192 .isInvisible(FlickerComponentName.IME)
193 .then()
194 .isVisible(FlickerComponentName.IME)
195 }
196 }
197
198 @FlakyTest(bugId = 204570898)
199 @Test
200 fun imeLayerIsBecomesVisible() {
201 assumeTrue(isShellTransitionsEnabled)
202 testSpec.assertLayers {
203 this.isVisible(FlickerComponentName.IME)
204 }
205 }
206
207 @Presubmit
208 @Test
209 fun appLayerReplacesLauncher() {
210 testSpec.assertLayers {
211 this.isVisible(LAUNCHER_COMPONENT)
212 .then()
213 .isVisible(FlickerComponentName.SNAPSHOT, isOptional = true)
214 .then()
215 .isVisible(testApp.component)
216 }
217 }
218
219 @Presubmit
220 @Test
221 fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales()
222
223 @FlakyTest(bugId = 206753786)
224 @Test
225 fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales()
226
227 @Presubmit
228 @Test
229 fun visibleLayersShownMoreThanOneConsecutiveEntry() {
230 // depends on how much of the animation transactions are sent to SF at once
231 // sometimes this layer appears for 2-3 frames, sometimes for only 1
232 val recentTaskComponent = FlickerComponentName("", "RecentTaskScreenshotSurface")
233 testSpec.assertLayers {
234 this.visibleLayersShownMoreThanOneConsecutiveEntry(
235 listOf(FlickerComponentName.SPLASH_SCREEN,
236 FlickerComponentName.SNAPSHOT, recentTaskComponent)
237 )
238 }
239 }
240
241 companion object {
242 @Parameterized.Parameters(name = "{0}")
243 @JvmStatic
244 fun getParams(): Collection<FlickerTestParameter> {
245 return FlickerTestParameterFactory.getInstance()
246 .getConfigNonRotationTests(
247 repetitions = 3,
248 supportedRotations = listOf(Surface.ROTATION_0)
249 )
250 }
251 }
252 }