| 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.helpers.ImeAppHelper |
| 32 |
import com.android.server.wm.flicker.navBarLayerIsVisible |
| 33 |
import com.android.server.wm.flicker.navBarLayerRotatesAndScales |
| 34 |
import com.android.server.wm.flicker.navBarWindowIsVisible |
| 35 |
import com.android.server.wm.flicker.entireScreenCovered |
| 36 |
import com.android.server.wm.flicker.dsl.FlickerBuilder |
| 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 org.junit.FixMethodOrder |
| 41 |
import org.junit.Test |
| 42 |
import org.junit.runner.RunWith |
| 43 |
import org.junit.runners.MethodSorters |
| 44 |
import org.junit.runners.Parameterized |
| 45 |
|
| 46 |
/** |
| 47 |
* Test IME window opening transitions. |
| 48 |
* To run this test: `atest FlickerTests:OpenImeWindowTest` |
| 49 |
*/ |
| 50 |
@RequiresDevice |
| 51 |
@RunWith(Parameterized::class) |
| 52 |
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) |
| 53 |
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
| 54 |
@Group2 |
| 55 |
class OpenImeWindowTest(private val testSpec: FlickerTestParameter) { |
| 56 |
private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() |
| 57 |
private val testApp = ImeAppHelper(instrumentation) |
| 58 |
|
| 59 |
@FlickerBuilderProvider |
| 60 |
fun buildFlicker(): FlickerBuilder { |
| 61 |
return FlickerBuilder(instrumentation).apply { |
| 62 |
setup { |
| 63 |
test { |
| 64 |
testApp.launchViaIntent(wmHelper) |
| 65 |
} |
| 66 |
} |
| 67 |
transitions { |
| 68 |
testApp.openIME(device, wmHelper) |
| 69 |
} |
| 70 |
teardown { |
| 71 |
eachRun { |
| 72 |
testApp.closeIME(device, wmHelper) |
| 73 |
} |
| 74 |
test { |
| 75 |
testApp.exit() |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
@Presubmit |
| 82 |
@Test |
| 83 |
fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() |
| 84 |
|
| 85 |
@Presubmit |
| 86 |
@Test |
| 87 |
fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() |
| 88 |
|
| 89 |
@Presubmit |
| 90 |
@Test |
| 91 |
fun imeWindowBecomesVisible() = testSpec.imeWindowBecomesVisible() |
| 92 |
|
| 93 |
@Presubmit |
| 94 |
@Test |
| 95 |
fun appWindowAlwaysVisibleOnTop() { |
| 96 |
testSpec.assertWm { |
| 97 |
this.isAppWindowOnTop(testApp.component) |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
@Presubmit |
| 102 |
@Test |
| 103 |
fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() |
| 104 |
|
| 105 |
@Presubmit |
| 106 |
@Test |
| 107 |
fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() |
| 108 |
|
| 109 |
@Presubmit |
| 110 |
@Test |
| 111 |
fun entireScreenCovered() = testSpec.entireScreenCovered() |
| 112 |
|
| 113 |
@Presubmit |
| 114 |
@Test |
| 115 |
fun imeLayerBecomesVisible() = testSpec.imeLayerBecomesVisible() |
| 116 |
|
| 117 |
@Presubmit |
| 118 |
@Test |
| 119 |
fun layerAlwaysVisible() { |
| 120 |
testSpec.assertLayers { |
| 121 |
this.isVisible(testApp.component) |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
@Presubmit |
| 126 |
@Test |
| 127 |
fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() |
| 128 |
|
| 129 |
@FlakyTest(bugId = 206753786) |
| 130 |
@Test |
| 131 |
fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() |
| 132 |
|
| 133 |
@Presubmit |
| 134 |
@Test |
| 135 |
fun visibleLayersShownMoreThanOneConsecutiveEntry() { |
| 136 |
testSpec.assertLayers { |
| 137 |
this.visibleLayersShownMoreThanOneConsecutiveEntry() |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
@Presubmit |
| 142 |
@Test |
| 143 |
fun visibleWindowsShownMoreThanOneConsecutiveEntry() { |
| 144 |
testSpec.assertWm { |
| 145 |
this.visibleWindowsShownMoreThanOneConsecutiveEntry() |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
companion object { |
| 150 |
@Parameterized.Parameters(name = "{0}") |
| 151 |
@JvmStatic |
| 152 |
fun getParams(): Collection<FlickerTestParameter> { |
| 153 |
return FlickerTestParameterFactory.getInstance() |
| 154 |
.getConfigNonRotationTests( |
| 155 |
repetitions = 3, |
| 156 |
supportedRotations = listOf(Surface.ROTATION_0), |
| 157 |
supportedNavigationModes = listOf( |
| 158 |
WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, |
| 159 |
WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY |
| 160 |
) |
| 161 |
) |
| 162 |
} |
| 163 |
} |
| 164 |
} |