From a2eb00255d275ef351aa4edb35b50cfd034d7444 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Thu, 2 Jun 2022 17:05:24 +0000 Subject: [PATCH] Update OpenImeWindowFromFixedOrientationAppTest (2nd) To catch Bug 230733128 that the size of TaskSnapshotStartingWindow surface wrongly rendered by not applying fixed-rotation when the snapshot included IME, Add snapshotStartingWindowLayerCoversExactlyOnApp to verify the size of snapshotRegion should cover appVisibleRegion exactly in animation. Bug: 232242249 Test: atest FlickerTest:OpenImeWindowFromFixedOrientationAppTest Change-Id: I709d8899381126efff82a43a0d39d3342079f122 --- .../server/wm/flicker/CommonAssertions.kt | 28 +++++++++++++++++++ ...penImeWindowFromFixedOrientationAppTest.kt | 8 ++++++ 2 files changed, 36 insertions(+) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt index 7f309e1974e14..0e5a1775bd6a2 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt @@ -18,6 +18,7 @@ package com.android.server.wm.flicker import com.android.server.wm.flicker.helpers.WindowUtils +import com.android.server.wm.flicker.traces.region.RegionSubject import com.android.server.wm.traces.common.FlickerComponentName val LAUNCHER_COMPONENT = FlickerComponentName("com.google.android.apps.nexuslauncher", @@ -172,6 +173,33 @@ fun FlickerTestParameter.statusBarLayerRotatesScales() { statusBarLayerPositionEnd() } +/** + * Asserts that the visibleRegion of the [FlickerComponentName.SNAPSHOT] layer can cover + * the visibleRegion of the given app component exactly + */ +fun FlickerTestParameter.snapshotStartingWindowLayerCoversExactlyOnApp( + component: FlickerComponentName) { + assertLayers { + invoke("snapshotStartingWindowLayerCoversExactlyOnApp") { + val snapshotLayers = it.subjects.filter { subject -> + subject.name.contains( + FlickerComponentName.SNAPSHOT.toLayerName()) && subject.isVisible + } + // Verify the size of snapshotRegion covers appVisibleRegion exactly in animation. + if (snapshotLayers.isNotEmpty()) { + val visibleAreas = snapshotLayers.mapNotNull { snapshotLayer -> + snapshotLayer.layer?.visibleRegion + }.toTypedArray() + val snapshotRegion = RegionSubject.assertThat(visibleAreas, this, timestamp) + val appVisibleRegion = it.visibleRegion(component) + if (snapshotRegion.region.isNotEmpty) { + snapshotRegion.coversExactly(appVisibleRegion.region) + } + } + } + } +} + /** * Asserts that: * [originalLayer] is visible at the start of the trace diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowFromFixedOrientationAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowFromFixedOrientationAppTest.kt index 933a3a0458ee8..88fb1a2209105 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowFromFixedOrientationAppTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowFromFixedOrientationAppTest.kt @@ -17,6 +17,7 @@ package com.android.server.wm.flicker.ime import android.app.Instrumentation +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.platform.test.annotations.RequiresDevice import android.view.Surface @@ -34,6 +35,7 @@ import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.navBarLayerPositionEnd import com.android.server.wm.flicker.navBarWindowIsVisible +import com.android.server.wm.flicker.snapshotStartingWindowLayerCoversExactlyOnApp import com.android.server.wm.flicker.statusBarLayerRotatesScales import com.android.server.wm.flicker.statusBarWindowIsVisible import org.junit.FixMethodOrder @@ -107,6 +109,12 @@ class OpenImeWindowFromFixedOrientationAppTest(private val testSpec: FlickerTest @Test fun imeLayerBecomesVisible() = testSpec.imeLayerBecomesVisible() + @Postsubmit + @Test + fun snapshotStartingWindowLayerCoversExactlyOnApp() { + testSpec.snapshotStartingWindowLayerCoversExactlyOnApp(imeTestApp.component) + } + companion object { /** * Creates the test configurations.