diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.kt index eaf4d87992089..abe7dbc57002c 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.kt @@ -92,7 +92,7 @@ abstract class FlickerTestBase { app2: IAppHelper?, extraInfo: String ): String { - var testTag = "${testName}__$${app.launcherName}" + var testTag = "${testName}__${app.launcherName}" if (app2 != null) { testTag += "-${app2.launcherName}" } 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 31d1fd313374a..2e4d390ceb60a 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 @@ -81,11 +81,11 @@ class CloseImeAutoOpenWindowToHomeTest( } layersTrace { - navBarLayerIsAlwaysVisible() - statusBarLayerIsAlwaysVisible() - noUncoveredRegions(rotation) - navBarLayerRotatesAndScales(rotation) - statusBarLayerRotatesScales(rotation) + navBarLayerIsAlwaysVisible(bugId = 140855415) + statusBarLayerIsAlwaysVisible(bugId = 140855415) + noUncoveredRegions(rotation, Surface.ROTATION_0, allStates = false) + navBarLayerRotatesAndScales(rotation, Surface.ROTATION_0) + statusBarLayerRotatesScales(rotation, Surface.ROTATION_0) imeLayerBecomesInvisible(bugId = 141458352) imeAppLayerBecomesInvisible(testApp, bugId = 153739621) } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToHomeTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToHomeTest.kt index b643ec2ba3326..1c0da4f920bb6 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToHomeTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToHomeTest.kt @@ -89,9 +89,9 @@ open class CloseImeWindowToHomeTest( } layersTrace { - navBarLayerIsAlwaysVisible() - statusBarLayerIsAlwaysVisible() - noUncoveredRegions(rotation) + navBarLayerIsAlwaysVisible(bugId = 140855415) + statusBarLayerIsAlwaysVisible(bugId = 140855415) + noUncoveredRegions(rotation, Surface.ROTATION_0, allStates = false) navBarLayerRotatesAndScales(rotation, Surface.ROTATION_0) statusBarLayerRotatesScales(rotation, Surface.ROTATION_0) imeLayerBecomesInvisible(bugId = 153739621) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt index af751dc71f6c7..62337e9bff346 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt @@ -71,18 +71,18 @@ class OpenAppColdTest( windowManagerTrace { navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() - appWindowReplacesLauncherAsTopWindow(bugId = 141361128) + appWindowReplacesLauncherAsTopWindow() wallpaperWindowBecomesInvisible() } layersTrace { - noUncoveredRegions(rotation, bugId = 141361128) // During testing the launcher is always in portrait mode + noUncoveredRegions(Surface.ROTATION_0, rotation, bugId = 141361128) navBarLayerRotatesAndScales(Surface.ROTATION_0, rotation) statusBarLayerRotatesScales(Surface.ROTATION_0, rotation) - navBarLayerIsAlwaysVisible(bugId = 141361128) - statusBarLayerIsAlwaysVisible(bugId = 141361128) - wallpaperLayerBecomesInvisible(bugId = 141361128) + navBarLayerIsAlwaysVisible() + statusBarLayerIsAlwaysVisible(enabled = false) + wallpaperLayerBecomesInvisible() } eventLog { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTestBase.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTestBase.kt index 3cec077f01841..7d70812a22f2d 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTestBase.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTestBase.kt @@ -44,10 +44,9 @@ abstract class OpenAppTestBase( enabled: Boolean = bugId == 0 ) { all("appWindowReplacesLauncherAsTopWindow", enabled, bugId) { - this.showsAppWindowOnTop( - "Launcher") + this.showsAppWindowOnTop("Launcher") .then() - .showsAppWindowOnTop(testApp.getPackage()) + .showsAppWindowOnTop("Snapshot", testApp.getPackage()) } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt index d3595747d3eee..9a8e37b19e561 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt @@ -79,18 +79,18 @@ class OpenAppWarmTest( windowManagerTrace { navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() - appWindowReplacesLauncherAsTopWindow(bugId = 141361128) + appWindowReplacesLauncherAsTopWindow() wallpaperWindowBecomesInvisible(enabled = false) } layersTrace { - noUncoveredRegions(rotation, bugId = 141361128) // During testing the launcher is always in portrait mode + noUncoveredRegions(Surface.ROTATION_0, rotation, bugId = 141361128) navBarLayerRotatesAndScales(Surface.ROTATION_0, rotation) statusBarLayerRotatesScales(Surface.ROTATION_0, rotation) - navBarLayerIsAlwaysVisible(bugId = 141361128) - statusBarLayerIsAlwaysVisible(bugId = 141361128) - wallpaperLayerBecomesInvisible(bugId = 141361128) + navBarLayerIsAlwaysVisible() + statusBarLayerIsAlwaysVisible(enabled = false) + wallpaperLayerBecomesInvisible() } eventLog { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/pip/EnterPipTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/pip/EnterPipTest.kt new file mode 100644 index 0000000000000..4acd97553bc0b --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/pip/EnterPipTest.kt @@ -0,0 +1,121 @@ +/* + * 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.view.Surface +import androidx.test.filters.FlakyTest +import androidx.test.filters.LargeTest +import com.android.server.wm.flicker.dsl.flicker +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.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.statusBarLayerIsAlwaysVisible +import com.android.server.wm.flicker.statusBarLayerRotatesScales +import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible +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 FlickerTests:PipToAppTest` + */ +@LargeTest +@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) + device.expandPipWindow() + } + assertions { + windowManagerTrace { + navBarWindowIsAlwaysVisible() + statusBarWindowIsAlwaysVisible() + all("pipWindowBecomesVisible") { + this.showsAppWindow(testApp.`package`) + .then() + .showsAppWindow(sPipWindowTitle) + } + } + + 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(sPipWindowTitle) + } + } + } + } + } + + companion object { + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection> { + val supportedRotations = intArrayOf(Surface.ROTATION_0) + return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) } + } + } +} \ No newline at end of file diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipTestBase.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipTestBase.kt index 4afabd4cdfb1b..691db7fbac5c0 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipTestBase.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipTestBase.kt @@ -16,9 +16,7 @@ package com.android.server.wm.flicker.pip -import com.android.server.wm.flicker.dsl.LayersAssertion import com.android.server.wm.flicker.NonRotationTestBase -import com.android.server.wm.flicker.dsl.WmAssertion import com.android.server.wm.flicker.helpers.PipAppHelper abstract class PipTestBase( @@ -27,24 +25,6 @@ abstract class PipTestBase( ) : NonRotationTestBase(rotationName, rotation) { protected val testApp = PipAppHelper(instrumentation) - protected fun WmAssertion.pipWindowBecomesVisible() { - all("pipWindowBecomesVisible") { - this.skipUntilFirstAssertion() - .showsAppWindowOnTop(sPipWindowTitle) - .then() - .hidesAppWindow(sPipWindowTitle) - } - } - - protected fun LayersAssertion.pipLayerBecomesVisible() { - all("pipLayerBecomesVisible") { - this.skipUntilFirstAssertion() - .showsLayer(sPipWindowTitle) - .then() - .hidesLayer(sPipWindowTitle) - } - } - companion object { const val sPipWindowTitle = "PipMenuActivity" } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipToAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipToAppTest.kt index c8a0e7dc9557e..04c2f59118bde 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipToAppTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipToAppTest.kt @@ -56,35 +56,42 @@ class PipToAppTest( withTag { buildTestTag("exitPipModeToApp", testApp, rotation) } repeat { 1 } setup { - eachRun { + test { device.wakeUpAndGoToHomeScreen() + device.pressHome() + testApp.open() + } + eachRun { + this.setRotation(rotation) + testApp.clickEnterPipButton(device) + device.hasPipWindow() } } teardown { eachRun { - testApp.exit() this.setRotation(Surface.ROTATION_0) } test { if (device.hasPipWindow()) { device.closePipWindow() } + testApp.exit() } } transitions { - device.pressHome() - this.setRotation(rotation) - testApp.open() - testApp.clickEnterPipButton(device) device.expandPipWindow() device.waitForIdle() - testApp.exit() } assertions { windowManagerTrace { navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() - pipWindowBecomesVisible() + + all("appReplacesPipWindow") { + this.showsAppWindow(sPipWindowTitle) + .then() + .showsAppWindowOnTop(testApp.launcherName) + } } layersTrace { @@ -93,7 +100,12 @@ class PipToAppTest( noUncoveredRegions(rotation) navBarLayerRotatesAndScales(rotation) statusBarLayerRotatesScales(rotation) - pipLayerBecomesVisible() + + all("appReplacesPipLayer") { + this.showsLayer(sPipWindowTitle) + .then() + .showsLayer(testApp.launcherName) + } } eventLog { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipToHomeTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipToHomeTest.kt index 7e9880c6caa8d..b6074cd7033b4 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipToHomeTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/pip/PipToHomeTest.kt @@ -55,52 +55,59 @@ class PipToHomeTest( withTag { buildTestTag("exitPipModeToApp", testApp, rotation) } repeat { 1 } setup { - eachRun { + test { device.wakeUpAndGoToHomeScreen() device.pressHome() - this.setRotation(rotation) + } + eachRun { testApp.open() + this.setRotation(rotation) + testApp.clickEnterPipButton(device) + device.hasPipWindow() } } teardown { eachRun { - testApp.exit() this.setRotation(Surface.ROTATION_0) + if (device.hasPipWindow()) { + device.closePipWindow() + } } test { if (device.hasPipWindow()) { device.closePipWindow() } + testApp.exit() } } transitions { - testApp.clickEnterPipButton(device) testApp.closePipWindow(device) - device.waitForIdle() - testApp.exit() } assertions { windowManagerTrace { navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() - pipWindowBecomesVisible() - all { - this.showsAppWindowOnTop(sPipWindowTitle) - .and() - .showsBelowAppWindow("Wallpaper") + all("pipWindowBecomesInvisible") { + this.showsAppWindow(sPipWindowTitle) .then() - .showsAboveAppWindow("Wallpaper") + .hidesAppWindow(sPipWindowTitle) } } layersTrace { navBarLayerIsAlwaysVisible() statusBarLayerIsAlwaysVisible() - noUncoveredRegions(rotation) + // The final state is the launcher, so always in portrait mode + noUncoveredRegions(rotation, Surface.ROTATION_0, allStates = false) navBarLayerRotatesAndScales(rotation) statusBarLayerRotatesScales(rotation) - pipLayerBecomesVisible() + + all("pipLayerBecomesInvisible") { + this.showsLayer(sPipWindowTitle) + .then() + .hidesLayer(sPipWindowTitle) + } } eventLog { @@ -109,4 +116,13 @@ class PipToHomeTest( } } } + + companion object { + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection> { + val supportedRotations = intArrayOf(Surface.ROTATION_0) + return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) } + } + } } \ No newline at end of file diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt index a7aae8c51d8fc..5e75e4a144bf2 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt @@ -62,25 +62,29 @@ class ChangeAppRotationTest( } repeat { 1 } setup { - eachRun { + test { device.wakeUpAndGoToHomeScreen() testApp.open() + } + eachRun { this.setRotation(beginRotation) } } teardown { eachRun { - testApp.exit() this.setRotation(Surface.ROTATION_0) } + test { + testApp.exit() + } } transitions { this.setRotation(endRotation) } assertions { windowManagerTrace { - navBarWindowIsAlwaysVisible(bugId = 140855415) - statusBarWindowIsAlwaysVisible(bugId = 140855415) + navBarWindowIsAlwaysVisible() + statusBarWindowIsAlwaysVisible() } layersTrace { @@ -103,21 +107,12 @@ class ChangeAppRotationTest( this.hasVisibleRegion(testApp.getPackage(), endingPos) } - all("screenshotLayerBecomesInvisible", enabled = false) { + all("screenshotLayerBecomesInvisible") { this.showsLayer(testApp.getPackage()) .then() - .replaceVisibleLayer( - testApp.getPackage(), - SCREENSHOT_LAYER) - .then() - .showsLayer(testApp.getPackage()) - .and() .showsLayer(SCREENSHOT_LAYER) .then() - .replaceVisibleLayer( - SCREENSHOT_LAYER, - testApp.getPackage() - ) + showsLayer(testApp.getPackage()) } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/splitscreen/OpenAppToSplitScreenTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/splitscreen/OpenAppToSplitScreenTest.kt index a4ec3b17e63e4..e078f266e5ed0 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/splitscreen/OpenAppToSplitScreenTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/splitscreen/OpenAppToSplitScreenTest.kt @@ -16,7 +16,6 @@ package com.android.server.wm.flicker.splitscreen -import android.os.SystemClock import android.view.Surface import androidx.test.filters.LargeTest import com.android.server.wm.flicker.NonRotationTestBase @@ -24,6 +23,7 @@ import com.android.server.wm.flicker.StandardAppHelper import com.android.server.wm.flicker.dsl.flicker import com.android.server.wm.flicker.focusChanges 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.wakeUpAndGoToHomeScreen import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible @@ -59,16 +59,21 @@ class OpenAppToSplitScreenTest( withTag { buildTestTag("appToSplitScreen", testApp, rotation) } repeat { 1 } setup { - eachRun { + test { device.wakeUpAndGoToHomeScreen() - this.setRotation(rotation) + } + eachRun { testApp.open() - SystemClock.sleep(500) + this.setRotation(rotation) } } teardown { eachRun { - device.exitSplitScreen() + if (device.isInSplitScreen()) { + device.exitSplitScreen() + } + } + test { testApp.exit() } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/splitscreen/SplitScreenToLauncherTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/splitscreen/SplitScreenToLauncherTest.kt index 3ae3967add436..e2d78399b35ba 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/splitscreen/SplitScreenToLauncherTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/splitscreen/SplitScreenToLauncherTest.kt @@ -17,9 +17,8 @@ package com.android.server.wm.flicker.splitscreen import android.view.Surface -import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import com.android.server.wm.flicker.FlickerTestBase +import com.android.server.wm.flicker.NonRotationTestBase import com.android.server.wm.flicker.StandardAppHelper import com.android.server.wm.flicker.dsl.flicker import com.android.server.wm.flicker.focusDoesNotChange @@ -38,16 +37,19 @@ import org.junit.FixMethodOrder import org.junit.Test 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 FlickerTests:SplitScreenToLauncherTest` */ @LargeTest -@RunWith(AndroidJUnit4::class) +@RunWith(Parameterized::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class SplitScreenToLauncherTest : FlickerTestBase() { - private val rotation: Int = Surface.ROTATION_0 +class SplitScreenToLauncherTest( + rotationName: String, + rotation: Int +) : NonRotationTestBase(rotationName, rotation) { @Test fun test() { val testApp = StandardAppHelper(instrumentation, @@ -57,8 +59,10 @@ class SplitScreenToLauncherTest : FlickerTestBase() { withTag { buildTestTag("splitScreenToLauncher", testApp, rotation) } repeat { 1 } setup { - eachRun { + test { device.wakeUpAndGoToHomeScreen() + } + eachRun { testApp.open() this.setRotation(rotation) device.launchSplitScreen() @@ -111,4 +115,14 @@ class SplitScreenToLauncherTest : FlickerTestBase() { } } } + + companion object { + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection> { + // b/161435597 causes the test not to work on 90 degrees + val supportedRotations = intArrayOf(Surface.ROTATION_0) + return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) } + } + } }