Debian Codegraph @

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

raw
1 /*
2 * Copyright (C) 2022 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.Postsubmit
21 import android.platform.test.annotations.Presubmit
22 import android.platform.test.annotations.RequiresDevice
23 import android.view.Surface
24 import android.view.WindowManagerPolicyConstants
25 import androidx.test.filters.FlakyTest
26 import androidx.test.platform.app.InstrumentationRegistry
27 import com.android.launcher3.tapl.LauncherInstrumentation
28 import com.android.server.wm.flicker.FlickerBuilderProvider
29 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
30 import com.android.server.wm.flicker.FlickerTestParameter
31 import com.android.server.wm.flicker.FlickerTestParameterFactory
32 import com.android.server.wm.flicker.annotation.Group2
33 import com.android.server.wm.flicker.dsl.FlickerBuilder
34 import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper
35 import com.android.server.wm.flicker.helpers.setRotation
36 import com.android.server.wm.flicker.navBarLayerPositionEnd
37 import com.android.server.wm.flicker.navBarWindowIsVisible
38 import com.android.server.wm.flicker.snapshotStartingWindowLayerCoversExactlyOnApp
39 import com.android.server.wm.flicker.statusBarLayerRotatesScales
40 import com.android.server.wm.flicker.statusBarWindowIsVisible
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 layer will become visible when switching from the fixed orientation activity
49 * (e.g. Launcher activity).
50 * To run this test: `atest FlickerTests:OpenImeWindowFromFixedOrientationAppTest`
51 */
52 @RequiresDevice
53 @RunWith(Parameterized::class)
54 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
55 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
56 @Group2
57 class OpenImeWindowFromFixedOrientationAppTest(private val testSpec: FlickerTestParameter) {
58 private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
59 private val imeTestApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation)
60 private val taplInstrumentation = LauncherInstrumentation()
61
62 @FlickerBuilderProvider
63 fun buildFlicker(): FlickerBuilder {
64 return FlickerBuilder(instrumentation).apply {
65 setup {
66 test {
67 // Launch the activity with expecting IME will be shown.
68 imeTestApp.launchViaIntent(wmHelper)
69 }
70 eachRun {
71 // Swiping out the IME activity to home.
72 taplInstrumentation.goHome()
73 wmHelper.waitForHomeActivityVisible()
74 }
75 }
76 transitions {
77 // Bring the exist IME activity to the front in landscape mode device rotation.
78 setRotation(Surface.ROTATION_90)
79 imeTestApp.launchViaIntent(wmHelper)
80 }
81 teardown {
82 test {
83 imeTestApp.exit(wmHelper)
84 }
85 }
86 }
87 }
88
89 @Presubmit
90 @Test
91 fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible()
92
93 @Presubmit
94 @Test
95 fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible()
96
97 @Presubmit
98 @Test
99 fun imeWindowBecomesVisible() = testSpec.imeWindowBecomesVisible()
100
101 @Presubmit
102 @Test
103 fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd()
104
105 @FlakyTest(bugId = 206753786)
106 fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales()
107
108 @Presubmit
109 @Test
110 fun imeLayerBecomesVisible() = testSpec.imeLayerBecomesVisible()
111
112 @Postsubmit
113 @Test
114 fun snapshotStartingWindowLayerCoversExactlyOnApp() {
115 testSpec.snapshotStartingWindowLayerCoversExactlyOnApp(imeTestApp.component)
116 }
117
118 companion object {
119 /**
120 * Creates the test configurations.
121 *
122 * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
123 * repetitions, screen orientation and navigation modes.
124 */
125 @Parameterized.Parameters(name = "{0}")
126 @JvmStatic
127 fun getParams(): Collection<FlickerTestParameter> {
128 return FlickerTestParameterFactory.getInstance()
129 .getConfigNonRotationTests(
130 repetitions = 3,
131 supportedRotations = listOf(Surface.ROTATION_90),
132 supportedNavigationModes = listOf(
133 WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY
134 )
135 )
136 }
137 }
138 }