Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowAndCloseTest.kt

raw
1 /*
2 * Copyright (C) 2021 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.RequiresDevice
24 import androidx.test.platform.app.InstrumentationRegistry
25 import com.android.server.wm.flicker.*
26 import com.android.server.wm.flicker.annotation.Group2
27 import com.android.server.wm.flicker.dsl.FlickerBuilder
28 import com.android.server.wm.flicker.helpers.ImeAppHelper
29 import com.android.server.wm.flicker.helpers.SimpleAppHelper
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 * Unlike {@link OpenImeWindowTest} testing IME window opening transitions, this test also verify
38 * there is no flickering when back to the simple activity without requesting IME to show.
39 *
40 * To run this test: `atest FlickerTests:OpenImeWindowAndCloseTest`
41 */
42 @RequiresDevice
43 @RunWith(Parameterized::class)
44 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
45 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
46 @Group2
47 class OpenImeWindowAndCloseTest(private val testSpec: FlickerTestParameter) {
48 private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
49 private val simpleApp = SimpleAppHelper(instrumentation)
50 private val testApp = ImeAppHelper(instrumentation)
51
52 @FlickerBuilderProvider
53 fun buildFlicker(): FlickerBuilder {
54 return FlickerBuilder(instrumentation).apply {
55 setup {
56 eachRun {
57 simpleApp.launchViaIntent(wmHelper)
58 testApp.launchViaIntent(wmHelper)
59 testApp.openIME(device, wmHelper)
60 }
61 }
62 transitions {
63 testApp.finishActivity(device, wmHelper)
64 }
65 teardown {
66 test {
67 simpleApp.exit()
68 }
69 }
70 }
71 }
72
73 @Presubmit
74 @Test
75 fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible()
76
77 @Presubmit
78 @Test
79 fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible()
80
81 @Presubmit
82 @Test
83 fun imeWindowBecomesInvisible() = testSpec.imeWindowBecomesInvisible()
84
85 @Presubmit
86 @Test
87 fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible()
88
89 @Presubmit
90 @Test
91 fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible()
92
93 @Presubmit
94 @Test
95 fun entireScreenCovered() = testSpec.entireScreenCovered()
96
97 @Presubmit
98 @Test
99 fun imeLayerBecomesInvisible() = testSpec.imeLayerBecomesInvisible()
100
101 @Presubmit
102 @Test
103 fun visibleLayersShownMoreThanOneConsecutiveEntry() {
104 testSpec.assertLayers {
105 this.visibleLayersShownMoreThanOneConsecutiveEntry()
106 }
107 }
108
109 @Test
110 fun visibleWindowsShownMoreThanOneConsecutiveEntry() {
111 testSpec.assertWm {
112 this.visibleWindowsShownMoreThanOneConsecutiveEntry()
113 }
114 }
115
116 companion object {
117 @Parameterized.Parameters(name = "{0}")
118 @JvmStatic
119 fun getParams(): Collection<FlickerTestParameter> {
120 return FlickerTestParameterFactory.getInstance()
121 .getConfigNonRotationTests(
122 repetitions = 3,
123 supportedRotations = listOf(Surface.ROTATION_0),
124 supportedNavigationModes = listOf(
125 WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY,
126 WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY
127 )
128 )
129 }
130 }
131 }