Loading libs/WindowManager/Shell/tests/flicker/AndroidTest.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,8 @@ <option name="run-command" value="locksettings set-disabled false" /> <option name="run-command" value="locksettings set-disabled false" /> <!-- restart launcher to activate TAPL --> <!-- restart launcher to activate TAPL --> <option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" /> <option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" /> <!-- Ensure output directory is empty at the start --> <option name="run-command" value="rm -rf /sdcard/flicker" /> </target_preparer> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <option name="cleanup-apks" value="true"/> <option name="cleanup-apks" value="true"/> Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt +22 −23 Original line number Original line Diff line number Diff line Loading @@ -20,10 +20,10 @@ import android.app.Instrumentation import android.platform.test.annotations.Presubmit import android.platform.test.annotations.Presubmit import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry import com.android.launcher3.tapl.LauncherInstrumentation import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerBuilder import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTest import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.junit.FlickerBuilderProvider import com.android.server.wm.flicker.navBarLayerIsVisibleAtStartAndEnd import com.android.server.wm.flicker.navBarLayerIsVisibleAtStartAndEnd import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible Loading @@ -45,12 +45,12 @@ import org.junit.Test abstract class BaseTest abstract class BaseTest @JvmOverloads @JvmOverloads constructor( constructor( protected val testSpec: FlickerTestParameter, protected val flicker: FlickerTest, protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), protected val tapl: LauncherInstrumentation = LauncherInstrumentation() protected val tapl: LauncherInstrumentation = LauncherInstrumentation() ) { ) { init { init { testSpec.setIsTablet( flicker.scenario.setIsTablet( WindowManagerStateHelper(instrumentation, clearCacheAfterParsing = false) WindowManagerStateHelper(instrumentation, clearCacheAfterParsing = false) .currentState .currentState .wmState .wmState Loading @@ -68,13 +68,13 @@ constructor( @FlickerBuilderProvider @FlickerBuilderProvider fun buildFlicker(): FlickerBuilder { fun buildFlicker(): FlickerBuilder { return FlickerBuilder(instrumentation).apply { return FlickerBuilder(instrumentation).apply { setup { testSpec.setIsTablet(wmHelper.currentState.wmState.isTablet) } setup { flicker.scenario.setIsTablet(wmHelper.currentState.wmState.isTablet) } transition() transition() } } } } /** Checks that all parts of the screen are covered during the transition */ /** Checks that all parts of the screen are covered during the transition */ @Presubmit @Test open fun entireScreenCovered() = testSpec.entireScreenCovered() @Presubmit @Test open fun entireScreenCovered() = flicker.entireScreenCovered() /** /** * Checks that the [ComponentNameMatcher.NAV_BAR] layer is visible during the whole transition * Checks that the [ComponentNameMatcher.NAV_BAR] layer is visible during the whole transition Loading @@ -82,8 +82,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun navBarLayerIsVisibleAtStartAndEnd() { open fun navBarLayerIsVisibleAtStartAndEnd() { Assume.assumeFalse(testSpec.isTablet) Assume.assumeFalse(flicker.scenario.isTablet) testSpec.navBarLayerIsVisibleAtStartAndEnd() flicker.navBarLayerIsVisibleAtStartAndEnd() } } /** /** Loading @@ -93,8 +93,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun navBarLayerPositionAtStartAndEnd() { open fun navBarLayerPositionAtStartAndEnd() { Assume.assumeFalse(testSpec.isTablet) Assume.assumeFalse(flicker.scenario.isTablet) testSpec.navBarLayerPositionAtStartAndEnd() flicker.navBarLayerPositionAtStartAndEnd() } } /** /** Loading @@ -105,8 +105,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun navBarWindowIsAlwaysVisible() { open fun navBarWindowIsAlwaysVisible() { Assume.assumeFalse(testSpec.isTablet) Assume.assumeFalse(flicker.scenario.isTablet) testSpec.navBarWindowIsAlwaysVisible() flicker.navBarWindowIsAlwaysVisible() } } /** /** Loading @@ -115,8 +115,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun taskBarLayerIsVisibleAtStartAndEnd() { open fun taskBarLayerIsVisibleAtStartAndEnd() { Assume.assumeTrue(testSpec.isTablet) Assume.assumeTrue(flicker.scenario.isTablet) testSpec.taskBarLayerIsVisibleAtStartAndEnd() flicker.taskBarLayerIsVisibleAtStartAndEnd() } } /** /** Loading @@ -127,8 +127,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun taskBarWindowIsAlwaysVisible() { open fun taskBarWindowIsAlwaysVisible() { Assume.assumeTrue(testSpec.isTablet) Assume.assumeTrue(flicker.scenario.isTablet) testSpec.taskBarWindowIsAlwaysVisible() flicker.taskBarWindowIsAlwaysVisible() } } /** /** Loading @@ -137,8 +137,7 @@ constructor( */ */ @Presubmit @Presubmit @Test @Test open fun statusBarLayerIsVisibleAtStartAndEnd() = open fun statusBarLayerIsVisibleAtStartAndEnd() = flicker.statusBarLayerIsVisibleAtStartAndEnd() testSpec.statusBarLayerIsVisibleAtStartAndEnd() /** /** * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the Loading @@ -146,7 +145,7 @@ constructor( */ */ @Presubmit @Presubmit @Test @Test open fun statusBarLayerPositionAtStartAndEnd() = testSpec.statusBarLayerPositionAtStartAndEnd() open fun statusBarLayerPositionAtStartAndEnd() = flicker.statusBarLayerPositionAtStartAndEnd() /** /** * Checks that the [ComponentNameMatcher.STATUS_BAR] window is visible during the whole * Checks that the [ComponentNameMatcher.STATUS_BAR] window is visible during the whole Loading @@ -154,7 +153,7 @@ constructor( */ */ @Presubmit @Presubmit @Test @Test open fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsAlwaysVisible() open fun statusBarWindowIsAlwaysVisible() = flicker.statusBarWindowIsAlwaysVisible() /** /** * Checks that all layers that are visible on the trace, are visible for at least 2 consecutive * Checks that all layers that are visible on the trace, are visible for at least 2 consecutive Loading @@ -163,7 +162,7 @@ constructor( @Presubmit @Presubmit @Test @Test open fun visibleLayersShownMoreThanOneConsecutiveEntry() { open fun visibleLayersShownMoreThanOneConsecutiveEntry() { testSpec.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() } flicker.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() } } } /** /** Loading @@ -173,6 +172,6 @@ constructor( @Presubmit @Presubmit @Test @Test open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { testSpec.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry() } flicker.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry() } } } } } libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt +72 −62 Original line number Original line Diff line number Diff line Loading @@ -18,23 +18,23 @@ package com.android.wm.shell.flicker package com.android.wm.shell.flicker import android.view.Surface import com.android.server.wm.flicker.FlickerTest import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.traces.layers.LayerTraceEntrySubject import com.android.server.wm.flicker.traces.layers.LayerTraceEntrySubject import com.android.server.wm.flicker.traces.layers.LayersTraceSubject import com.android.server.wm.flicker.traces.layers.LayersTraceSubject import com.android.server.wm.traces.common.IComponentMatcher import com.android.server.wm.traces.common.IComponentMatcher import com.android.server.wm.traces.common.region.Region import com.android.server.wm.traces.common.region.Region import com.android.server.wm.traces.common.service.PlatformConsts fun FlickerTestParameter.appPairsDividerIsVisibleAtEnd() { fun FlickerTest.appPairsDividerIsVisibleAtEnd() { assertLayersEnd { this.isVisible(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } assertLayersEnd { this.isVisible(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.appPairsDividerIsInvisibleAtEnd() { fun FlickerTest.appPairsDividerIsInvisibleAtEnd() { assertLayersEnd { this.notContains(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } assertLayersEnd { this.notContains(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.appPairsDividerBecomesVisible() { fun FlickerTest.appPairsDividerBecomesVisible() { assertLayers { assertLayers { this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT) this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT) .then() .then() Loading @@ -42,7 +42,7 @@ fun FlickerTestParameter.appPairsDividerBecomesVisible() { } } } } fun FlickerTestParameter.splitScreenEntered( fun FlickerTest.splitScreenEntered( component1: IComponentMatcher, component1: IComponentMatcher, component2: IComponentMatcher, component2: IComponentMatcher, fromOtherApp: Boolean, fromOtherApp: Boolean, Loading @@ -69,7 +69,7 @@ fun FlickerTestParameter.splitScreenEntered( splitScreenDividerIsVisibleAtEnd() splitScreenDividerIsVisibleAtEnd() } } fun FlickerTestParameter.splitScreenDismissed( fun FlickerTest.splitScreenDismissed( component1: IComponentMatcher, component1: IComponentMatcher, component2: IComponentMatcher, component2: IComponentMatcher, toHome: Boolean toHome: Boolean Loading @@ -87,27 +87,27 @@ fun FlickerTestParameter.splitScreenDismissed( splitScreenDividerIsInvisibleAtEnd() splitScreenDividerIsInvisibleAtEnd() } } fun FlickerTestParameter.splitScreenDividerIsVisibleAtStart() { fun FlickerTest.splitScreenDividerIsVisibleAtStart() { assertLayersStart { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } assertLayersStart { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.splitScreenDividerIsVisibleAtEnd() { fun FlickerTest.splitScreenDividerIsVisibleAtEnd() { assertLayersEnd { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } assertLayersEnd { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.splitScreenDividerIsInvisibleAtStart() { fun FlickerTest.splitScreenDividerIsInvisibleAtStart() { assertLayersStart { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } assertLayersStart { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.splitScreenDividerIsInvisibleAtEnd() { fun FlickerTest.splitScreenDividerIsInvisibleAtEnd() { assertLayersEnd { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } assertLayersEnd { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.splitScreenDividerBecomesVisible() { fun FlickerTest.splitScreenDividerBecomesVisible() { layerBecomesVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) layerBecomesVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } fun FlickerTestParameter.splitScreenDividerBecomesInvisible() { fun FlickerTest.splitScreenDividerBecomesInvisible() { assertLayers { assertLayers { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) .then() .then() Loading @@ -115,23 +115,23 @@ fun FlickerTestParameter.splitScreenDividerBecomesInvisible() { } } } } fun FlickerTestParameter.layerBecomesVisible(component: IComponentMatcher) { fun FlickerTest.layerBecomesVisible(component: IComponentMatcher) { assertLayers { this.isInvisible(component).then().isVisible(component) } assertLayers { this.isInvisible(component).then().isVisible(component) } } } fun FlickerTestParameter.layerBecomesInvisible(component: IComponentMatcher) { fun FlickerTest.layerBecomesInvisible(component: IComponentMatcher) { assertLayers { this.isVisible(component).then().isInvisible(component) } assertLayers { this.isVisible(component).then().isInvisible(component) } } } fun FlickerTestParameter.layerIsVisibleAtEnd(component: IComponentMatcher) { fun FlickerTest.layerIsVisibleAtEnd(component: IComponentMatcher) { assertLayersEnd { this.isVisible(component) } assertLayersEnd { this.isVisible(component) } } } fun FlickerTestParameter.layerKeepVisible(component: IComponentMatcher) { fun FlickerTest.layerKeepVisible(component: IComponentMatcher) { assertLayers { this.isVisible(component) } assertLayers { this.isVisible(component) } } } fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible( fun FlickerTest.splitAppLayerBoundsBecomesVisible( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean Loading @@ -145,12 +145,12 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) } } } } fun FlickerTestParameter.splitAppLayerBoundsBecomesVisibleByDrag(component: IComponentMatcher) { fun FlickerTest.splitAppLayerBoundsBecomesVisibleByDrag(component: IComponentMatcher) { assertLayers { assertLayers { this.notContains(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component), isOptional = true) this.notContains(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component), isOptional = true) .then() .then() Loading @@ -161,7 +161,7 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesVisibleByDrag(component: ICom } } } } fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible( fun FlickerTest.splitAppLayerBoundsBecomesInvisible( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean Loading @@ -171,7 +171,7 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) .then() .then() .isVisible(component, true) .isVisible(component, true) Loading @@ -180,27 +180,37 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible( } } } } fun FlickerTestParameter.splitAppLayerBoundsIsVisibleAtEnd( fun FlickerTest.splitAppLayerBoundsIsVisibleAtEnd( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean ) { ) { assertLayersEnd { assertLayersEnd { splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation) splitAppLayerBoundsSnapToDivider( component, landscapePosLeft, portraitPosTop, scenario.endRotation ) } } } } fun FlickerTestParameter.splitAppLayerBoundsKeepVisible( fun FlickerTest.splitAppLayerBoundsKeepVisible( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean ) { ) { assertLayers { assertLayers { splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation) splitAppLayerBoundsSnapToDivider( component, landscapePosLeft, portraitPosTop, scenario.endRotation ) } } } } fun FlickerTestParameter.splitAppLayerBoundsChanges( fun FlickerTest.splitAppLayerBoundsChanges( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean Loading @@ -211,14 +221,14 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) } else { } else { this.splitAppLayerBoundsSnapToDivider( this.splitAppLayerBoundsSnapToDivider( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) .then() .then() .isInvisible(component) .isInvisible(component) Loading @@ -227,7 +237,7 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) } } } } Loading @@ -237,7 +247,7 @@ fun LayersTraceSubject.splitAppLayerBoundsSnapToDivider( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean, portraitPosTop: Boolean, rotation: Int rotation: PlatformConsts.Rotation ): LayersTraceSubject { ): LayersTraceSubject { return invoke("splitAppLayerBoundsSnapToDivider") { return invoke("splitAppLayerBoundsSnapToDivider") { it.splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, rotation) it.splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, rotation) Loading @@ -248,7 +258,7 @@ fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean, portraitPosTop: Boolean, rotation: Int rotation: PlatformConsts.Rotation ): LayerTraceEntrySubject { ): LayerTraceEntrySubject { val displayBounds = WindowUtils.getDisplayBounds(rotation) val displayBounds = WindowUtils.getDisplayBounds(rotation) return invoke { return invoke { Loading Loading @@ -292,7 +302,7 @@ fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider( } } } } fun FlickerTestParameter.appWindowBecomesVisible(component: IComponentMatcher) { fun FlickerTest.appWindowBecomesVisible(component: IComponentMatcher) { assertWm { assertWm { this.isAppWindowInvisible(component) this.isAppWindowInvisible(component) .then() .then() Loading @@ -304,39 +314,39 @@ fun FlickerTestParameter.appWindowBecomesVisible(component: IComponentMatcher) { } } } } fun FlickerTestParameter.appWindowBecomesInvisible(component: IComponentMatcher) { fun FlickerTest.appWindowBecomesInvisible(component: IComponentMatcher) { assertWm { this.isAppWindowVisible(component).then().isAppWindowInvisible(component) } assertWm { this.isAppWindowVisible(component).then().isAppWindowInvisible(component) } } } fun FlickerTestParameter.appWindowIsVisibleAtStart(component: IComponentMatcher) { fun FlickerTest.appWindowIsVisibleAtStart(component: IComponentMatcher) { assertWmStart { this.isAppWindowVisible(component) } assertWmStart { this.isAppWindowVisible(component) } } } fun FlickerTestParameter.appWindowIsVisibleAtEnd(component: IComponentMatcher) { fun FlickerTest.appWindowIsVisibleAtEnd(component: IComponentMatcher) { assertWmEnd { this.isAppWindowVisible(component) } assertWmEnd { this.isAppWindowVisible(component) } } } fun FlickerTestParameter.appWindowIsInvisibleAtStart(component: IComponentMatcher) { fun FlickerTest.appWindowIsInvisibleAtStart(component: IComponentMatcher) { assertWmStart { this.isAppWindowInvisible(component) } assertWmStart { this.isAppWindowInvisible(component) } } } fun FlickerTestParameter.appWindowIsInvisibleAtEnd(component: IComponentMatcher) { fun FlickerTest.appWindowIsInvisibleAtEnd(component: IComponentMatcher) { assertWmEnd { this.isAppWindowInvisible(component) } assertWmEnd { this.isAppWindowInvisible(component) } } } fun FlickerTestParameter.appWindowIsNotContainAtStart(component: IComponentMatcher) { fun FlickerTest.appWindowIsNotContainAtStart(component: IComponentMatcher) { assertWmStart { this.notContains(component) } assertWmStart { this.notContains(component) } } } fun FlickerTestParameter.appWindowKeepVisible(component: IComponentMatcher) { fun FlickerTest.appWindowKeepVisible(component: IComponentMatcher) { assertWm { this.isAppWindowVisible(component) } assertWm { this.isAppWindowVisible(component) } } } fun FlickerTestParameter.dockedStackDividerIsVisibleAtEnd() { fun FlickerTest.dockedStackDividerIsVisibleAtEnd() { assertLayersEnd { this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) } assertLayersEnd { this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.dockedStackDividerBecomesVisible() { fun FlickerTest.dockedStackDividerBecomesVisible() { assertLayers { assertLayers { this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT) this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT) .then() .then() Loading @@ -344,7 +354,7 @@ fun FlickerTestParameter.dockedStackDividerBecomesVisible() { } } } } fun FlickerTestParameter.dockedStackDividerBecomesInvisible() { fun FlickerTest.dockedStackDividerBecomesInvisible() { assertLayers { assertLayers { this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) .then() .then() Loading @@ -352,12 +362,12 @@ fun FlickerTestParameter.dockedStackDividerBecomesInvisible() { } } } } fun FlickerTestParameter.dockedStackDividerNotExistsAtEnd() { fun FlickerTest.dockedStackDividerNotExistsAtEnd() { assertLayersEnd { this.notContains(DOCKED_STACK_DIVIDER_COMPONENT) } assertLayersEnd { this.notContains(DOCKED_STACK_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.appPairsPrimaryBoundsIsVisibleAtEnd( fun FlickerTest.appPairsPrimaryBoundsIsVisibleAtEnd( rotation: Int, rotation: PlatformConsts.Rotation, primaryComponent: IComponentMatcher primaryComponent: IComponentMatcher ) { ) { assertLayersEnd { assertLayersEnd { Loading @@ -366,8 +376,8 @@ fun FlickerTestParameter.appPairsPrimaryBoundsIsVisibleAtEnd( } } } } fun FlickerTestParameter.dockedStackPrimaryBoundsIsVisibleAtEnd( fun FlickerTest.dockedStackPrimaryBoundsIsVisibleAtEnd( rotation: Int, rotation: PlatformConsts.Rotation, primaryComponent: IComponentMatcher primaryComponent: IComponentMatcher ) { ) { assertLayersEnd { assertLayersEnd { Loading @@ -376,8 +386,8 @@ fun FlickerTestParameter.dockedStackPrimaryBoundsIsVisibleAtEnd( } } } } fun FlickerTestParameter.appPairsSecondaryBoundsIsVisibleAtEnd( fun FlickerTest.appPairsSecondaryBoundsIsVisibleAtEnd( rotation: Int, rotation: PlatformConsts.Rotation, secondaryComponent: IComponentMatcher secondaryComponent: IComponentMatcher ) { ) { assertLayersEnd { assertLayersEnd { Loading @@ -386,8 +396,8 @@ fun FlickerTestParameter.appPairsSecondaryBoundsIsVisibleAtEnd( } } } } fun FlickerTestParameter.dockedStackSecondaryBoundsIsVisibleAtEnd( fun FlickerTest.dockedStackSecondaryBoundsIsVisibleAtEnd( rotation: Int, rotation: PlatformConsts.Rotation, secondaryComponent: IComponentMatcher secondaryComponent: IComponentMatcher ) { ) { assertLayersEnd { assertLayersEnd { Loading @@ -396,38 +406,38 @@ fun FlickerTestParameter.dockedStackSecondaryBoundsIsVisibleAtEnd( } } } } fun getPrimaryRegion(dividerRegion: Region, rotation: Int): Region { fun getPrimaryRegion(dividerRegion: Region, rotation: PlatformConsts.Rotation): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { return if (rotation.isRotated()) { Region.from( Region.from( 0, 0, 0, 0, displayBounds.bounds.right, dividerRegion.bounds.left + WindowUtils.dockedStackDividerInset, dividerRegion.bounds.top + WindowUtils.dockedStackDividerInset displayBounds.bounds.bottom ) ) } else { } else { Region.from( Region.from( 0, 0, 0, 0, dividerRegion.bounds.left + WindowUtils.dockedStackDividerInset, displayBounds.bounds.right, displayBounds.bounds.bottom dividerRegion.bounds.top + WindowUtils.dockedStackDividerInset ) ) } } } } fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region { fun getSecondaryRegion(dividerRegion: Region, rotation: PlatformConsts.Rotation): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { return if (rotation.isRotated()) { Region.from( Region.from( dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset, 0, 0, dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset, displayBounds.bounds.right, displayBounds.bounds.right, displayBounds.bounds.bottom displayBounds.bounds.bottom ) ) } else { } else { Region.from( Region.from( dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset, 0, 0, dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset, displayBounds.bounds.right, displayBounds.bounds.right, displayBounds.bounds.bottom displayBounds.bounds.bottom ) ) Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt +12 −11 Original line number Original line Diff line number Diff line Loading @@ -21,21 +21,21 @@ import android.app.NotificationManager import android.content.Context import android.content.Context import android.content.pm.PackageManager import android.content.pm.PackageManager import android.os.ServiceManager import android.os.ServiceManager import android.view.Surface import androidx.test.uiautomator.By import androidx.test.uiautomator.By import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until import com.android.server.wm.flicker.Flicker import com.android.server.wm.flicker.FlickerBuilder import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTest import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.FlickerTestFactory import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.IFlickerTestData import com.android.server.wm.flicker.helpers.LaunchBubbleHelper import com.android.server.wm.flicker.helpers.LaunchBubbleHelper import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE import com.android.server.wm.traces.common.service.PlatformConsts import com.android.wm.shell.flicker.BaseTest import com.android.wm.shell.flicker.BaseTest import org.junit.runners.Parameterized import org.junit.runners.Parameterized /** Base configurations for Bubble flicker tests */ /** Base configurations for Bubble flicker tests */ abstract class BaseBubbleScreen(testSpec: FlickerTestParameter) : BaseTest(testSpec) { abstract class BaseBubbleScreen(flicker: FlickerTest) : BaseTest(flicker) { protected val context: Context = instrumentation.context protected val context: Context = instrumentation.context protected val testApp = LaunchBubbleHelper(instrumentation) protected val testApp = LaunchBubbleHelper(instrumentation) Loading Loading @@ -79,17 +79,18 @@ abstract class BaseBubbleScreen(testSpec: FlickerTestParameter) : BaseTest(testS } } } } protected fun Flicker.waitAndGetAddBubbleBtn(): UiObject2? = protected fun IFlickerTestData.waitAndGetAddBubbleBtn(): UiObject2? = device.wait(Until.findObject(By.text("Add Bubble")), FIND_OBJECT_TIMEOUT) device.wait(Until.findObject(By.text("Add Bubble")), FIND_OBJECT_TIMEOUT) protected fun Flicker.waitAndGetCancelAllBtn(): UiObject2? = protected fun IFlickerTestData.waitAndGetCancelAllBtn(): UiObject2? = device.wait(Until.findObject(By.text("Cancel All Bubble")), FIND_OBJECT_TIMEOUT) device.wait(Until.findObject(By.text("Cancel All Bubble")), FIND_OBJECT_TIMEOUT) companion object { companion object { @Parameterized.Parameters(name = "{0}") @Parameterized.Parameters(name = "{0}") @JvmStatic @JvmStatic fun getParams(): List<FlickerTestParameter> { fun getParams(): List<FlickerTest> { return FlickerTestParameterFactory.getInstance() return FlickerTestFactory.nonRotationTests( .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) supportedRotations = listOf(PlatformConsts.Rotation.ROTATION_0) ) } } const val FIND_OBJECT_TIMEOUT = 2000L const val FIND_OBJECT_TIMEOUT = 2000L Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt +5 −5 Original line number Original line Diff line number Diff line Loading @@ -25,9 +25,9 @@ import android.view.WindowManager import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By import androidx.test.uiautomator.By import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerBuilder import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTest import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.junit.FlickerParametersRunnerFactory import org.junit.Test import org.junit.Test import org.junit.runner.RunWith import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized Loading @@ -45,7 +45,7 @@ import org.junit.runners.Parameterized @RequiresDevice @RequiresDevice @RunWith(Parameterized::class) @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(testSpec) { open class DismissBubbleScreen(flicker: FlickerTest) : BaseBubbleScreen(flicker) { private val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager private val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager private val displaySize = DisplayMetrics() private val displaySize = DisplayMetrics() Loading @@ -72,7 +72,7 @@ open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScree @Presubmit @Presubmit @Test @Test open fun testAppIsAlwaysVisible() { open fun testAppIsAlwaysVisible() { testSpec.assertLayers { this.isVisible(testApp) } flicker.assertLayers { this.isVisible(testApp) } } } /** {@inheritDoc} */ /** {@inheritDoc} */ Loading Loading
libs/WindowManager/Shell/tests/flicker/AndroidTest.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,8 @@ <option name="run-command" value="locksettings set-disabled false" /> <option name="run-command" value="locksettings set-disabled false" /> <!-- restart launcher to activate TAPL --> <!-- restart launcher to activate TAPL --> <option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" /> <option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" /> <!-- Ensure output directory is empty at the start --> <option name="run-command" value="rm -rf /sdcard/flicker" /> </target_preparer> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <option name="cleanup-apks" value="true"/> <option name="cleanup-apks" value="true"/> Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt +22 −23 Original line number Original line Diff line number Diff line Loading @@ -20,10 +20,10 @@ import android.app.Instrumentation import android.platform.test.annotations.Presubmit import android.platform.test.annotations.Presubmit import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry import com.android.launcher3.tapl.LauncherInstrumentation import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerBuilder import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTest import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.junit.FlickerBuilderProvider import com.android.server.wm.flicker.navBarLayerIsVisibleAtStartAndEnd import com.android.server.wm.flicker.navBarLayerIsVisibleAtStartAndEnd import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible Loading @@ -45,12 +45,12 @@ import org.junit.Test abstract class BaseTest abstract class BaseTest @JvmOverloads @JvmOverloads constructor( constructor( protected val testSpec: FlickerTestParameter, protected val flicker: FlickerTest, protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), protected val tapl: LauncherInstrumentation = LauncherInstrumentation() protected val tapl: LauncherInstrumentation = LauncherInstrumentation() ) { ) { init { init { testSpec.setIsTablet( flicker.scenario.setIsTablet( WindowManagerStateHelper(instrumentation, clearCacheAfterParsing = false) WindowManagerStateHelper(instrumentation, clearCacheAfterParsing = false) .currentState .currentState .wmState .wmState Loading @@ -68,13 +68,13 @@ constructor( @FlickerBuilderProvider @FlickerBuilderProvider fun buildFlicker(): FlickerBuilder { fun buildFlicker(): FlickerBuilder { return FlickerBuilder(instrumentation).apply { return FlickerBuilder(instrumentation).apply { setup { testSpec.setIsTablet(wmHelper.currentState.wmState.isTablet) } setup { flicker.scenario.setIsTablet(wmHelper.currentState.wmState.isTablet) } transition() transition() } } } } /** Checks that all parts of the screen are covered during the transition */ /** Checks that all parts of the screen are covered during the transition */ @Presubmit @Test open fun entireScreenCovered() = testSpec.entireScreenCovered() @Presubmit @Test open fun entireScreenCovered() = flicker.entireScreenCovered() /** /** * Checks that the [ComponentNameMatcher.NAV_BAR] layer is visible during the whole transition * Checks that the [ComponentNameMatcher.NAV_BAR] layer is visible during the whole transition Loading @@ -82,8 +82,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun navBarLayerIsVisibleAtStartAndEnd() { open fun navBarLayerIsVisibleAtStartAndEnd() { Assume.assumeFalse(testSpec.isTablet) Assume.assumeFalse(flicker.scenario.isTablet) testSpec.navBarLayerIsVisibleAtStartAndEnd() flicker.navBarLayerIsVisibleAtStartAndEnd() } } /** /** Loading @@ -93,8 +93,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun navBarLayerPositionAtStartAndEnd() { open fun navBarLayerPositionAtStartAndEnd() { Assume.assumeFalse(testSpec.isTablet) Assume.assumeFalse(flicker.scenario.isTablet) testSpec.navBarLayerPositionAtStartAndEnd() flicker.navBarLayerPositionAtStartAndEnd() } } /** /** Loading @@ -105,8 +105,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun navBarWindowIsAlwaysVisible() { open fun navBarWindowIsAlwaysVisible() { Assume.assumeFalse(testSpec.isTablet) Assume.assumeFalse(flicker.scenario.isTablet) testSpec.navBarWindowIsAlwaysVisible() flicker.navBarWindowIsAlwaysVisible() } } /** /** Loading @@ -115,8 +115,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun taskBarLayerIsVisibleAtStartAndEnd() { open fun taskBarLayerIsVisibleAtStartAndEnd() { Assume.assumeTrue(testSpec.isTablet) Assume.assumeTrue(flicker.scenario.isTablet) testSpec.taskBarLayerIsVisibleAtStartAndEnd() flicker.taskBarLayerIsVisibleAtStartAndEnd() } } /** /** Loading @@ -127,8 +127,8 @@ constructor( @Presubmit @Presubmit @Test @Test open fun taskBarWindowIsAlwaysVisible() { open fun taskBarWindowIsAlwaysVisible() { Assume.assumeTrue(testSpec.isTablet) Assume.assumeTrue(flicker.scenario.isTablet) testSpec.taskBarWindowIsAlwaysVisible() flicker.taskBarWindowIsAlwaysVisible() } } /** /** Loading @@ -137,8 +137,7 @@ constructor( */ */ @Presubmit @Presubmit @Test @Test open fun statusBarLayerIsVisibleAtStartAndEnd() = open fun statusBarLayerIsVisibleAtStartAndEnd() = flicker.statusBarLayerIsVisibleAtStartAndEnd() testSpec.statusBarLayerIsVisibleAtStartAndEnd() /** /** * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the Loading @@ -146,7 +145,7 @@ constructor( */ */ @Presubmit @Presubmit @Test @Test open fun statusBarLayerPositionAtStartAndEnd() = testSpec.statusBarLayerPositionAtStartAndEnd() open fun statusBarLayerPositionAtStartAndEnd() = flicker.statusBarLayerPositionAtStartAndEnd() /** /** * Checks that the [ComponentNameMatcher.STATUS_BAR] window is visible during the whole * Checks that the [ComponentNameMatcher.STATUS_BAR] window is visible during the whole Loading @@ -154,7 +153,7 @@ constructor( */ */ @Presubmit @Presubmit @Test @Test open fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsAlwaysVisible() open fun statusBarWindowIsAlwaysVisible() = flicker.statusBarWindowIsAlwaysVisible() /** /** * Checks that all layers that are visible on the trace, are visible for at least 2 consecutive * Checks that all layers that are visible on the trace, are visible for at least 2 consecutive Loading @@ -163,7 +162,7 @@ constructor( @Presubmit @Presubmit @Test @Test open fun visibleLayersShownMoreThanOneConsecutiveEntry() { open fun visibleLayersShownMoreThanOneConsecutiveEntry() { testSpec.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() } flicker.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() } } } /** /** Loading @@ -173,6 +172,6 @@ constructor( @Presubmit @Presubmit @Test @Test open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { testSpec.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry() } flicker.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry() } } } } }
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt +72 −62 Original line number Original line Diff line number Diff line Loading @@ -18,23 +18,23 @@ package com.android.wm.shell.flicker package com.android.wm.shell.flicker import android.view.Surface import com.android.server.wm.flicker.FlickerTest import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.traces.layers.LayerTraceEntrySubject import com.android.server.wm.flicker.traces.layers.LayerTraceEntrySubject import com.android.server.wm.flicker.traces.layers.LayersTraceSubject import com.android.server.wm.flicker.traces.layers.LayersTraceSubject import com.android.server.wm.traces.common.IComponentMatcher import com.android.server.wm.traces.common.IComponentMatcher import com.android.server.wm.traces.common.region.Region import com.android.server.wm.traces.common.region.Region import com.android.server.wm.traces.common.service.PlatformConsts fun FlickerTestParameter.appPairsDividerIsVisibleAtEnd() { fun FlickerTest.appPairsDividerIsVisibleAtEnd() { assertLayersEnd { this.isVisible(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } assertLayersEnd { this.isVisible(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.appPairsDividerIsInvisibleAtEnd() { fun FlickerTest.appPairsDividerIsInvisibleAtEnd() { assertLayersEnd { this.notContains(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } assertLayersEnd { this.notContains(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.appPairsDividerBecomesVisible() { fun FlickerTest.appPairsDividerBecomesVisible() { assertLayers { assertLayers { this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT) this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT) .then() .then() Loading @@ -42,7 +42,7 @@ fun FlickerTestParameter.appPairsDividerBecomesVisible() { } } } } fun FlickerTestParameter.splitScreenEntered( fun FlickerTest.splitScreenEntered( component1: IComponentMatcher, component1: IComponentMatcher, component2: IComponentMatcher, component2: IComponentMatcher, fromOtherApp: Boolean, fromOtherApp: Boolean, Loading @@ -69,7 +69,7 @@ fun FlickerTestParameter.splitScreenEntered( splitScreenDividerIsVisibleAtEnd() splitScreenDividerIsVisibleAtEnd() } } fun FlickerTestParameter.splitScreenDismissed( fun FlickerTest.splitScreenDismissed( component1: IComponentMatcher, component1: IComponentMatcher, component2: IComponentMatcher, component2: IComponentMatcher, toHome: Boolean toHome: Boolean Loading @@ -87,27 +87,27 @@ fun FlickerTestParameter.splitScreenDismissed( splitScreenDividerIsInvisibleAtEnd() splitScreenDividerIsInvisibleAtEnd() } } fun FlickerTestParameter.splitScreenDividerIsVisibleAtStart() { fun FlickerTest.splitScreenDividerIsVisibleAtStart() { assertLayersStart { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } assertLayersStart { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.splitScreenDividerIsVisibleAtEnd() { fun FlickerTest.splitScreenDividerIsVisibleAtEnd() { assertLayersEnd { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } assertLayersEnd { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.splitScreenDividerIsInvisibleAtStart() { fun FlickerTest.splitScreenDividerIsInvisibleAtStart() { assertLayersStart { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } assertLayersStart { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.splitScreenDividerIsInvisibleAtEnd() { fun FlickerTest.splitScreenDividerIsInvisibleAtEnd() { assertLayersEnd { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } assertLayersEnd { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.splitScreenDividerBecomesVisible() { fun FlickerTest.splitScreenDividerBecomesVisible() { layerBecomesVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) layerBecomesVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } fun FlickerTestParameter.splitScreenDividerBecomesInvisible() { fun FlickerTest.splitScreenDividerBecomesInvisible() { assertLayers { assertLayers { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) .then() .then() Loading @@ -115,23 +115,23 @@ fun FlickerTestParameter.splitScreenDividerBecomesInvisible() { } } } } fun FlickerTestParameter.layerBecomesVisible(component: IComponentMatcher) { fun FlickerTest.layerBecomesVisible(component: IComponentMatcher) { assertLayers { this.isInvisible(component).then().isVisible(component) } assertLayers { this.isInvisible(component).then().isVisible(component) } } } fun FlickerTestParameter.layerBecomesInvisible(component: IComponentMatcher) { fun FlickerTest.layerBecomesInvisible(component: IComponentMatcher) { assertLayers { this.isVisible(component).then().isInvisible(component) } assertLayers { this.isVisible(component).then().isInvisible(component) } } } fun FlickerTestParameter.layerIsVisibleAtEnd(component: IComponentMatcher) { fun FlickerTest.layerIsVisibleAtEnd(component: IComponentMatcher) { assertLayersEnd { this.isVisible(component) } assertLayersEnd { this.isVisible(component) } } } fun FlickerTestParameter.layerKeepVisible(component: IComponentMatcher) { fun FlickerTest.layerKeepVisible(component: IComponentMatcher) { assertLayers { this.isVisible(component) } assertLayers { this.isVisible(component) } } } fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible( fun FlickerTest.splitAppLayerBoundsBecomesVisible( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean Loading @@ -145,12 +145,12 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) } } } } fun FlickerTestParameter.splitAppLayerBoundsBecomesVisibleByDrag(component: IComponentMatcher) { fun FlickerTest.splitAppLayerBoundsBecomesVisibleByDrag(component: IComponentMatcher) { assertLayers { assertLayers { this.notContains(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component), isOptional = true) this.notContains(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component), isOptional = true) .then() .then() Loading @@ -161,7 +161,7 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesVisibleByDrag(component: ICom } } } } fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible( fun FlickerTest.splitAppLayerBoundsBecomesInvisible( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean Loading @@ -171,7 +171,7 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) .then() .then() .isVisible(component, true) .isVisible(component, true) Loading @@ -180,27 +180,37 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible( } } } } fun FlickerTestParameter.splitAppLayerBoundsIsVisibleAtEnd( fun FlickerTest.splitAppLayerBoundsIsVisibleAtEnd( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean ) { ) { assertLayersEnd { assertLayersEnd { splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation) splitAppLayerBoundsSnapToDivider( component, landscapePosLeft, portraitPosTop, scenario.endRotation ) } } } } fun FlickerTestParameter.splitAppLayerBoundsKeepVisible( fun FlickerTest.splitAppLayerBoundsKeepVisible( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean ) { ) { assertLayers { assertLayers { splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation) splitAppLayerBoundsSnapToDivider( component, landscapePosLeft, portraitPosTop, scenario.endRotation ) } } } } fun FlickerTestParameter.splitAppLayerBoundsChanges( fun FlickerTest.splitAppLayerBoundsChanges( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean portraitPosTop: Boolean Loading @@ -211,14 +221,14 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) } else { } else { this.splitAppLayerBoundsSnapToDivider( this.splitAppLayerBoundsSnapToDivider( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) .then() .then() .isInvisible(component) .isInvisible(component) Loading @@ -227,7 +237,7 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges( component, component, landscapePosLeft, landscapePosLeft, portraitPosTop, portraitPosTop, endRotation scenario.endRotation ) ) } } } } Loading @@ -237,7 +247,7 @@ fun LayersTraceSubject.splitAppLayerBoundsSnapToDivider( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean, portraitPosTop: Boolean, rotation: Int rotation: PlatformConsts.Rotation ): LayersTraceSubject { ): LayersTraceSubject { return invoke("splitAppLayerBoundsSnapToDivider") { return invoke("splitAppLayerBoundsSnapToDivider") { it.splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, rotation) it.splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, rotation) Loading @@ -248,7 +258,7 @@ fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider( component: IComponentMatcher, component: IComponentMatcher, landscapePosLeft: Boolean, landscapePosLeft: Boolean, portraitPosTop: Boolean, portraitPosTop: Boolean, rotation: Int rotation: PlatformConsts.Rotation ): LayerTraceEntrySubject { ): LayerTraceEntrySubject { val displayBounds = WindowUtils.getDisplayBounds(rotation) val displayBounds = WindowUtils.getDisplayBounds(rotation) return invoke { return invoke { Loading Loading @@ -292,7 +302,7 @@ fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider( } } } } fun FlickerTestParameter.appWindowBecomesVisible(component: IComponentMatcher) { fun FlickerTest.appWindowBecomesVisible(component: IComponentMatcher) { assertWm { assertWm { this.isAppWindowInvisible(component) this.isAppWindowInvisible(component) .then() .then() Loading @@ -304,39 +314,39 @@ fun FlickerTestParameter.appWindowBecomesVisible(component: IComponentMatcher) { } } } } fun FlickerTestParameter.appWindowBecomesInvisible(component: IComponentMatcher) { fun FlickerTest.appWindowBecomesInvisible(component: IComponentMatcher) { assertWm { this.isAppWindowVisible(component).then().isAppWindowInvisible(component) } assertWm { this.isAppWindowVisible(component).then().isAppWindowInvisible(component) } } } fun FlickerTestParameter.appWindowIsVisibleAtStart(component: IComponentMatcher) { fun FlickerTest.appWindowIsVisibleAtStart(component: IComponentMatcher) { assertWmStart { this.isAppWindowVisible(component) } assertWmStart { this.isAppWindowVisible(component) } } } fun FlickerTestParameter.appWindowIsVisibleAtEnd(component: IComponentMatcher) { fun FlickerTest.appWindowIsVisibleAtEnd(component: IComponentMatcher) { assertWmEnd { this.isAppWindowVisible(component) } assertWmEnd { this.isAppWindowVisible(component) } } } fun FlickerTestParameter.appWindowIsInvisibleAtStart(component: IComponentMatcher) { fun FlickerTest.appWindowIsInvisibleAtStart(component: IComponentMatcher) { assertWmStart { this.isAppWindowInvisible(component) } assertWmStart { this.isAppWindowInvisible(component) } } } fun FlickerTestParameter.appWindowIsInvisibleAtEnd(component: IComponentMatcher) { fun FlickerTest.appWindowIsInvisibleAtEnd(component: IComponentMatcher) { assertWmEnd { this.isAppWindowInvisible(component) } assertWmEnd { this.isAppWindowInvisible(component) } } } fun FlickerTestParameter.appWindowIsNotContainAtStart(component: IComponentMatcher) { fun FlickerTest.appWindowIsNotContainAtStart(component: IComponentMatcher) { assertWmStart { this.notContains(component) } assertWmStart { this.notContains(component) } } } fun FlickerTestParameter.appWindowKeepVisible(component: IComponentMatcher) { fun FlickerTest.appWindowKeepVisible(component: IComponentMatcher) { assertWm { this.isAppWindowVisible(component) } assertWm { this.isAppWindowVisible(component) } } } fun FlickerTestParameter.dockedStackDividerIsVisibleAtEnd() { fun FlickerTest.dockedStackDividerIsVisibleAtEnd() { assertLayersEnd { this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) } assertLayersEnd { this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.dockedStackDividerBecomesVisible() { fun FlickerTest.dockedStackDividerBecomesVisible() { assertLayers { assertLayers { this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT) this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT) .then() .then() Loading @@ -344,7 +354,7 @@ fun FlickerTestParameter.dockedStackDividerBecomesVisible() { } } } } fun FlickerTestParameter.dockedStackDividerBecomesInvisible() { fun FlickerTest.dockedStackDividerBecomesInvisible() { assertLayers { assertLayers { this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) .then() .then() Loading @@ -352,12 +362,12 @@ fun FlickerTestParameter.dockedStackDividerBecomesInvisible() { } } } } fun FlickerTestParameter.dockedStackDividerNotExistsAtEnd() { fun FlickerTest.dockedStackDividerNotExistsAtEnd() { assertLayersEnd { this.notContains(DOCKED_STACK_DIVIDER_COMPONENT) } assertLayersEnd { this.notContains(DOCKED_STACK_DIVIDER_COMPONENT) } } } fun FlickerTestParameter.appPairsPrimaryBoundsIsVisibleAtEnd( fun FlickerTest.appPairsPrimaryBoundsIsVisibleAtEnd( rotation: Int, rotation: PlatformConsts.Rotation, primaryComponent: IComponentMatcher primaryComponent: IComponentMatcher ) { ) { assertLayersEnd { assertLayersEnd { Loading @@ -366,8 +376,8 @@ fun FlickerTestParameter.appPairsPrimaryBoundsIsVisibleAtEnd( } } } } fun FlickerTestParameter.dockedStackPrimaryBoundsIsVisibleAtEnd( fun FlickerTest.dockedStackPrimaryBoundsIsVisibleAtEnd( rotation: Int, rotation: PlatformConsts.Rotation, primaryComponent: IComponentMatcher primaryComponent: IComponentMatcher ) { ) { assertLayersEnd { assertLayersEnd { Loading @@ -376,8 +386,8 @@ fun FlickerTestParameter.dockedStackPrimaryBoundsIsVisibleAtEnd( } } } } fun FlickerTestParameter.appPairsSecondaryBoundsIsVisibleAtEnd( fun FlickerTest.appPairsSecondaryBoundsIsVisibleAtEnd( rotation: Int, rotation: PlatformConsts.Rotation, secondaryComponent: IComponentMatcher secondaryComponent: IComponentMatcher ) { ) { assertLayersEnd { assertLayersEnd { Loading @@ -386,8 +396,8 @@ fun FlickerTestParameter.appPairsSecondaryBoundsIsVisibleAtEnd( } } } } fun FlickerTestParameter.dockedStackSecondaryBoundsIsVisibleAtEnd( fun FlickerTest.dockedStackSecondaryBoundsIsVisibleAtEnd( rotation: Int, rotation: PlatformConsts.Rotation, secondaryComponent: IComponentMatcher secondaryComponent: IComponentMatcher ) { ) { assertLayersEnd { assertLayersEnd { Loading @@ -396,38 +406,38 @@ fun FlickerTestParameter.dockedStackSecondaryBoundsIsVisibleAtEnd( } } } } fun getPrimaryRegion(dividerRegion: Region, rotation: Int): Region { fun getPrimaryRegion(dividerRegion: Region, rotation: PlatformConsts.Rotation): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { return if (rotation.isRotated()) { Region.from( Region.from( 0, 0, 0, 0, displayBounds.bounds.right, dividerRegion.bounds.left + WindowUtils.dockedStackDividerInset, dividerRegion.bounds.top + WindowUtils.dockedStackDividerInset displayBounds.bounds.bottom ) ) } else { } else { Region.from( Region.from( 0, 0, 0, 0, dividerRegion.bounds.left + WindowUtils.dockedStackDividerInset, displayBounds.bounds.right, displayBounds.bounds.bottom dividerRegion.bounds.top + WindowUtils.dockedStackDividerInset ) ) } } } } fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region { fun getSecondaryRegion(dividerRegion: Region, rotation: PlatformConsts.Rotation): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { return if (rotation.isRotated()) { Region.from( Region.from( dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset, 0, 0, dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset, displayBounds.bounds.right, displayBounds.bounds.right, displayBounds.bounds.bottom displayBounds.bounds.bottom ) ) } else { } else { Region.from( Region.from( dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset, 0, 0, dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset, displayBounds.bounds.right, displayBounds.bounds.right, displayBounds.bounds.bottom displayBounds.bounds.bottom ) ) Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt +12 −11 Original line number Original line Diff line number Diff line Loading @@ -21,21 +21,21 @@ import android.app.NotificationManager import android.content.Context import android.content.Context import android.content.pm.PackageManager import android.content.pm.PackageManager import android.os.ServiceManager import android.os.ServiceManager import android.view.Surface import androidx.test.uiautomator.By import androidx.test.uiautomator.By import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until import com.android.server.wm.flicker.Flicker import com.android.server.wm.flicker.FlickerBuilder import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTest import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.FlickerTestFactory import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.IFlickerTestData import com.android.server.wm.flicker.helpers.LaunchBubbleHelper import com.android.server.wm.flicker.helpers.LaunchBubbleHelper import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE import com.android.server.wm.traces.common.service.PlatformConsts import com.android.wm.shell.flicker.BaseTest import com.android.wm.shell.flicker.BaseTest import org.junit.runners.Parameterized import org.junit.runners.Parameterized /** Base configurations for Bubble flicker tests */ /** Base configurations for Bubble flicker tests */ abstract class BaseBubbleScreen(testSpec: FlickerTestParameter) : BaseTest(testSpec) { abstract class BaseBubbleScreen(flicker: FlickerTest) : BaseTest(flicker) { protected val context: Context = instrumentation.context protected val context: Context = instrumentation.context protected val testApp = LaunchBubbleHelper(instrumentation) protected val testApp = LaunchBubbleHelper(instrumentation) Loading Loading @@ -79,17 +79,18 @@ abstract class BaseBubbleScreen(testSpec: FlickerTestParameter) : BaseTest(testS } } } } protected fun Flicker.waitAndGetAddBubbleBtn(): UiObject2? = protected fun IFlickerTestData.waitAndGetAddBubbleBtn(): UiObject2? = device.wait(Until.findObject(By.text("Add Bubble")), FIND_OBJECT_TIMEOUT) device.wait(Until.findObject(By.text("Add Bubble")), FIND_OBJECT_TIMEOUT) protected fun Flicker.waitAndGetCancelAllBtn(): UiObject2? = protected fun IFlickerTestData.waitAndGetCancelAllBtn(): UiObject2? = device.wait(Until.findObject(By.text("Cancel All Bubble")), FIND_OBJECT_TIMEOUT) device.wait(Until.findObject(By.text("Cancel All Bubble")), FIND_OBJECT_TIMEOUT) companion object { companion object { @Parameterized.Parameters(name = "{0}") @Parameterized.Parameters(name = "{0}") @JvmStatic @JvmStatic fun getParams(): List<FlickerTestParameter> { fun getParams(): List<FlickerTest> { return FlickerTestParameterFactory.getInstance() return FlickerTestFactory.nonRotationTests( .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) supportedRotations = listOf(PlatformConsts.Rotation.ROTATION_0) ) } } const val FIND_OBJECT_TIMEOUT = 2000L const val FIND_OBJECT_TIMEOUT = 2000L Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt +5 −5 Original line number Original line Diff line number Diff line Loading @@ -25,9 +25,9 @@ import android.view.WindowManager import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By import androidx.test.uiautomator.By import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerBuilder import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTest import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.junit.FlickerParametersRunnerFactory import org.junit.Test import org.junit.Test import org.junit.runner.RunWith import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized Loading @@ -45,7 +45,7 @@ import org.junit.runners.Parameterized @RequiresDevice @RequiresDevice @RunWith(Parameterized::class) @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(testSpec) { open class DismissBubbleScreen(flicker: FlickerTest) : BaseBubbleScreen(flicker) { private val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager private val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager private val displaySize = DisplayMetrics() private val displaySize = DisplayMetrics() Loading @@ -72,7 +72,7 @@ open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScree @Presubmit @Presubmit @Test @Test open fun testAppIsAlwaysVisible() { open fun testAppIsAlwaysVisible() { testSpec.assertLayers { this.isVisible(testApp) } flicker.assertLayers { this.isVisible(testApp) } } } /** {@inheritDoc} */ /** {@inheritDoc} */ Loading