From 76ed5ef0be9e04a3628c14190a9597f190b5ccdf Mon Sep 17 00:00:00 2001 From: Antonella Dellanzo Date: Thu, 12 Nov 2020 18:12:51 +0100 Subject: [PATCH] Add test transition to reopen ime window app Add a new test (only the transition at the moment) that reopens an IME app with focused IME from recents apps and it will check (once we add the assertions) that the IME is still showing. Test: atest FlickerTests:ReOpenImeWindowTest Bug: b/171049722 Change-Id: I43f89bb26b6abcaba4b984b0955034bdf41b2977 --- .../wm/flicker/ime/ReOpenImeWindowTest.kt | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt 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 new file mode 100644 index 0000000000000..7b5dc872a5a2f --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2020 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.view.Surface +import androidx.test.filters.RequiresDevice +import androidx.test.platform.app.InstrumentationRegistry +import com.android.server.wm.flicker.Flicker +import com.android.server.wm.flicker.FlickerTestRunner +import com.android.server.wm.flicker.FlickerTestRunnerFactory +import com.android.server.wm.flicker.helpers.buildTestTag +import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper +import com.android.server.wm.flicker.helpers.reopenAppFromOverview +import com.android.server.wm.flicker.helpers.hasWindow +import com.android.server.wm.flicker.helpers.setRotation +import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen +import com.android.server.wm.flicker.repetitions +import com.android.server.wm.flicker.startRotation +import org.junit.FixMethodOrder +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test IME window opening transitions. + * To run this test: `atest FlickerTests:ReOpenImeWindowTest` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class ReOpenImeWindowTest( + testName: String, + flickerSpec: Flicker +) : FlickerTestRunner(testName, flickerSpec) { + companion object { + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): List> { + val instrumentation = InstrumentationRegistry.getInstrumentation() + val testApp = ImeAppAutoFocusHelper(instrumentation) + + return FlickerTestRunnerFactory(instrumentation, repetitions = 10) + .buildTest { configuration -> + withTestName { buildTestTag("reOpenImeAutoFocus", testApp, configuration) } + repeat { configuration.repetitions } + setup { + test { + device.wakeUpAndGoToHomeScreen() + } + eachRun { + testApp.open() + testApp.openIME(device) + device.pressHome() + device.pressRecentApps() + this.setRotation(configuration.startRotation) + } + } + transitions { + device.reopenAppFromOverview() + device.hasWindow(testApp.getPackage()) + } + teardown { + eachRun { + testApp.closeIME(device) + testApp.exit() + } + test { + this.setRotation(Surface.ROTATION_0) + } + } + } + } + } +} \ No newline at end of file