From 6dbb226dad9c3cbdef0fb933850fa83594a28174 Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Mon, 7 Jun 2021 10:45:46 +0200 Subject: [PATCH] Fix status bar assertions on seamless rotation Status bar should not be visible because the app layer in seamless rotation is in full screen. Also, add checks to ensure: app window is always full screen and app window is always set to seamless Also: refactor rotation test assertions: - base class, all assertions in presubmit - child classes, override if need flaky or postsubmit Bug: 186115871 Bug: 190350376 Test: atest FlickerTests:com.android.server.wm.flicker.rotation Change-Id: I31f9c41ad6a8c0048a8f8a353c7e468afda1fc8e --- .../flicker/rotation/ChangeAppRotationTest.kt | 38 +++++++++-- .../wm/flicker/rotation/RotationTransition.kt | 29 +-------- .../rotation/SeamlessAppRotationTest.kt | 65 +++++++++++++++++-- 3 files changed, 96 insertions(+), 36 deletions(-) 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 69e8a8d08e58e..25a94e3ba7966 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 @@ -25,7 +25,12 @@ import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group3 import com.android.server.wm.flicker.dsl.FlickerBuilder +import com.android.server.wm.flicker.endRotation import com.android.server.wm.flicker.helpers.SimpleAppHelper +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.Test import org.junit.runner.RunWith @@ -73,10 +78,23 @@ class ChangeAppRotationTest( } } + @Presubmit + @Test + fun statusBarWindowIsAlwaysVisible() { + testSpec.statusBarWindowIsAlwaysVisible() + } + + @FlakyTest + @Test + fun statusBarLayerIsAlwaysVisible() { + testSpec.statusBarLayerIsAlwaysVisible(rotatesScreen = true) + } + @Postsubmit @Test - override fun statusBarLayerRotatesScales() { - super.statusBarLayerRotatesScales() + fun statusBarLayerRotatesScales() { + testSpec.statusBarLayerRotatesScales( + testSpec.config.startRotation, testSpec.config.endRotation) } @Presubmit @@ -87,8 +105,20 @@ class ChangeAppRotationTest( @FlakyTest @Test - override fun statusBarLayerIsAlwaysVisible() { - super.statusBarLayerIsAlwaysVisible() + override fun navBarLayerIsAlwaysVisible() { + super.navBarLayerIsAlwaysVisible() + } + + @FlakyTest + @Test + override fun navBarLayerRotatesAndScales() { + super.navBarLayerRotatesAndScales() + } + + @FlakyTest + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() { + super.visibleLayersShownMoreThanOneConsecutiveEntry() } companion object { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt index 4b888cd5aad0b..1739d03b0f4cb 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt @@ -18,7 +18,6 @@ package com.android.server.wm.flicker.rotation import android.app.Instrumentation import android.platform.test.annotations.Presubmit -import androidx.test.filters.FlakyTest import androidx.test.platform.app.InstrumentationRegistry import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerTestParameter @@ -33,9 +32,6 @@ 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.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.server.wm.traces.parser.windowmanager.WindowManagerStateHelper import org.junit.Test @@ -69,19 +65,19 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter) } } - @FlakyTest + @Presubmit @Test open fun navBarWindowIsAlwaysVisible() { testSpec.navBarWindowIsAlwaysVisible() } - @FlakyTest + @Presubmit @Test open fun navBarLayerIsAlwaysVisible() { testSpec.navBarLayerIsAlwaysVisible(rotatesScreen = true) } - @FlakyTest + @Presubmit @Test open fun navBarLayerRotatesAndScales() { testSpec.navBarLayerRotatesAndScales( @@ -90,25 +86,6 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter) @Presubmit @Test - open fun statusBarWindowIsAlwaysVisible() { - testSpec.statusBarWindowIsAlwaysVisible() - } - - @FlakyTest - @Test - open fun statusBarLayerIsAlwaysVisible() { - testSpec.statusBarLayerIsAlwaysVisible(rotatesScreen = true) - } - - @FlakyTest - @Test - open fun statusBarLayerRotatesScales() { - testSpec.statusBarLayerRotatesScales( - testSpec.config.startRotation, testSpec.config.endRotation) - } - - @FlakyTest - @Test open fun visibleLayersShownMoreThanOneConsecutiveEntry() { testSpec.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry( diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt index b153bece1133d..9d788a7637318 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt @@ -18,6 +18,7 @@ package com.android.server.wm.flicker.rotation import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit +import android.view.WindowManager import androidx.test.filters.FlakyTest import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.FlickerParametersRunnerFactory @@ -27,6 +28,7 @@ import com.android.server.wm.flicker.annotation.Group3 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.SeamlessRotationAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions +import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -60,16 +62,33 @@ class SeamlessAppRotationTest( } } - @FlakyTest(bugId = 140855415) + @Postsubmit @Test - override fun statusBarWindowIsAlwaysVisible() { - super.statusBarWindowIsAlwaysVisible() + fun appWindowFullScreen() { + testSpec.assertWm { + this.invoke("isFullScreen") { + val appWindow = it.windowState(testApp.`package`) + val flags = appWindow.windowState?.attributes?.flags ?: 0 + appWindow.verify("isFullScreen") + .that(flags.and(WindowManager.LayoutParams.FLAG_FULLSCREEN)) + .isGreaterThan(0) + } + } } - @FlakyTest(bugId = 140855415) + @Postsubmit @Test - override fun statusBarLayerIsAlwaysVisible() { - super.statusBarLayerIsAlwaysVisible() + fun appWindowSeamlessRotation() { + testSpec.assertWm { + this.invoke("isRotationSeamless") { + val appWindow = it.windowState(testApp.`package`) + val rotationAnimation = appWindow.windowState?.attributes?.rotationAnimation ?: 0 + appWindow.verify("isRotationSeamless") + .that(rotationAnimation + .and(WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS)) + .isGreaterThan(0) + } + } } @Presubmit @@ -90,12 +109,46 @@ class SeamlessAppRotationTest( } } + @Presubmit + @Test + fun statusBarWindowIsAlwaysInvisible() { + testSpec.assertWm { + this.hidesAboveAppWindow(WindowManagerStateHelper.STATUS_BAR_WINDOW_NAME) + } + } + + @Presubmit + @Test + fun statusBarLayerIsAlwaysInvisible() { + testSpec.assertLayers { + this.isInvisible(WindowManagerStateHelper.STATUS_BAR_LAYER_NAME) + } + } + @Postsubmit @Test override fun visibleLayersShownMoreThanOneConsecutiveEntry() { super.visibleLayersShownMoreThanOneConsecutiveEntry() } + @FlakyTest + @Test + override fun navBarWindowIsAlwaysVisible() { + super.navBarWindowIsAlwaysVisible() + } + + @FlakyTest + @Test + override fun navBarLayerIsAlwaysVisible() { + super.navBarLayerIsAlwaysVisible() + } + + @FlakyTest + @Test + override fun navBarLayerRotatesAndScales() { + super.navBarLayerRotatesAndScales() + } + companion object { private val testFactory = FlickerTestParameterFactory.getInstance()