Merge "Move tests from FlickerTests to WMShell"

This commit is contained in:
Antonella Dellanzo
2020-11-24 11:03:06 +00:00
committed by Android (Google) Code Review
15 changed files with 148 additions and 310 deletions

View File

@@ -29,7 +29,10 @@ android_test {
"truth-prebuilt",
"app-helpers-core",
"launcher-helper-lib",
"launcher-aosp-tapl"
"launcher-aosp-tapl",
"wm-flicker-common-assertions",
"wm-flicker-common-app-helpers",
"platform-test-annotations",
],
}
@@ -47,6 +50,9 @@ android_test {
"truth-prebuilt",
"app-helpers-core",
"launcher-helper-lib",
"launcher-aosp-tapl"
"launcher-aosp-tapl",
"wm-flicker-common-assertions",
"wm-flicker-common-app-helpers",
"platform-test-annotations",
],
}

View File

@@ -0,0 +1,19 @@
/*
* 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.wm.shell.flicker.pip
internal const val PIP_WINDOW_TITLE = "PipMenuActivity"

View File

@@ -19,104 +19,113 @@ package com.android.wm.shell.flicker.pip
import android.view.Surface
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.dsl.flicker
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.closePipWindow
import com.android.server.wm.flicker.helpers.expandPipWindow
import com.android.server.wm.flicker.helpers.hasPipWindow
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.wm.shell.flicker.navBarLayerIsAlwaysVisible
import com.android.wm.shell.flicker.navBarLayerRotatesAndScales
import com.android.wm.shell.flicker.navBarWindowIsAlwaysVisible
import com.android.wm.shell.flicker.noUncoveredRegions
import com.android.wm.shell.flicker.statusBarLayerIsAlwaysVisible
import com.android.wm.shell.flicker.statusBarLayerRotatesScales
import com.android.wm.shell.flicker.statusBarWindowIsAlwaysVisible
import com.android.wm.shell.flicker.PIP_WINDOW_NAME
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
import com.android.wm.shell.flicker.helpers.PipAppHelper
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test Pip launch.
* To run this test: `atest WMShellFlickerTests:PipToAppTest`
* To run this test: `atest WMShellFlickerTests:EnterPipTest`
*/
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FlakyTest(bugId = 152738416)
class EnterPipTest(
rotationName: String,
rotation: Int
) : PipTestBase(rotationName, rotation) {
@Test
fun test() {
flicker(instrumentation) {
withTag { buildTestTag("enterPip", testApp, rotation) }
repeat { 1 }
setup {
test {
device.wakeUpAndGoToHomeScreen()
}
eachRun {
device.pressHome()
testApp.open()
this.setRotation(rotation)
}
}
teardown {
eachRun {
if (device.hasPipWindow()) {
device.closePipWindow()
}
testApp.exit()
this.setRotation(Surface.ROTATION_0)
}
test {
if (device.hasPipWindow()) {
device.closePipWindow()
}
}
}
transitions {
testApp.clickEnterPipButton()
device.expandPipWindow()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
all("pipWindowBecomesVisible") {
this.showsAppWindow(testApp.`package`)
.then()
.showsAppWindow(PIP_WINDOW_NAME)
}
}
layersTrace {
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(rotation, Surface.ROTATION_0, allStates = false)
navBarLayerRotatesAndScales(rotation, Surface.ROTATION_0)
statusBarLayerRotatesScales(rotation, Surface.ROTATION_0)
all("pipLayerBecomesVisible") {
this.showsLayer(testApp.launcherName)
.then()
.showsLayer(PIP_WINDOW_NAME)
}
}
}
}
}
testName: String,
flickerSpec: Flicker
) : FlickerTestRunner(testName, flickerSpec) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
val supportedRotations = intArrayOf(Surface.ROTATION_0)
return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) }
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testApp = PipAppHelper(instrumentation)
return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0))
.buildTest { configuration ->
withTestName { buildTestTag("enterPip", testApp, configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
}
eachRun {
device.pressHome()
testApp.open()
this.setRotation(configuration.startRotation)
}
}
teardown {
eachRun {
if (device.hasPipWindow()) {
device.closePipWindow()
}
testApp.exit()
this.setRotation(Surface.ROTATION_0)
}
test {
if (device.hasPipWindow()) {
device.closePipWindow()
}
}
}
transitions {
testApp.clickEnterPipButton()
device.expandPipWindow()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
all("pipWindowBecomesVisible") {
this.showsAppWindow(testApp.`package`)
.then()
.showsAppWindow(PIP_WINDOW_TITLE)
}
}
layersTrace {
navBarLayerIsAlwaysVisible(bugId = 140855415)
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(configuration.startRotation, Surface.ROTATION_0,
enabled = false)
navBarLayerRotatesAndScales(configuration.startRotation,
Surface.ROTATION_0, bugId = 140855415)
statusBarLayerRotatesScales(configuration.startRotation,
Surface.ROTATION_0)
}
layersTrace {
all("pipLayerBecomesVisible") {
this.showsLayer(testApp.launcherName)
.then()
.showsLayer(PIP_WINDOW_TITLE)
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,135 @@
/*
* 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.wm.shell.flicker.pip
import android.view.Surface
import androidx.test.filters.FlakyTest
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.focusChanges
import com.android.server.wm.flicker.helpers.buildTestTag
import com.android.server.wm.flicker.helpers.closePipWindow
import com.android.server.wm.flicker.helpers.expandPipWindow
import com.android.server.wm.flicker.helpers.hasPipWindow
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.wm.shell.flicker.helpers.PipAppHelper
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test Pip launch.
* To run this test: `atest WMShellFlickerTests:PipToAppTest`
*/
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FlakyTest(bugId = 152738416)
class PipToAppTest(
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 = PipAppHelper(instrumentation)
return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0))
.buildTest { configuration ->
withTestName { buildTestTag("exitPipModeToApp", testApp, configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
device.pressHome()
testApp.open()
}
eachRun {
this.setRotation(configuration.startRotation)
testApp.clickEnterPipButton()
device.hasPipWindow()
}
}
teardown {
eachRun {
this.setRotation(Surface.ROTATION_0)
}
test {
if (device.hasPipWindow()) {
device.closePipWindow()
}
testApp.exit()
}
}
transitions {
device.expandPipWindow()
device.waitForIdle()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
all("appReplacesPipWindow") {
this.showsAppWindow(PIP_WINDOW_TITLE)
.then()
.showsAppWindowOnTop(testApp.launcherName)
}
}
layersTrace {
navBarLayerIsAlwaysVisible(bugId = 140855415)
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(configuration.startRotation, Surface.ROTATION_0,
enabled = false)
navBarLayerRotatesAndScales(configuration.startRotation,
Surface.ROTATION_0, bugId = 140855415)
statusBarLayerRotatesScales(configuration.startRotation,
Surface.ROTATION_0)
all("appReplacesPipLayer") {
this.showsLayer(PIP_WINDOW_TITLE)
.then()
.showsLayer(testApp.launcherName)
}
}
eventLog {
focusChanges(
"NexusLauncherActivity", testApp.launcherName,
"NexusLauncherActivity", bugId = 151179149)
}
}
}
}
}
}

