Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeAndDialogThemeAppTest.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.view.WindowInsets.Type.ime
20 import android.view.WindowInsets.Type.navigationBars
21 import android.view.WindowInsets.Type.statusBars
22
23 import android.app.Instrumentation
24 import android.platform.test.annotations.Presubmit
25 import android.view.Surface
26 import android.view.WindowManagerPolicyConstants
27 import androidx.test.filters.FlakyTest
28 import androidx.test.filters.RequiresDevice
29 import androidx.test.platform.app.InstrumentationRegistry
30 import com.android.server.wm.flicker.FlickerBuilderProvider
31 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
32 import com.android.server.wm.flicker.FlickerTestParameter
33 import com.android.server.wm.flicker.FlickerTestParameterFactory
34 import com.android.server.wm.flicker.dsl.FlickerBuilder
35 import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper
36 import com.android.server.wm.traces.common.FlickerComponentName
37 import org.junit.FixMethodOrder
38 import org.junit.Test
39 import org.junit.runner.RunWith
40 import org.junit.runners.MethodSorters
41 import org.junit.runners.Parameterized
42 import org.junit.Assert.assertFalse
43 import org.junit.Assert.assertTrue
44
45 /**
46 * Test IME snapshot mechanism won't apply when transitioning from non-IME focused dialog activity.
47 * To run this test: `atest FlickerTests:LaunchAppShowImeAndDialogThemeAppTest`
48 */
49 @RequiresDevice
50 @RunWith(Parameterized::class)
51 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
52 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
53 class LaunchAppShowImeAndDialogThemeAppTest(private val testSpec: FlickerTestParameter) {
54 private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
55 private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation)
56
57 @FlickerBuilderProvider
58 fun buildFlicker(): FlickerBuilder {
59 return FlickerBuilder(instrumentation).apply {
60 setup {
61 eachRun {
62 testApp.launchViaIntent(wmHelper)
63 wmHelper.waitImeShown()
64 testApp.startDialogThemedActivity(wmHelper)
65 // Verify IME insets isn't visible on dialog since it's non-IME focusable window
66 assertFalse(testApp.getInsetsVisibleFromDialog(ime()))
67 assertTrue(testApp.getInsetsVisibleFromDialog(statusBars()))
68 assertTrue(testApp.getInsetsVisibleFromDialog(navigationBars()))
69 }
70 }
71 teardown {
72 eachRun {
73 testApp.exit()
74 }
75 }
76 transitions {
77 testApp.dismissDialog(wmHelper)
78 }
79 }
80 }
81
82 /**
83 * Checks that [FlickerComponentName.IME] layer becomes visible during the transition
84 */
85 @FlakyTest(bugId = 215884488)
86 @Test
87 fun imeWindowIsAlwaysVisible() = testSpec.imeWindowIsAlwaysVisible()
88
89 /**
90 * Checks that [FlickerComponentName.IME] layer is visible at the end of the transition
91 */
92 @FlakyTest(bugId = 227142436)
93 @Test
94 fun imeLayerExistsEnd() {
95 testSpec.assertLayersEnd {
96 this.isVisible(FlickerComponentName.IME)
97 }
98 }
99
100 /**
101 * Checks that [FlickerComponentName.IME_SNAPSHOT] layer is invisible always.
102 */
103 @Presubmit
104 @Test
105 fun imeSnapshotNotVisible() {
106 testSpec.assertLayers {
107 this.isInvisible(FlickerComponentName.IME_SNAPSHOT)
108 }
109 }
110
111 companion object {
112 /**
113 * Creates the test configurations.
114 *
115 * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
116 * repetitions, screen orientation and navigation modes.
117 */
118 @Parameterized.Parameters(name = "{0}")
119 @JvmStatic
120 fun getParams(): Collection<FlickerTestParameter> {
121 return FlickerTestParameterFactory.getInstance()
122 .getConfigNonRotationTests(
123 repetitions = 3,
124 supportedRotations = listOf(Surface.ROTATION_0),
125 supportedNavigationModes = listOf(
126 WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY,
127 WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY
128 )
129 )
130 }
131 }
132 }