Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.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.Surface
22 import android.view.WindowManagerPolicyConstants
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.annotation.Group2
31 import com.android.server.wm.flicker.dsl.FlickerBuilder
32 import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper
33 import com.android.server.wm.flicker.navBarLayerIsVisible
34 import com.android.server.wm.flicker.navBarLayerRotatesAndScales
35 import com.android.server.wm.flicker.navBarWindowIsVisible
36 import com.android.server.wm.flicker.entireScreenCovered
37 import com.android.server.wm.flicker.statusBarLayerIsVisible
38 import com.android.server.wm.flicker.statusBarLayerRotatesScales
39 import com.android.server.wm.flicker.statusBarWindowIsVisible
40 import com.android.server.wm.traces.common.FlickerComponentName
41 import org.junit.FixMethodOrder
42 import org.junit.Test
43 import org.junit.runner.RunWith
44 import org.junit.runners.MethodSorters
45 import org.junit.runners.Parameterized
46
47 /**
48 * Test IME window closing back to app window transitions.
49 *
50 * This test doesn't work on 90 degrees. According to the InputMethodService documentation:
51 *
52 * Don't show if this is not explicitly requested by the user and the input method
53 * is fullscreen. That would be too disruptive.
54 *
55 * More details on b/190352379
56 *
57 * To run this test: `atest FlickerTests:CloseImeAutoOpenWindowToHomeTest`
58 */
59 @RequiresDevice
60 @RunWith(Parameterized::class)
61 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
62 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
63 @Group2
64 class CloseImeAutoOpenWindowToHomeTest(private val testSpec: FlickerTestParameter) {
65 private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
66 private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation)
67
68 @FlickerBuilderProvider
69 fun buildFlicker(): FlickerBuilder {
70 return FlickerBuilder(instrumentation).apply {
71 setup {
72 eachRun {
73 testApp.launchViaIntent(wmHelper)
74 testApp.openIME(device, wmHelper)
75 }
76 }
77 teardown {
78 eachRun {
79 testApp.exit(wmHelper)
80 }
81 }
82 transitions {
83 device.pressHome()
84 wmHelper.waitForHomeActivityVisible()
85 wmHelper.waitImeGone()
86 }
87 }
88 }
89
90 @Presubmit
91 @Test
92 fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible()
93
94 @Presubmit
95 @Test
96 fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible()
97
98 @Presubmit
99 @Test
100 fun visibleWindowsShownMoreThanOneConsecutiveEntry() {
101 testSpec.assertWm {
102 this.visibleWindowsShownMoreThanOneConsecutiveEntry()
103 }
104 }
105
106 @Presubmit
107 @Test
108 fun imeAppWindowBecomesInvisible() {
109 testSpec.assertWm {
110 this.isAppWindowOnTop(testApp.component)
111 .then()
112 .isAppWindowNotOnTop(testApp.component)
113 }
114 }
115
116 @Presubmit
117 @Test
118 fun entireScreenCovered() = testSpec.entireScreenCovered()
119
120 @Presubmit
121 @Test
122 fun imeLayerVisibleStart() {
123 testSpec.assertLayersStart {
124 this.isVisible(FlickerComponentName.IME)
125 }
126 }
127
128 @Presubmit
129 @Test
130 fun imeLayerInvisibleEnd() {
131 testSpec.assertLayersEnd {
132 this.isInvisible(FlickerComponentName.IME)
133 }
134 }
135
136 @Presubmit
137 @Test
138 fun imeLayerBecomesInvisible() = testSpec.imeLayerBecomesInvisible()
139
140 @Presubmit
141 @Test
142 fun imeAppLayerBecomesInvisible() {
143 testSpec.assertLayers {
144 this.isVisible(testApp.component)
145 .then()
146 .isInvisible(testApp.component)
147 }
148 }
149
150 @Presubmit
151 @Test
152 fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales()
153
154 @FlakyTest(bugId = 206753786)
155 @Test
156 fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales()
157
158 @Presubmit
159 @Test
160 fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible()
161
162 @Presubmit
163 @Test
164 fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible()
165
166 @Presubmit
167 @Test
168 fun visibleLayersShownMoreThanOneConsecutiveEntry() {
169 testSpec.assertLayers {
170 this.visibleLayersShownMoreThanOneConsecutiveEntry(listOf(
171 FlickerComponentName.IME,
172 FlickerComponentName.SPLASH_SCREEN))
173 }
174 }
175
176 companion object {
177 @Parameterized.Parameters(name = "{0}")
178 @JvmStatic
179 fun getParams(): Collection<FlickerTestParameter> {
180 return FlickerTestParameterFactory.getInstance()
181 .getConfigNonRotationTests(repetitions = 3,
182 // b/190352379 (IME doesn't show on app launch in 90 degrees)
183 supportedRotations = listOf(Surface.ROTATION_0),
184 supportedNavigationModes = listOf(
185 WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY,
186 WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY)
187 )
188 }
189 }
190 }