View File

@@ -0,0 +1,135 @@
/*
* 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.wm.shell.flicker.pip
import android.view.Surface
import androidx.test.filters.FlakyTest
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.focusChanges
import com.android.server.wm.flicker.helpers.buildTestTag
import com.android.server.wm.flicker.helpers.closePipWindow
import com.android.server.wm.flicker.helpers.hasPipWindow
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.wm.shell.flicker.helpers.PipAppHelper
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test Pip launch.
* To run this test: `atest WMShellFlickerTests:PipToHomeTest`
*/
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FlakyTest(bugId = 152738416)
class PipToHomeTest(
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 = PipAppHelper(instrumentation)
return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0))
.buildTest { configuration ->
withTestName { buildTestTag("exitPipModeToApp", testApp, configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
device.pressHome()
}
eachRun {
testApp.open()
this.setRotation(configuration.startRotation)
testApp.clickEnterPipButton()
device.hasPipWindow()
}
}
teardown {
eachRun {
this.setRotation(Surface.ROTATION_0)
if (device.hasPipWindow()) {
device.closePipWindow()
}
}
test {
if (device.hasPipWindow()) {
device.closePipWindow()
}
testApp.exit()
}
}
transitions {
testApp.closePipWindow()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
all("pipWindowBecomesInvisible") {
this.showsAppWindow(PIP_WINDOW_TITLE)
.then()
.hidesAppWindow(PIP_WINDOW_TITLE)
}
}
layersTrace {
navBarLayerIsAlwaysVisible(bugId = 140855415)
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(configuration.startRotation, Surface.ROTATION_0,
enabled = false)
navBarLayerRotatesAndScales(configuration.startRotation,
Surface.ROTATION_0, bugId = 140855415)
statusBarLayerRotatesScales(configuration.startRotation,
Surface.ROTATION_0)
all("pipLayerBecomesInvisible") {
this.showsLayer(PIP_WINDOW_TITLE)
.then()
.hidesLayer(PIP_WINDOW_TITLE)
}
}
eventLog {
focusChanges(testApp.launcherName, "NexusLauncherActivity",
bugId = 151179149)
}
}
}
}
}
}

View File

