diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2021-11-15 12:28:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-11-15 12:28:02 +0000 |
commit | 2a3027fd8631e36e8ec98948968471a9ada8ccd9 (patch) | |
tree | a71880f8bb6079406e689b85de1123d192489bb0 /tests | |
parent | b62fb90d71c062d51fd6a73ddaf2a550c6c3073b (diff) | |
parent | e2cf2faa7d64b1d2ea195c606fc77e976dccf6b3 (diff) |
Merge "Add a regression test to verify no IME flickering when navigating back" into sc-v2-dev
Diffstat (limited to 'tests')
4 files changed, 158 insertions, 0 deletions
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppHelper.kt index 1c2164a70a55..7ee6451b2797 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppHelper.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppHelper.kt @@ -84,4 +84,20 @@ open class ImeAppHelper @JvmOverloads constructor( wmHelper.waitImeGone() } } + + @JvmOverloads + open fun finishActivity(device: UiDevice, wmHelper: WindowManagerStateHelper? = null) { + val finishButton = device.wait( + Until.findObject(By.res(getPackage(), "finish_activity_btn")), + FIND_TIMEOUT) + require(finishButton != null) { + "Finish activity button not found, probably IME activity is not on the screen ?" + } + finishButton.click() + if (wmHelper == null) { + device.waitForIdle() + } else { + wmHelper.waitForActivityRemoved(component) + } + } }
\ No newline at end of file diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowAndCloseTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowAndCloseTest.kt new file mode 100644 index 000000000000..972918e28fa7 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowAndCloseTest.kt @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.wm.flicker.ime + +import android.app.Instrumentation +import android.platform.test.annotations.Presubmit +import android.view.Surface +import android.view.WindowManagerPolicyConstants +import androidx.test.filters.RequiresDevice +import androidx.test.platform.app.InstrumentationRegistry +import com.android.server.wm.flicker.* +import com.android.server.wm.flicker.annotation.Group2 +import com.android.server.wm.flicker.dsl.FlickerBuilder +import com.android.server.wm.flicker.helpers.ImeAppHelper +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Unlike {@link OpenImeWindowTest} testing IME window opening transitions, this test also verify + * there is no flickering when back to the simple activity without requesting IME to show. + * + * To run this test: `atest FlickerTests:OpenImeWindowAndCloseTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Group2 +class OpenImeWindowAndCloseTest(private val testSpec: FlickerTestParameter) { + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val simpleApp = SimpleAppHelper(instrumentation) + private val testApp = ImeAppHelper(instrumentation) + + @FlickerBuilderProvider + fun buildFlicker(): FlickerBuilder { + return FlickerBuilder(instrumentation).apply { + setup { + eachRun { + simpleApp.launchViaIntent(wmHelper) + testApp.launchViaIntent(wmHelper) + testApp.openIME(device, wmHelper) + } + } + transitions { + testApp.finishActivity(device, wmHelper) + } + teardown { + test { + simpleApp.exit() + } + } + } + } + + @Presubmit + @Test + fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() + + @Presubmit + @Test + fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() + + @Presubmit + @Test + fun imeWindowBecomesInvisible() = testSpec.imeWindowBecomesInvisible() + + @Presubmit + @Test + fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() + + @Presubmit + @Test + fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() + + @Presubmit + @Test + fun entireScreenCovered() = testSpec.entireScreenCovered() + + @Presubmit + @Test + fun imeLayerBecomesInvisible() = testSpec.imeLayerBecomesInvisible() + + @Presubmit + @Test + fun visibleLayersShownMoreThanOneConsecutiveEntry() { + testSpec.assertLayers { + this.visibleLayersShownMoreThanOneConsecutiveEntry() + } + } + + @Test + fun visibleWindowsShownMoreThanOneConsecutiveEntry() { + testSpec.assertWm { + this.visibleWindowsShownMoreThanOneConsecutiveEntry() + } + } + + companion object { + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection<FlickerTestParameter> { + return FlickerTestParameterFactory.getInstance() + .getConfigNonRotationTests( + repetitions = 3, + supportedRotations = listOf(Surface.ROTATION_0), + supportedNavigationModes = listOf( + WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, + WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY + ) + ) + } + } +}
\ No newline at end of file diff --git a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_ime.xml b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_ime.xml index c55e7c2720db..2620ff407efc 100644 --- a/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_ime.xml +++ b/tests/FlickerTests/test-apps/flickerapp/res/layout/activity_ime.xml @@ -18,6 +18,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" + android:orientation="vertical" android:focusableInTouchMode="true" android:background="@android:color/holo_green_light"> <EditText android:id="@+id/plain_text_input" @@ -25,4 +26,9 @@ android:layout_width="match_parent" android:imeOptions="flagNoExtractUi" android:inputType="text"/> + <Button + android:id="@+id/finish_activity_btn" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Finish activity" /> </LinearLayout> diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ImeActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ImeActivity.java index df60460e7ae3..d7ee2af44111 100644 --- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ImeActivity.java +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ImeActivity.java @@ -19,6 +19,7 @@ package com.android.server.wm.flicker.testapp; import android.app.Activity; import android.os.Bundle; import android.view.WindowManager; +import android.widget.Button; public class ImeActivity extends Activity { @Override @@ -29,5 +30,9 @@ public class ImeActivity extends Activity { .LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; getWindow().setAttributes(p); setContentView(R.layout.activity_ime); + Button button = findViewById(R.id.finish_activity_btn); + button.setOnClickListener(view -> { + finish(); + }); } } |