Merge "Move tests from FlickerTests to WMShell"
This commit is contained in:
committed by
Android (Google) Code Review
commit
ba500e9603
@@ -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",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.wm.flicker.pip
|
||||
package com.android.wm.shell.flicker.pip
|
||||
|
||||
internal const val PIP_WINDOW_TITLE = "PipMenuActivity"
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.wm.flicker.pip
|
||||
package com.android.wm.shell.flicker.pip
|
||||
|
||||
import android.view.Surface
|
||||
import androidx.test.filters.FlakyTest
|
||||
@@ -24,7 +24,6 @@ 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.PipAppHelper
|
||||
import com.android.server.wm.flicker.helpers.buildTestTag
|
||||
import com.android.server.wm.flicker.helpers.closePipWindow
|
||||
import com.android.server.wm.flicker.helpers.expandPipWindow
|
||||
@@ -40,6 +39,7 @@ 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
|
||||
@@ -47,7 +47,7 @@ import org.junit.runners.Parameterized
|
||||
|
||||
/**
|
||||
* Test Pip launch.
|
||||
* To run this test: `atest FlickerTests:PipToAppTest`
|
||||
* To run this test: `atest WMShellFlickerTests:PipToAppTest`
|
||||
*/
|
||||
@RequiresDevice
|
||||
@RunWith(Parameterized::class)
|
||||
@@ -75,7 +75,7 @@ class PipToAppTest(
|
||||
}
|
||||
eachRun {
|
||||
this.setRotation(configuration.startRotation)
|
||||
testApp.clickEnterPipButton(device)
|
||||
testApp.clickEnterPipButton()
|
||||
device.hasPipWindow()
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.wm.flicker.pip
|
||||
package com.android.wm.shell.flicker.pip
|
||||
|
||||
import android.view.Surface
|
||||
import androidx.test.filters.FlakyTest
|
||||
@@ -24,7 +24,6 @@ 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.PipAppHelper
|
||||
import com.android.server.wm.flicker.helpers.buildTestTag
|
||||
import com.android.server.wm.flicker.helpers.closePipWindow
|
||||
import com.android.server.wm.flicker.helpers.hasPipWindow
|
||||
@@ -39,6 +38,7 @@ 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
|
||||
@@ -46,7 +46,7 @@ import org.junit.runners.Parameterized
|
||||
|
||||
/**
|
||||
* Test Pip launch.
|
||||
* To run this test: `atest FlickerTests:PipToHomeTest`
|
||||
* To run this test: `atest WMShellFlickerTests:PipToHomeTest`
|
||||
*/
|
||||
@RequiresDevice
|
||||
@RunWith(Parameterized::class)
|
||||
@@ -74,7 +74,7 @@ class PipToHomeTest(
|
||||
eachRun {
|
||||
testApp.open()
|
||||
this.setRotation(configuration.startRotation)
|
||||
testApp.clickEnterPipButton(device)
|
||||
testApp.clickEnterPipButton()
|
||||
device.hasPipWindow()
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class PipToHomeTest(
|
||||
}
|
||||
}
|
||||
transitions {
|
||||
testApp.closePipWindow(device)
|
||||
testApp.closePipWindow()
|
||||
}
|
||||
assertions {
|
||||
windowManagerTrace {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.wm.flicker.splitscreen
|
||||
package com.android.wm.shell.flicker.splitscreen
|
||||
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import androidx.test.filters.FlakyTest
|
||||
@@ -48,7 +48,7 @@ import org.junit.runners.Parameterized
|
||||
|
||||
/**
|
||||
* Test open app to split screen.
|
||||
* To run this test: `atest FlickerTests:OpenAppToSplitScreenTest`
|
||||
* To run this test: `atest WMShellFlickerTests:OpenAppToSplitScreenTest`
|
||||
*/
|
||||
@Presubmit
|
||||
@RequiresDevice
|
||||
@@ -65,7 +65,7 @@ class OpenAppToSplitScreenTest(
|
||||
fun getParams(): Collection<Array<Any>> {
|
||||
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||
val testApp = StandardAppHelper(instrumentation,
|
||||
"com.android.server.wm.flicker.testapp", "SimpleApp")
|
||||
"com.android.wm.shell.flicker.testapp", "SimpleApp")
|
||||
|
||||
return FlickerTestRunnerFactory(instrumentation)
|
||||
.buildTest { configuration ->
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.wm.flicker.splitscreen
|
||||
package com.android.wm.shell.flicker.splitscreen
|
||||
|
||||
import android.graphics.Region
|
||||
import android.util.Rational
|
||||
@@ -29,8 +29,8 @@ 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.focusDoesNotChange
|
||||
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
|
||||
@@ -55,7 +55,7 @@ import org.junit.runners.Parameterized
|
||||
|
||||
/**
|
||||
* Test split screen resizing window transitions.
|
||||
* To run this test: `atest FlickerTests:ResizeSplitScreenTest`
|
||||
* To run this test: `atest WMShellFlickerTests:ResizeSplitScreenTest`
|
||||
*
|
||||
* Currently it runs only in 0 degrees because of b/156100803
|
||||
*/
|
||||
@@ -78,7 +78,7 @@ class ResizeSplitScreenTest(
|
||||
fun getParams(): Collection<Array<Any>> {
|
||||
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||
val testAppTop = StandardAppHelper(instrumentation,
|
||||
"com.android.server.wm.flicker.testapp", "SimpleApp")
|
||||
"com.android.wm.shell.flicker.testapp", "SimpleApp")
|
||||
val testAppBottom = ImeAppHelper(instrumentation)
|
||||
|
||||
return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0))
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.wm.flicker.splitscreen
|
||||
package com.android.wm.shell.flicker.splitscreen
|
||||
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import android.view.Surface
|
||||
@@ -48,7 +48,7 @@ import org.junit.runners.Parameterized
|
||||
|
||||
/**
|
||||
* Test open app to split screen.
|
||||
* To run this test: `atest FlickerTests:SplitScreenToLauncherTest`
|
||||
* To run this test: `atest WMShellFlickerTests:SplitScreenToLauncherTest`
|
||||
*/
|
||||
@Presubmit
|
||||
@RequiresDevice
|
||||
@@ -64,7 +64,7 @@ class SplitScreenToLauncherTest(
|
||||
fun getParams(): Collection<Array<Any>> {
|
||||
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||
val testApp = StandardAppHelper(instrumentation,
|
||||
"com.android.server.wm.flicker.testapp", "SimpleApp")
|
||||
"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))
|
||||
@@ -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>
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/holo_blue_bright">
|
||||
<Button android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/enter_pip"
|
||||
android:text="Enter PIP"/>
|
||||
android:background="@android:color/holo_orange_light">
|
||||
|
||||
</LinearLayout>
|
||||
@@ -14,17 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.wm.flicker.testapp;
|
||||
package com.android.wm.shell.flicker.testapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.PictureInPictureParams;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.util.Rational;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
|
||||
public class PipActivity extends Activity {
|
||||
public class SimpleActivity extends Activity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -32,14 +28,6 @@ public class PipActivity extends Activity {
|
||||
p.layoutInDisplayCutoutMode = WindowManager.LayoutParams
|
||||
.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
getWindow().setAttributes(p);
|
||||
setContentView(R.layout.activity_pip);
|
||||
Button enterPip = (Button) findViewById(R.id.enter_pip);
|
||||
|
||||
PictureInPictureParams params = new PictureInPictureParams.Builder()
|
||||
.setAspectRatio(new Rational(1, 1))
|
||||
.setSourceRectHint(new Rect(0, 0, 100, 100))
|
||||
.build();
|
||||
|
||||
enterPip.setOnClickListener((v) -> enterPictureInPictureMode(params));
|
||||
setContentView(R.layout.activity_simple);
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,10 @@ android_test {
|
||||
java_library {
|
||||
name: "wm-flicker-common-assertions",
|
||||
platform_apis: true,
|
||||
srcs: ["src/**/*Assertions.java", "src/**/*Assertions.kt"],
|
||||
srcs: [
|
||||
"src/**/*Assertions.java",
|
||||
"src/**/*Assertions.kt",
|
||||
],
|
||||
exclude_srcs: [
|
||||
"**/helpers/*",
|
||||
],
|
||||
@@ -68,4 +71,17 @@ java_library {
|
||||
"truth-prebuilt",
|
||||
"app-helpers-core"
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "wm-flicker-common-app-helpers",
|
||||
platform_apis: true,
|
||||
srcs: [
|
||||
"**/helpers/*"
|
||||
],
|
||||
static_libs: [
|
||||
"flickerlib",
|
||||
"truth-prebuilt",
|
||||
"app-helpers-core"
|
||||
],
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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.helpers
|
||||
|
||||
import android.app.Instrumentation
|
||||
import android.support.test.launcherhelper.ILauncherStrategy
|
||||
import android.support.test.launcherhelper.LauncherStrategyFactory
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.junit.Assert
|
||||
|
||||
class PipAppHelper(
|
||||
instr: Instrumentation,
|
||||
launcherStrategy: ILauncherStrategy = LauncherStrategyFactory
|
||||
.getInstance(instr)
|
||||
.launcherStrategy
|
||||
) : StandardAppHelper(instr, "PipApp", launcherStrategy) {
|
||||
fun clickEnterPipButton(device: UiDevice) {
|
||||
val enterPipButton = device.findObject(By.res(getPackage(), "enter_pip"))
|
||||
Assert.assertNotNull("Pip button not found, this usually happens when the device " +
|
||||
"was left in an unknown state (e.g. in split screen)", enterPipButton)
|
||||
enterPipButton.click()
|
||||
device.hasPipWindow()
|
||||
}
|
||||
|
||||
fun closePipWindow(device: UiDevice) {
|
||||
device.closePipWindow()
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* 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.pip
|
||||
|
||||
import android.platform.test.annotations.Presubmit
|
||||
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.helpers.PipAppHelper
|
||||
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 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 FlickerTests:PipToAppTest`
|
||||
*/
|
||||
@Presubmit
|
||||
@RequiresDevice
|
||||
@RunWith(Parameterized::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@FlakyTest(bugId = 152738416)
|
||||
class EnterPipTest(
|
||||
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("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)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,18 +49,6 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".PipActivity"
|
||||
android:resizeableActivity="true"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:taskAffinity="com.android.server.wm.flicker.testapp.PipActivity"
|
||||
android:label="PipApp"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".SeamlessRotationActivity"
|
||||
android:taskAffinity="com.android.server.wm.flicker.testapp.SeamlessRotationActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
|
||||
Reference in New Issue
Block a user