@@ -0,0 +1,128 @@
/*
* 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.wm.shell.flicker.splitscreen
import android.platform.test.annotations.Presubmit
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.DOCKED_STACK_DIVIDER
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.endRotation
import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.focusChanges
import com.android.server.wm.flicker.helpers.buildTestTag
import com.android.server.wm.flicker.helpers.exitSplitScreen
import com.android.server.wm.flicker.helpers.isInSplitScreen
import com.android.server.wm.flicker.helpers.launchSplitScreen
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test open app to split screen.
* To run this test: `atest WMShellFlickerTests:OpenAppToSplitScreenTest`
*/
@Presubmit
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FlakyTest(bugId = 161435597)
class OpenAppToSplitScreenTest(
testName: String,
flickerSpec: Flicker
) : FlickerTestRunner(testName, flickerSpec) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testApp = StandardAppHelper(instrumentation,
"com.android.wm.shell.flicker.testapp", "SimpleApp")
return FlickerTestRunnerFactory(instrumentation)
.buildTest { configuration ->
withTestName {
buildTestTag("appToSplitScreen", testApp, configuration)
}
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
}
eachRun {
testApp.open()
this.setRotation(configuration.endRotation)
}
}
teardown {
eachRun {
if (device.isInSplitScreen()) {
device.exitSplitScreen()
}
}
test {
testApp.exit()
}
}
transitions {
device.launchSplitScreen()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
}
layersTrace {
navBarLayerIsAlwaysVisible(bugId = 140855415)
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(configuration.endRotation, enabled = false)
navBarLayerRotatesAndScales(configuration.endRotation,
bugId = 140855415)
statusBarLayerRotatesScales(configuration.endRotation)
all("dividerLayerBecomesVisible") {
this.hidesLayer(DOCKED_STACK_DIVIDER)
.then()
.showsLayer(DOCKED_STACK_DIVIDER)
}
}
eventLog {
focusChanges(testApp.`package`,
"recents_animation_input_consumer", "NexusLauncherActivity",
bugId = 151179149)
}
}
}
}
}
}

View File

@@ -0,0 +1,208 @@
/*
* 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.wm.shell.flicker.splitscreen
import android.graphics.Region
import android.util.Rational
import android.view.Surface
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import com.android.server.wm.flicker.DOCKED_STACK_DIVIDER
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.endRotation
import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.ImeAppHelper
import com.android.server.wm.flicker.focusDoesNotChange
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.helpers.buildTestTag
import com.android.server.wm.flicker.helpers.exitSplitScreen
import com.android.server.wm.flicker.helpers.isInSplitScreen
import com.android.server.wm.flicker.helpers.launchSplitScreen
import com.android.server.wm.flicker.helpers.resizeSplitScreen
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test split screen resizing window transitions.
* To run this test: `atest WMShellFlickerTests:ResizeSplitScreenTest`
*
* Currently it runs only in 0 degrees because of b/156100803
*/
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FlakyTest(bugId = 159096424)
class ResizeSplitScreenTest(
testName: String,
flickerSpec: Flicker
) : FlickerTestRunner(testName, flickerSpec) {
companion object {
private const val sSimpleActivity = "SimpleActivity"
private const val sImeActivity = "ImeActivity"
private val startRatio = Rational(1, 3)
private val stopRatio = Rational(2, 3)
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testAppTop = StandardAppHelper(instrumentation,
"com.android.wm.shell.flicker.testapp", "SimpleApp")
val testAppBottom = ImeAppHelper(instrumentation)
return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0))
.buildTest { configuration ->
withTestName {
val description = (startRatio.toString().replace("/", "-") + "_to_" +
stopRatio.toString().replace("/", "-"))
buildTestTag("resizeSplitScreen", testAppTop.launcherName,
configuration.startRotation, configuration.endRotation,
testAppBottom.launcherName, description)
}
repeat { configuration.repetitions }
setup {
eachRun {
device.wakeUpAndGoToHomeScreen()
this.setRotation(configuration.startRotation)
this.launcherStrategy.clearRecentAppsFromOverview()
testAppBottom.open()
device.pressHome()
testAppTop.open()
device.waitForIdle()
device.launchSplitScreen()
val snapshot =
device.findObject(By.res(device.launcherPackageName, "snapshot"))
snapshot.click()
testAppBottom.openIME(device)
device.pressBack()
device.resizeSplitScreen(startRatio)
}
}
teardown {
eachRun {
if (device.isInSplitScreen()) {
device.exitSplitScreen()
}
device.pressHome()
testAppTop.exit()
testAppBottom.exit()
}
test {
if (device.isInSplitScreen()) {
device.exitSplitScreen()
}
}
}
transitions {
device.resizeSplitScreen(stopRatio)
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
all("topAppWindowIsAlwaysVisible", bugId = 156223549) {
this.showsAppWindow(sSimpleActivity)
}
all("bottomAppWindowIsAlwaysVisible", bugId = 156223549) {
this.showsAppWindow(sImeActivity)
}
}
layersTrace {
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(configuration.endRotation)
navBarLayerRotatesAndScales(configuration.endRotation)
statusBarLayerRotatesScales(configuration.endRotation)
all("topAppLayerIsAlwaysVisible") {
this.showsLayer(sSimpleActivity)
}
all("bottomAppLayerIsAlwaysVisible") {
this.showsLayer(sImeActivity)
}
all("dividerLayerIsAlwaysVisible") {
this.showsLayer(DOCKED_STACK_DIVIDER)
}
start("appsStartingBounds", enabled = false) {
val displayBounds = WindowUtils.displayBounds
val entry = this.trace.entries.firstOrNull()
?: throw IllegalStateException("Trace is empty")
val dividerBounds =
entry.getVisibleBounds(DOCKED_STACK_DIVIDER).bounds
val topAppBounds = Region(0, 0, dividerBounds.right,
dividerBounds.top + WindowUtils.dockedStackDividerInset)
val bottomAppBounds = Region(0,
dividerBounds.bottom - WindowUtils.dockedStackDividerInset,
displayBounds.right,
displayBounds.bottom - WindowUtils.navigationBarHeight)
this.hasVisibleRegion("SimpleActivity", topAppBounds)
.and()
.hasVisibleRegion("ImeActivity", bottomAppBounds)
}
end("appsEndingBounds", enabled = false) {
val displayBounds = WindowUtils.displayBounds
val entry = this.trace.entries.lastOrNull()
?: throw IllegalStateException("Trace is empty")
val dividerBounds =
entry.getVisibleBounds(DOCKED_STACK_DIVIDER).bounds
val topAppBounds = Region(0, 0, dividerBounds.right,
dividerBounds.top + WindowUtils.dockedStackDividerInset)
val bottomAppBounds = Region(0,
dividerBounds.bottom - WindowUtils.dockedStackDividerInset,
displayBounds.right,
displayBounds.bottom - WindowUtils.navigationBarHeight)
this.hasVisibleRegion(sSimpleActivity, topAppBounds)
.and()
.hasVisibleRegion(sImeActivity, bottomAppBounds)
}
}
eventLog {
focusDoesNotChange()
}
}
}
}
}
}

