Use only requires device annotation to determine what should run on cf_arm

If any assertion doesn't run on arm we can annotate the assertion itself, instead of copying the class

Bug: 288341660
Test: atest FlickerTestsIme FlickerTestsAppClose FlickerTestsAppLaunch WMShellFlickerTestsPip
Change-Id: I9204535e3f4b4417700d7b49178f191f89a9e43d
This commit is contained in:
Nataniel Borges
2023-07-11 09:28:44 +00:00
parent 915b96c872
commit d3378e448f
6 changed files with 70 additions and 177 deletions

View File

@@ -18,7 +18,6 @@ package com.android.server.wm.flicker.activityembedding
import android.platform.test.annotations.Presubmit
import android.tools.common.datatypes.Rect
import android.tools.common.datatypes.Region
import android.tools.common.flicker.subject.region.RegionSubject
import android.tools.common.traces.component.ComponentNameMatcher
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
@@ -38,8 +37,8 @@ import org.junit.runners.Parameterized
*
* Setup: Launch Activity A in fullscreen.
*
* Transitions: From A launch a trampoline Activity T, T launches secondary Activity B and
* finishes itself, end up in split A|B.
* Transitions: From A launch a trampoline Activity T, T launches secondary Activity B and finishes
* itself, end up in split A|B.
*
* To run this test: `atest FlickerTests:OpenTrampolineActivityTest`
*/
@@ -53,12 +52,10 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
tapl.setExpectedRotationCheckEnabled(false)
testApp.launchViaIntent(wmHelper)
startDisplayBounds =
wmHelper.currentState.layerState.physicalDisplayBounds
?: error("Can't get display bounds")
}
transitions {
testApp.launchTrampolineActivity(wmHelper)
wmHelper.currentState.layerState.physicalDisplayBounds
?: error("Can't get display bounds")
}
transitions { testApp.launchTrampolineActivity(wmHelper) }
teardown {
tapl.goHome()
testApp.exit(wmHelper)
@@ -70,9 +67,7 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
@Test
fun backgroundLayerNeverVisible() {
val backgroundColorLayer = ComponentNameMatcher("", "Animation Background")
flicker.assertLayers {
isInvisible(backgroundColorLayer)
}
flicker.assertLayers { isInvisible(backgroundColorLayer) }
}
/** Trampoline activity should finish itself before the end of this test. */
@@ -96,9 +91,7 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
@Presubmit
@Test
fun mainActivityWindowAlwaysVisible() {
flicker.assertWm {
isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
}
flicker.assertWm { isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) }
}
// TODO(b/289140963): After this is fixed, assert the main Activity window is visible
@@ -107,12 +100,8 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
@Presubmit
@Test
fun mainActivityLayerAlwaysVisible() {
flicker.assertLayersStart {
isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
}
flicker.assertLayersEnd {
isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
}
flicker.assertLayersStart { isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) }
flicker.assertLayersEnd { isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) }
}
/** Secondary activity is launched from the trampoline activity. */
@@ -121,10 +110,10 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
fun secondaryActivityWindowLaunchedFromTrampoline() {
flicker.assertWm {
notContains(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
}
}
@@ -134,8 +123,8 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
fun secondaryActivityLayerLaunchedFromTrampoline() {
flicker.assertLayers {
isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
}
}
@@ -145,36 +134,38 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
fun mainActivityWindowGoesFromFullscreenToSplit() {
flicker.assertWm {
this.invoke("mainActivityStartsInFullscreen") {
it.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
it.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.coversExactly(startDisplayBounds)
}
// Begin of transition.
.then()
.isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.invoke("mainAndSecondaryInSplit") {
val mainActivityRegion =
RegionSubject(
it.visibleRegion(
ActivityEmbeddingAppHelper
.MAIN_ACTIVITY_COMPONENT).region,
it.timestamp)
val secondaryActivityRegion =
RegionSubject(
it.visibleRegion(
ActivityEmbeddingAppHelper
.SECONDARY_ACTIVITY_COMPONENT).region,
it.timestamp)
check { "height" }
.that(mainActivityRegion.region.height)
.isEqual(secondaryActivityRegion.region.height)
check { "width" }
.that(mainActivityRegion.region.width)
.isEqual(secondaryActivityRegion.region.width)
mainActivityRegion
.plus(secondaryActivityRegion.region)
.coversExactly(startDisplayBounds)
}
}
// Begin of transition.
.then()
.isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.invoke("mainAndSecondaryInSplit") {
val mainActivityRegion =
RegionSubject(
it.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.region,
it.timestamp
)
val secondaryActivityRegion =
RegionSubject(
it.visibleRegion(
ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT
)
.region,
it.timestamp
)
check { "height" }
.that(mainActivityRegion.region.height)
.isEqual(secondaryActivityRegion.region.height)
check { "width" }
.that(mainActivityRegion.region.width)
.isEqual(secondaryActivityRegion.region.width)
mainActivityRegion
.plus(secondaryActivityRegion.region)
.coversExactly(startDisplayBounds)
}
}
}
@@ -184,27 +175,26 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
fun mainActivityLayerGoesFromFullscreenToSplit() {
flicker.assertLayers {
this.invoke("mainActivityStartsInFullscreen") {
it.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
it.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.coversExactly(startDisplayBounds)
}
.then()
.isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
}
.then()
.isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
}
flicker.assertLayersEnd {
val leftLayerRegion = visibleRegion(
ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
val leftLayerRegion = visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
val rightLayerRegion =
visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
// Compare dimensions of two splits, given we're using default split attributes,
// both activities take up the same visible size on the display.
check { "height" }
.that(leftLayerRegion.region.height)
.isEqual(rightLayerRegion.region.height)
.that(leftLayerRegion.region.height)
.isEqual(rightLayerRegion.region.height)
check { "width" }
.that(leftLayerRegion.region.width)
.isEqual(rightLayerRegion.region.width)
.that(leftLayerRegion.region.width)
.isEqual(rightLayerRegion.region.width)
leftLayerRegion.notOverlaps(rightLayerRegion.region)
// Layers of two activities sum to be fullscreen size on display.
leftLayerRegion.plus(rightLayerRegion.region).coversExactly(startDisplayBounds)
@@ -225,4 +215,4 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
@JvmStatic
fun getParams() = LegacyFlickerTestFactory.nonRotationTests()
}
}
}

