| 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.entireScreenCovered |
| 33 |
import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper |
| 34 |
import com.android.server.wm.flicker.navBarLayerIsVisible |
| 35 |
import com.android.server.wm.flicker.navBarLayerRotatesAndScales |
| 36 |
import com.android.server.wm.flicker.navBarWindowIsVisible |
| 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:CloseImeAutoOpenWindowToAppTest` |
| 58 |
*/ |
| 59 |
@RequiresDevice |
| 60 |
@RunWith(Parameterized::class) |
| 61 |
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) |
| 62 |
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
| 63 |
@Group2 |
| 64 |
class CloseImeAutoOpenWindowToAppTest(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 |
testApp.closeIME(device, wmHelper) |
| 84 |
} |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
@Presubmit |
| 89 |
@Test |
| 90 |
fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() |
| 91 |
|
| 92 |
@Presubmit |
| 93 |
@Test |
| 94 |
fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() |
| 95 |
|
| 96 |
@Presubmit |
| 97 |
@Test |
| 98 |
fun visibleWindowsShownMoreThanOneConsecutiveEntry() { |
| 99 |
testSpec.assertWm { |
| 100 |
this.visibleWindowsShownMoreThanOneConsecutiveEntry() |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
@Presubmit |
| 105 |
@Test |
| 106 |
fun imeAppWindowIsAlwaysVisible() { |
| 107 |
testSpec.assertWm { |
| 108 |
this.isAppWindowOnTop(testApp.component) |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
@Presubmit |
| 113 |
@Test |
| 114 |
fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() |
| 115 |
|
| 116 |
@Presubmit |
| 117 |
@Test |
| 118 |
fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() |
| 119 |
|
| 120 |
@Presubmit |
| 121 |
@Test |
| 122 |
fun entireScreenCovered() = testSpec.entireScreenCovered() |
| 123 |
|
| 124 |
@Presubmit |
| 125 |
@Test |
| 126 |
fun imeLayerVisibleStart() { |
| 127 |
testSpec.assertLayersStart { |
| 128 |
this.isVisible(FlickerComponentName.IME) |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
@Presubmit |
| 133 |
@Test |
| 134 |
fun imeLayerInvisibleEnd() { |
| 135 |
testSpec.assertLayersEnd { |
| 136 |
this.isInvisible(FlickerComponentName.IME) |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
@Presubmit |
| 141 |
@Test |
| 142 |
fun imeLayerBecomesInvisible() = testSpec.imeLayerBecomesInvisible() |
| 143 |
|
| 144 |
@Presubmit |
| 145 |
@Test |
| 146 |
fun imeAppLayerIsAlwaysVisible() { |
| 147 |
testSpec.assertLayers { |
| 148 |
this.isVisible(testApp.component) |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
@Presubmit |
| 153 |
@Test |
| 154 |
fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() |
| 155 |
|
| 156 |
@FlakyTest(bugId = 206753786) |
| 157 |
@Test |
| 158 |
fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() |
| 159 |
|
| 160 |
@Presubmit |
| 161 |
@Test |
| 162 |
fun visibleLayersShownMoreThanOneConsecutiveEntry() { |
| 163 |
testSpec.assertLayers { |
| 164 |
this.visibleLayersShownMoreThanOneConsecutiveEntry() |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
companion object { |
| 169 |
@Parameterized.Parameters(name = "{0}") |
| 170 |
@JvmStatic |
| 171 |
fun getParams(): Collection<FlickerTestParameter> { |
| 172 |
return FlickerTestParameterFactory.getInstance() |
| 173 |
.getConfigNonRotationTests(repetitions = 3, |
| 174 |
// b/190352379 (IME doesn't show on app launch in 90 degrees) |
| 175 |
supportedRotations = listOf(Surface.ROTATION_0), |
| 176 |
supportedNavigationModes = listOf( |
| 177 |
WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, |
| 178 |
WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY) |
| 179 |
) |
| 180 |
} |
| 181 |
} |
| 182 |
} |