Merge "Add a regression test to verify no IME flickering when navigating back" into sc-v2-dev am: 2a3027fd86 am: 7b4da68f22
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16245703 Change-Id: I8c22c3651f2795bcc21b91a4e2ff2b6aa9881116
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user