View File

@@ -82,17 +82,17 @@ constructor(
*/
fun launchTrampolineActivity(wmHelper: WindowManagerStateHelper) {
val launchButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "launch_trampoline_button")),
FIND_TIMEOUT
)
uiDevice.wait(
Until.findObject(By.res(getPackage(), "launch_trampoline_button")),
FIND_TIMEOUT
)
require(launchButton != null) { "Can't find launch trampoline activity button on screen." }
launchButton.click()
wmHelper
.StateSyncBuilder()
.withActivityState(SECONDARY_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED)
.withActivityRemoved(TRAMPOLINE_ACTIVITY_COMPONENT)
.waitForAndVerify()
.StateSyncBuilder()
.withActivityState(SECONDARY_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED)
.withActivityRemoved(TRAMPOLINE_ACTIVITY_COMPONENT)
.waitForAndVerify()
}
/**
@@ -217,7 +217,7 @@ constructor(
.toFlickerComponent()
val TRAMPOLINE_ACTIVITY_COMPONENT =
ActivityOptions.ActivityEmbedding.TrampolineActivity.COMPONENT.toFlickerComponent()
ActivityOptions.ActivityEmbedding.TrampolineActivity.COMPONENT.toFlickerComponent()
@JvmStatic
fun getWindowExtensions(): WindowExtensions? {

View File

@@ -23,7 +23,6 @@ import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import org.junit.FixMethodOrder
import org.junit.Test
@@ -81,11 +80,10 @@ import org.junit.runners.Parameterized
* apps are running before setup
* ```
*/
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class ChangeAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(flicker) {
class ChangeAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(flicker) {
override val testApp = SimpleAppHelper(instrumentation)
override val transition: FlickerBuilder.() -> Unit
get() = {

View File

@@ -1,42 +0,0 @@
/*
* Copyright (C) 2023 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.rotation
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ChangeAppRotationTestCfArm(flicker: LegacyFlickerTest) : ChangeAppRotationTest(flicker) {
companion object {
/**
* Creates the test configurations.
*
* See [LegacyFlickerTestFactory.rotationTests] for configuring screen orientation and
* navigation modes.
*/
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams() = LegacyFlickerTestFactory.rotationTests()
}
}

View File

@@ -26,7 +26,6 @@ import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import android.view.WindowManager
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.helpers.SeamlessRotationAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions
import org.junit.FixMethodOrder
@@ -88,11 +87,10 @@ import org.junit.runners.Parameterized
* apps are running before setup
* ```
*/
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class SeamlessAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(flicker) {
class SeamlessAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(flicker) {
override val testApp = SeamlessRotationAppHelper(instrumentation)
/** {@inheritDoc} */

View File

@@ -1,51 +0,0 @@
/*
* Copyright (C) 2023 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.rotation
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import com.android.server.wm.flicker.testapp.ActivityOptions
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/** This test should fail because of b/264518826 */
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class SeamlessAppRotationTestCfArm(flicker: LegacyFlickerTest) :
SeamlessAppRotationTest(flicker) {
companion object {
/**
* Creates the test configurations for seamless rotation based on the default rotation tests
* from [LegacyFlickerTestFactory.rotationTests], but adding a flag (
* [ActivityOptions.SeamlessRotation.EXTRA_STARVE_UI_THREAD]) to indicate if the app should
* starve the UI thread of not
*/
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams() =
LegacyFlickerTestFactory.rotationTests().flatMap { sourceCfg ->
val legacyCfg = sourceCfg as LegacyFlickerTest
val defaultRun = createConfig(legacyCfg, starveUiThread = false)
val busyUiRun = createConfig(legacyCfg, starveUiThread = true)
listOf(defaultRun, busyUiRun)
}
}
}