Add test to open app from overview

Adding a new test to the flicker launch ones that opens an app from the overview.

Test: atest FlickerTests:OpenAppFromOverviewTest
Bug: b/171049760
Change-Id: I6ee397d17e2de1987d5d8aecd719fa81b2dfe7c0
This commit is contained in:
Antonella Dellanzo
2020-10-28 10:04:33 +01:00
parent 64cd208bee
commit a7f9bb290a

View File

@@ -0,0 +1,84 @@
/*
* 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.launch
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.FlickerTestRunnerFactory
import com.android.server.wm.flicker.FlickerTestRunner
import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.reopenAppFromOverview
import com.android.server.wm.flicker.helpers.hasWindow
import com.android.server.wm.flicker.helpers.buildTestTag
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
/**
* Launch an app from the recents app view (the overview)
* To run this test: `atest FlickerTests:OpenAppFromOverviewTest`
*/
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class OpenAppFromOverviewTest(
testName: String,
flickerSpec: Flicker
) : FlickerTestRunner(testName, flickerSpec) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testApp = StandardAppHelper(instrumentation,
"com.android.server.wm.flicker.testapp", "SimpleApp")
return FlickerTestRunnerFactory(instrumentation, repetitions = 10)
.buildTest { configuration ->
withTag { buildTestTag("openAppFromOverview", testApp, configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
testApp.open()
}
eachRun {
device.pressHome()
device.pressRecentApps()
this.setRotation(configuration.startRotation)
}
}
transitions {
device.reopenAppFromOverview()
device.hasWindow(testApp.getPackage())
}
teardown {
test {
testApp.exit()
this.setRotation(Surface.ROTATION_0)
}
}
}
}
}
}