From 07f68e36fdc5bfc892c6f2840180ad7b28312eec Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Thu, 7 Jan 2021 12:10:47 +0100 Subject: [PATCH] Expect IME to use whole screen on landscape On flame the IME is using the whole UI and the test app is not visible, when the phone is in landscape mode. Make the flicker tests compatible with this change. Bug: 176799414 Test: atest FlickerTests Change-Id: I52f18e4b6c1dc48758b833fbf4e11e80853effc2 --- .../wm/flicker/helpers/ImeAppAutoFocusHelper.kt | 15 ++++++++++++++- .../ime/CloseImeAutoOpenWindowToAppTest.kt | 3 ++- .../ime/CloseImeAutoOpenWindowToHomeTest.kt | 3 ++- .../server/wm/flicker/ime/ReOpenImeWindowTest.kt | 3 ++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppAutoFocusHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppAutoFocusHelper.kt index d587f1e383c53..6bf2c855f08ad 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppAutoFocusHelper.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppAutoFocusHelper.kt @@ -19,8 +19,21 @@ package com.android.server.wm.flicker.helpers import android.app.Instrumentation import androidx.test.uiautomator.UiDevice -class ImeAppAutoFocusHelper(instr: Instrumentation) : ImeAppHelper(instr, "ImeAppAutoFocus") { +class ImeAppAutoFocusHelper @JvmOverloads constructor( + instr: Instrumentation, + private val rotation: Int, + private val imePackageName: String = IME_PACKAGE +) : ImeAppHelper(instr, "ImeAppAutoFocus") { override fun openIME(device: UiDevice) { // do nothing (the app is focused automatically) } + + override fun open() { + val expectedPackage = if (rotation.isRotated()) { + imePackageName + } else { + packageName + } + launcherStrategy.launch(appName, expectedPackage) + } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToAppTest.kt index b341e621d9ed9..412a3c383785c 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToAppTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToAppTest.kt @@ -61,10 +61,11 @@ class CloseImeAutoOpenWindowToAppTest( @JvmStatic fun getParams(): List> { val instrumentation = InstrumentationRegistry.getInstrumentation() - val testApp = ImeAppAutoFocusHelper(instrumentation) return FlickerTestRunnerFactory(instrumentation) .buildTest { configuration -> + val testApp = ImeAppAutoFocusHelper(instrumentation, + configuration.startRotation) withTag { buildTestTag("imeToAppAutoOpen", testApp, configuration) } repeat { configuration.repetitions } setup { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.kt index 51a4ca86681b2..60a798fda5e4f 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.kt @@ -61,10 +61,11 @@ class CloseImeAutoOpenWindowToHomeTest( @JvmStatic fun getParams(): List> { val instrumentation = InstrumentationRegistry.getInstrumentation() - val testApp = ImeAppAutoFocusHelper(instrumentation) return FlickerTestRunnerFactory(instrumentation) .buildTest { configuration -> + val testApp = ImeAppAutoFocusHelper(instrumentation, + configuration.startRotation) withTestName { buildTestTag("imeToHomeAutoOpen", testApp, configuration) } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt index c7114da501178..d1842739171d1 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt @@ -66,11 +66,12 @@ class ReOpenImeWindowTest( @JvmStatic fun getParams(): List> { val instrumentation = InstrumentationRegistry.getInstrumentation() - val testApp = ImeAppAutoFocusHelper(instrumentation) val testAppComponentName = ActivityOptions.IME_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME return FlickerTestRunnerFactory(instrumentation, repetitions = 5) .buildTest { configuration -> + val testApp = ImeAppAutoFocusHelper(instrumentation, + configuration.startRotation) withTestName { buildTestTag("reOpenImeAutoFocus", testApp, configuration) } repeat { configuration.repetitions } setup {