View File

@@ -0,0 +1,134 @@
/*
* 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.wm.shell.flicker.splitscreen
import android.platform.test.annotations.Presubmit
import android.view.Surface
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.DOCKED_STACK_DIVIDER
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.StandardAppHelper
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.focusDoesNotChange
import com.android.server.wm.flicker.helpers.buildTestTag
import com.android.server.wm.flicker.helpers.exitSplitScreen
import com.android.server.wm.flicker.helpers.isInSplitScreen
import com.android.server.wm.flicker.helpers.launchSplitScreen
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test open app to split screen.
* To run this test: `atest WMShellFlickerTests:SplitScreenToLauncherTest`
*/
@Presubmit
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class SplitScreenToLauncherTest(
testName: String,
flickerSpec: Flicker
) : FlickerTestRunner(testName, flickerSpec) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testApp = StandardAppHelper(instrumentation,
"com.android.wm.shell.flicker.testapp", "SimpleApp")
// b/161435597 causes the test not to work on 90 degrees
return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0))
.buildTest { configuration ->
withTestName {
buildTestTag("splitScreenToLauncher", testApp, configuration)
}
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
}
eachRun {
testApp.open()
this.setRotation(configuration.endRotation)
device.launchSplitScreen()
device.waitForIdle()
}
}
teardown {
eachRun {
testApp.exit()
}
test {
if (device.isInSplitScreen()) {
device.exitSplitScreen()
}
}
}
transitions {
device.exitSplitScreen()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
}
layersTrace {
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(configuration.endRotation)
navBarLayerRotatesAndScales(configuration.endRotation)
statusBarLayerRotatesScales(configuration.endRotation)
// b/161435597 causes the test not to work on 90 degrees
all("dividerLayerBecomesInvisible") {
this.showsLayer(DOCKED_STACK_DIVIDER)
.then()
.hidesLayer(DOCKED_STACK_DIVIDER)
}
all("appLayerBecomesInvisible") {
this.showsLayer(testApp.getPackage())
.then()
.hidesLayer(testApp.getPackage())
}
}
eventLog {
focusDoesNotChange(bugId = 151179149)
}
}
}
}
}
}

View File

@@ -73,5 +73,15 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SimpleActivity"
android:taskAffinity="com.android.wm.shell.flicker.testapp.SimpleActivity"
android:label="SimpleApp"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_orange_light">
</LinearLayout>

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2018 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.wm.shell.flicker.testapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
public class SimpleActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams p = getWindow().getAttributes();
p.layoutInDisplayCutoutMode = WindowManager.LayoutParams
.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().setAttributes(p);
setContentView(R.layout.activity_simple);
}
}