Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeOnStartTest.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.FlickerBuilderProvider
26 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
27 import com.android.server.wm.flicker.FlickerTestParameter
28 import com.android.server.wm.flicker.FlickerTestParameterFactory
29 import com.android.server.wm.flicker.dsl.FlickerBuilder
30 import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper
31 import com.android.server.wm.flicker.helpers.ImeStateInitializeHelper
32 import com.android.server.wm.flicker.helpers.setRotation
33 import com.android.server.wm.traces.common.FlickerComponentName
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 * Launch an app that automatically displays the IME
42 *
43 * To run this test: `atest FlickerTests:LaunchAppShowImeOnStartTest`
44 *
45 * Actions:
46 * Make sure no apps are running on the device
47 * Launch an app [testApp] that automatically displays IME and wait animation to complete
48 *
49 * To run only the presubmit assertions add: `--
50 * --module-arg FlickerTests:exclude-annotation:androidx.test.filters.FlakyTest
51 * --module-arg FlickerTests:include-annotation:android.platform.test.annotations.Presubmit`
52 *
53 * To run only the postsubmit assertions add: `--
54 * --module-arg FlickerTests:exclude-annotation:androidx.test.filters.FlakyTest
55 * --module-arg FlickerTests:include-annotation:android.platform.test.annotations.Postsubmit`
56 *
57 * To run only the flaky assertions add: `--
58 * --module-arg FlickerTests:include-annotation:androidx.test.filters.FlakyTest`
59 *
60 * Notes:
61 * 1. Some default assertions (e.g., nav bar, status bar and screen covered)
62 * are inherited [CloseAppTransition]
63 * 2. Part of the test setup occurs automatically via
64 * [com.android.server.wm.flicker.TransitionRunnerWithRules],
65 * including configuring navigation mode, initial orientation and ensuring no
66 * apps are running before setup
67 */
68 @RequiresDevice
69 @RunWith(Parameterized::class)
70 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
71 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
72 class LaunchAppShowImeOnStartTest(private val testSpec: FlickerTestParameter) {
73 private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
74 private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation)
75 private val initializeApp = ImeStateInitializeHelper(instrumentation)
76
77 @FlickerBuilderProvider
78 fun buildFlicker(): FlickerBuilder {
79 return FlickerBuilder(instrumentation).apply {
80 setup {
81 eachRun {
82 initializeApp.launchViaIntent()
83 this.setRotation(testSpec.startRotation)
84 }
85 }
86 teardown {
87 eachRun {
88 initializeApp.exit()
89 testApp.exit()
90 }
91 }
92 transitions {
93 testApp.launchViaIntent(wmHelper)
94 wmHelper.waitImeShown()
95 }
96 }
97 }
98
99 /**
100 * Checks that [FlickerComponentName.IME] window becomes visible during the transition
101 */
102 @Presubmit
103 @Test
104 fun imeWindowBecomesVisible() = testSpec.imeWindowBecomesVisible()
105
106 /**
107 * Checks that [FlickerComponentName.IME] layer becomes visible during the transition
108 */
109 @Presubmit
110 @Test
111 fun imeLayerBecomesVisible() = testSpec.imeLayerBecomesVisible()
112
113 /**
114 * Checks that [FlickerComponentName.IME] layer is invisible at the start of the transition
115 */
116 @Presubmit
117 @Test
118 fun imeLayerNotExistsStart() {
119 testSpec.assertLayersStart {
120 this.isInvisible(FlickerComponentName.IME)
121 }
122 }
123
124 /**
125 * Checks that [FlickerComponentName.IME] layer is visible at the end of the transition
126 */
127 @Presubmit
128 @Test
129 fun imeLayerExistsEnd() {
130 testSpec.assertLayersEnd {
131 this.isVisible(FlickerComponentName.IME)
132 }
133 }
134
135 companion object {
136 /**
137 * Creates the test configurations.
138 *
139 * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
140 * repetitions, screen orientation and navigation modes.
141 */
142 @Parameterized.Parameters(name = "{0}")
143 @JvmStatic
144 fun getParams(): Collection<FlickerTestParameter> {
145 return FlickerTestParameterFactory.getInstance()
146 .getConfigNonRotationTests(
147 repetitions = 3,
148 supportedRotations = listOf(Surface.ROTATION_0),
149 supportedNavigationModes = listOf(
150 WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY,
151 WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY
152 )
153 )
154 }
155 }
156 }