Loading libs/WindowManager/Shell/tests/flicker/service/src/com/android/wm/shell/flicker/service/desktopmode/flicker/DesktopModeFlickerScenarios.kt +26 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAtStart import android.tools.flicker.assertors.assertions.AppWindowHasDesktopModeInitialBoundsAtTheEnd import android.tools.flicker.assertors.assertions.AppWindowOnTopAtEnd import android.tools.flicker.assertors.assertions.AppWindowOnTopAtStart import android.tools.flicker.assertors.assertions.AppWindowRemainInsideDisplayBounds import android.tools.flicker.assertors.assertions.LauncherWindowMovesToTop import android.tools.flicker.config.AssertionTemplates import android.tools.flicker.config.FlickerConfigEntry Loading Loading @@ -114,5 +115,30 @@ class DesktopModeFlickerScenarios { ) .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }), ) val CORNER_RESIZE = FlickerConfigEntry( scenarioId = ScenarioId("CORNER_RESIZE"), extractor = ShellTransitionScenarioExtractor( transitionMatcher = object : ITransitionMatcher { override fun findAll( transitions: Collection<Transition> ): Collection<Transition> { return transitions.filter { it.type == TransitionType.CHANGE } } } ), assertions = AssertionTemplates.COMMON_ASSERTIONS + listOf( AppLayerIsVisibleAlways(Components.DESKTOP_MODE_APP), AppWindowOnTopAtEnd(Components.DESKTOP_MODE_APP), AppWindowRemainInsideDisplayBounds(Components.DESKTOP_MODE_APP), ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING }), ) } } libs/WindowManager/Shell/tests/flicker/service/src/com/android/wm/shell/flicker/service/desktopmode/flicker/ResizeAppWithCornerResizeLandscape.kt 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.wm.shell.flicker.service.desktopmode.flicker import android.tools.Rotation import android.tools.flicker.FlickerConfig import android.tools.flicker.annotation.ExpectedScenarios import android.tools.flicker.annotation.FlickerConfigProvider import android.tools.flicker.config.FlickerConfig import android.tools.flicker.config.FlickerServiceConfig import android.tools.flicker.junit.FlickerServiceJUnit4ClassRunner import com.android.wm.shell.flicker.service.desktopmode.flicker.DesktopModeFlickerScenarios.Companion.CORNER_RESIZE import com.android.wm.shell.flicker.service.desktopmode.scenarios.ResizeAppWithCornerResize import org.junit.Test import org.junit.runner.RunWith @RunWith(FlickerServiceJUnit4ClassRunner::class) class ResizeAppWithCornerResizeLandscape : ResizeAppWithCornerResize(Rotation.ROTATION_90) { @ExpectedScenarios(["CORNER_RESIZE"]) @Test override fun resizeAppWithCornerResize() = super.resizeAppWithCornerResize() companion object { @JvmStatic @FlickerConfigProvider fun flickerConfigProvider(): FlickerConfig = FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(CORNER_RESIZE) } } libs/WindowManager/Shell/tests/flicker/service/src/com/android/wm/shell/flicker/service/desktopmode/flicker/ResizeAppWithCornerResizePortrait.kt 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.wm.shell.flicker.service.desktopmode.flicker import android.tools.Rotation import android.tools.flicker.FlickerConfig import android.tools.flicker.annotation.ExpectedScenarios import android.tools.flicker.annotation.FlickerConfigProvider import android.tools.flicker.config.FlickerConfig import android.tools.flicker.config.FlickerServiceConfig import android.tools.flicker.junit.FlickerServiceJUnit4ClassRunner import com.android.wm.shell.flicker.service.desktopmode.flicker.DesktopModeFlickerScenarios.Companion.CORNER_RESIZE import com.android.wm.shell.flicker.service.desktopmode.scenarios.ResizeAppWithCornerResize import org.junit.Test import org.junit.runner.RunWith @RunWith(FlickerServiceJUnit4ClassRunner::class) class ResizeAppWithCornerResizePortrait : ResizeAppWithCornerResize(Rotation.ROTATION_0) { @ExpectedScenarios(["CORNER_RESIZE"]) @Test override fun resizeAppWithCornerResize() = super.resizeAppWithCornerResize() companion object { @JvmStatic @FlickerConfigProvider fun flickerConfigProvider(): FlickerConfig = FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(CORNER_RESIZE) } } libs/WindowManager/Shell/tests/flicker/service/src/com/android/wm/shell/flicker/service/desktopmode/scenarios/ResizeAppWithCornerResize.kt 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.wm.shell.flicker.service.desktopmode.scenarios import android.app.Instrumentation import android.tools.NavBar import android.tools.Rotation import android.tools.traces.parsers.WindowManagerStateHelper import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.helpers.DesktopModeAppHelper import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.window.flags.Flags import com.android.wm.shell.flicker.service.common.Utils import org.junit.After import org.junit.Assume import org.junit.Before import org.junit.Ignore import org.junit.Rule import org.junit.Test @Ignore("Base Test Class") abstract class ResizeAppWithCornerResize @JvmOverloads constructor(val rotation: Rotation = Rotation.ROTATION_0) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val tapl = LauncherInstrumentation() private val wmHelper = WindowManagerStateHelper(instrumentation) private val device = UiDevice.getInstance(instrumentation) private val testApp = DesktopModeAppHelper(SimpleAppHelper(instrumentation)) @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation) @Before fun setup() { Assume.assumeTrue(Flags.enableDesktopWindowingMode()) tapl.setEnableRotation(true) tapl.setExpectedRotation(rotation.value) testApp.enterDesktopWithDrag(wmHelper, device) } @Test open fun resizeAppWithCornerResize() { testApp.cornerResize(wmHelper, device, DesktopModeAppHelper.Corners.RIGHT_TOP, 50, -50) } @After fun teardown() { testApp.exit(wmHelper) } } tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/DesktopModeAppHelper.kt +44 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm.flicker.helpers import android.graphics.Rect import android.tools.device.apphelpers.IStandardAppHelper import android.tools.helpers.SYSTEMUI_PACKAGE import android.tools.traces.parsers.WindowManagerStateHelper Loading @@ -32,6 +33,14 @@ import androidx.test.uiautomator.Until */ open class DesktopModeAppHelper(private val innerHelper: IStandardAppHelper) : IStandardAppHelper by innerHelper { enum class Corners { LEFT_TOP, RIGHT_TOP, LEFT_BOTTOM, RIGHT_BOTTOM } private val TIMEOUT_MS = 3_000L private val CAPTION = "desktop_mode_caption" private val CAPTION_HANDLE = "caption_handle" Loading Loading @@ -121,4 +130,39 @@ open class DesktopModeAppHelper(private val innerHelper: IStandardAppHelper) : wmHelper.getWindowRegion(innerHelper).bounds.contains(it.visibleBounds) } } /** Resize a desktop app from its corners. */ fun cornerResize( wmHelper: WindowManagerStateHelper, device: UiDevice, corner: Corners, horizontalChange: Int, verticalChange: Int ) { val windowRect = wmHelper.getWindowRegion(innerHelper).bounds val (startX, startY) = getStartCoordinatesForCornerResize(windowRect, corner) // The position we want to drag to val endY = startY + verticalChange val endX = startX + horizontalChange // drag the specified corner of the window to the end coordinate. device.drag(startX, startY, endX, endY, 100) wmHelper .StateSyncBuilder() .withAppTransitionIdle() .waitForAndVerify() } private fun getStartCoordinatesForCornerResize( windowRect: Rect, corner: Corners ): Pair<Int, Int> { return when (corner) { Corners.LEFT_TOP -> Pair(windowRect.left, windowRect.top) Corners.RIGHT_TOP -> Pair(windowRect.right, windowRect.top) Corners.LEFT_BOTTOM -> Pair(windowRect.left, windowRect.bottom) Corners.RIGHT_BOTTOM -> Pair(windowRect.right, windowRect.bottom) } } } Loading
libs/WindowManager/Shell/tests/flicker/service/src/com/android/wm/shell/flicker/service/desktopmode/flicker/DesktopModeFlickerScenarios.kt +26 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAtStart import android.tools.flicker.assertors.assertions.AppWindowHasDesktopModeInitialBoundsAtTheEnd import android.tools.flicker.assertors.assertions.AppWindowOnTopAtEnd import android.tools.flicker.assertors.assertions.AppWindowOnTopAtStart import android.tools.flicker.assertors.assertions.AppWindowRemainInsideDisplayBounds import android.tools.flicker.assertors.assertions.LauncherWindowMovesToTop import android.tools.flicker.config.AssertionTemplates import android.tools.flicker.config.FlickerConfigEntry Loading Loading @@ -114,5 +115,30 @@ class DesktopModeFlickerScenarios { ) .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }), ) val CORNER_RESIZE = FlickerConfigEntry( scenarioId = ScenarioId("CORNER_RESIZE"), extractor = ShellTransitionScenarioExtractor( transitionMatcher = object : ITransitionMatcher { override fun findAll( transitions: Collection<Transition> ): Collection<Transition> { return transitions.filter { it.type == TransitionType.CHANGE } } } ), assertions = AssertionTemplates.COMMON_ASSERTIONS + listOf( AppLayerIsVisibleAlways(Components.DESKTOP_MODE_APP), AppWindowOnTopAtEnd(Components.DESKTOP_MODE_APP), AppWindowRemainInsideDisplayBounds(Components.DESKTOP_MODE_APP), ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING }), ) } }
libs/WindowManager/Shell/tests/flicker/service/src/com/android/wm/shell/flicker/service/desktopmode/flicker/ResizeAppWithCornerResizeLandscape.kt 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.wm.shell.flicker.service.desktopmode.flicker import android.tools.Rotation import android.tools.flicker.FlickerConfig import android.tools.flicker.annotation.ExpectedScenarios import android.tools.flicker.annotation.FlickerConfigProvider import android.tools.flicker.config.FlickerConfig import android.tools.flicker.config.FlickerServiceConfig import android.tools.flicker.junit.FlickerServiceJUnit4ClassRunner import com.android.wm.shell.flicker.service.desktopmode.flicker.DesktopModeFlickerScenarios.Companion.CORNER_RESIZE import com.android.wm.shell.flicker.service.desktopmode.scenarios.ResizeAppWithCornerResize import org.junit.Test import org.junit.runner.RunWith @RunWith(FlickerServiceJUnit4ClassRunner::class) class ResizeAppWithCornerResizeLandscape : ResizeAppWithCornerResize(Rotation.ROTATION_90) { @ExpectedScenarios(["CORNER_RESIZE"]) @Test override fun resizeAppWithCornerResize() = super.resizeAppWithCornerResize() companion object { @JvmStatic @FlickerConfigProvider fun flickerConfigProvider(): FlickerConfig = FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(CORNER_RESIZE) } }
libs/WindowManager/Shell/tests/flicker/service/src/com/android/wm/shell/flicker/service/desktopmode/flicker/ResizeAppWithCornerResizePortrait.kt 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.wm.shell.flicker.service.desktopmode.flicker import android.tools.Rotation import android.tools.flicker.FlickerConfig import android.tools.flicker.annotation.ExpectedScenarios import android.tools.flicker.annotation.FlickerConfigProvider import android.tools.flicker.config.FlickerConfig import android.tools.flicker.config.FlickerServiceConfig import android.tools.flicker.junit.FlickerServiceJUnit4ClassRunner import com.android.wm.shell.flicker.service.desktopmode.flicker.DesktopModeFlickerScenarios.Companion.CORNER_RESIZE import com.android.wm.shell.flicker.service.desktopmode.scenarios.ResizeAppWithCornerResize import org.junit.Test import org.junit.runner.RunWith @RunWith(FlickerServiceJUnit4ClassRunner::class) class ResizeAppWithCornerResizePortrait : ResizeAppWithCornerResize(Rotation.ROTATION_0) { @ExpectedScenarios(["CORNER_RESIZE"]) @Test override fun resizeAppWithCornerResize() = super.resizeAppWithCornerResize() companion object { @JvmStatic @FlickerConfigProvider fun flickerConfigProvider(): FlickerConfig = FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(CORNER_RESIZE) } }
libs/WindowManager/Shell/tests/flicker/service/src/com/android/wm/shell/flicker/service/desktopmode/scenarios/ResizeAppWithCornerResize.kt 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.wm.shell.flicker.service.desktopmode.scenarios import android.app.Instrumentation import android.tools.NavBar import android.tools.Rotation import android.tools.traces.parsers.WindowManagerStateHelper import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.helpers.DesktopModeAppHelper import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.window.flags.Flags import com.android.wm.shell.flicker.service.common.Utils import org.junit.After import org.junit.Assume import org.junit.Before import org.junit.Ignore import org.junit.Rule import org.junit.Test @Ignore("Base Test Class") abstract class ResizeAppWithCornerResize @JvmOverloads constructor(val rotation: Rotation = Rotation.ROTATION_0) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val tapl = LauncherInstrumentation() private val wmHelper = WindowManagerStateHelper(instrumentation) private val device = UiDevice.getInstance(instrumentation) private val testApp = DesktopModeAppHelper(SimpleAppHelper(instrumentation)) @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation) @Before fun setup() { Assume.assumeTrue(Flags.enableDesktopWindowingMode()) tapl.setEnableRotation(true) tapl.setExpectedRotation(rotation.value) testApp.enterDesktopWithDrag(wmHelper, device) } @Test open fun resizeAppWithCornerResize() { testApp.cornerResize(wmHelper, device, DesktopModeAppHelper.Corners.RIGHT_TOP, 50, -50) } @After fun teardown() { testApp.exit(wmHelper) } }
tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/DesktopModeAppHelper.kt +44 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm.flicker.helpers import android.graphics.Rect import android.tools.device.apphelpers.IStandardAppHelper import android.tools.helpers.SYSTEMUI_PACKAGE import android.tools.traces.parsers.WindowManagerStateHelper Loading @@ -32,6 +33,14 @@ import androidx.test.uiautomator.Until */ open class DesktopModeAppHelper(private val innerHelper: IStandardAppHelper) : IStandardAppHelper by innerHelper { enum class Corners { LEFT_TOP, RIGHT_TOP, LEFT_BOTTOM, RIGHT_BOTTOM } private val TIMEOUT_MS = 3_000L private val CAPTION = "desktop_mode_caption" private val CAPTION_HANDLE = "caption_handle" Loading Loading @@ -121,4 +130,39 @@ open class DesktopModeAppHelper(private val innerHelper: IStandardAppHelper) : wmHelper.getWindowRegion(innerHelper).bounds.contains(it.visibleBounds) } } /** Resize a desktop app from its corners. */ fun cornerResize( wmHelper: WindowManagerStateHelper, device: UiDevice, corner: Corners, horizontalChange: Int, verticalChange: Int ) { val windowRect = wmHelper.getWindowRegion(innerHelper).bounds val (startX, startY) = getStartCoordinatesForCornerResize(windowRect, corner) // The position we want to drag to val endY = startY + verticalChange val endX = startX + horizontalChange // drag the specified corner of the window to the end coordinate. device.drag(startX, startY, endX, endY, 100) wmHelper .StateSyncBuilder() .withAppTransitionIdle() .waitForAndVerify() } private fun getStartCoordinatesForCornerResize( windowRect: Rect, corner: Corners ): Pair<Int, Int> { return when (corner) { Corners.LEFT_TOP -> Pair(windowRect.left, windowRect.top) Corners.RIGHT_TOP -> Pair(windowRect.right, windowRect.top) Corners.LEFT_BOTTOM -> Pair(windowRect.left, windowRect.bottom) Corners.RIGHT_BOTTOM -> Pair(windowRect.right, windowRect.bottom) } } }