Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46d9b2c1 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Add edge resizing flicker tests using stylus, mouse and touchpad.

Fixes: 358327200
Test: atest ResizeAppWithEdgeResizeStylus, Mouse, Touchpad
Flag: EXEMPT adding test
Change-Id: I05f9df9ce57127dfa3dc8c14488b32282ae8d11d
parent 0c217d3b
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -153,6 +153,22 @@ class DesktopModeFlickerScenarios {
                assertions = AssertionTemplates.DESKTOP_MODE_APP_VISIBILITY_ASSERTIONS
            )

        val EDGE_RESIZE =
            FlickerConfigEntry(
                scenarioId = ScenarioId("EDGE_RESIZE"),
                extractor =
                TaggedScenarioExtractorBuilder()
                    .setTargetTag(CujType.CUJ_DESKTOP_MODE_RESIZE_WINDOW)
                    .setTransitionMatcher(
                        TaggedCujTransitionMatcher(associatedTransitionRequired = false)
                    )
                    .build(),
                assertions = AssertionTemplates.DESKTOP_MODE_APP_VISIBILITY_ASSERTIONS +
                        listOf(
                            AppLayerIncreasesInSize(DESKTOP_MODE_APP),
                        ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
            )

        val CORNER_RESIZE_TO_MINIMUM_SIZE =
            FlickerConfigEntry(
                scenarioId = ScenarioId("CORNER_RESIZE_TO_MINIMUM_SIZE"),
+55 −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

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.server.wm.flicker.helpers.MotionEventHelper.InputMethod
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.EDGE_RESIZE
import com.android.wm.shell.scenarios.ResizeAppWithEdgeResize
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(FlickerServiceJUnit4ClassRunner::class)
class ResizeAppWithEdgeResizeMouse : ResizeAppWithEdgeResize(InputMethod.MOUSE) {
    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeRight() = super.resizeAppWithEdgeResizeRight()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeLeft() = super.resizeAppWithEdgeResizeLeft()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeTop() = super.resizeAppWithEdgeResizeTop()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeBottom() = super.resizeAppWithEdgeResizeBottom()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(EDGE_RESIZE)
    }
}
+55 −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

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.server.wm.flicker.helpers.MotionEventHelper.InputMethod
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.EDGE_RESIZE
import com.android.wm.shell.scenarios.ResizeAppWithEdgeResize
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(FlickerServiceJUnit4ClassRunner::class)
class ResizeAppWithEdgeResizeStylus : ResizeAppWithEdgeResize(InputMethod.STYLUS) {
    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeRight() = super.resizeAppWithEdgeResizeRight()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeLeft() = super.resizeAppWithEdgeResizeLeft()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeTop() = super.resizeAppWithEdgeResizeTop()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeBottom() = super.resizeAppWithEdgeResizeBottom()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(EDGE_RESIZE)
    }
}
+55 −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

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.server.wm.flicker.helpers.MotionEventHelper.InputMethod
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.EDGE_RESIZE
import com.android.wm.shell.scenarios.ResizeAppWithEdgeResize
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(FlickerServiceJUnit4ClassRunner::class)
class ResizeAppWithEdgeResizeTouchpad : ResizeAppWithEdgeResize(InputMethod.TOUCHPAD) {
    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeRight() = super.resizeAppWithEdgeResizeRight()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeLeft() = super.resizeAppWithEdgeResizeLeft()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeTop() = super.resizeAppWithEdgeResizeTop()

    @ExpectedScenarios(["EDGE_RESIZE"])
    @Test
    override fun resizeAppWithEdgeResizeBottom() = super.resizeAppWithEdgeResizeBottom()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(EDGE_RESIZE)
    }
}
+110 −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.scenarios

import android.platform.test.annotations.Postsubmit
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.MotionEventHelper
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.window.flags.Flags
import com.android.wm.shell.Utils
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.BlockJUnit4ClassRunner

@RunWith(BlockJUnit4ClassRunner::class)
@Postsubmit
open class ResizeAppWithEdgeResize
@JvmOverloads
constructor(
    val inputMethod: MotionEventHelper.InputMethod,
    val rotation: Rotation = Rotation.ROTATION_90
) {
    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))
    private val motionEventHelper = MotionEventHelper(instrumentation, inputMethod)

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation)

    @Before
    fun setup() {
        Assume.assumeTrue(
            Flags.enableDesktopWindowingMode()
                    && Flags.enableWindowingEdgeDragResize() && tapl.isTablet
        )
        tapl.setEnableRotation(true)
        tapl.setExpectedRotation(rotation.value)
        testApp.enterDesktopWithDrag(wmHelper, device)
    }

    @Test
    open fun resizeAppWithEdgeResizeRight() {
        testApp.edgeResize(
            wmHelper,
            motionEventHelper,
            DesktopModeAppHelper.Edges.RIGHT
        )
    }

    @Test
    open fun resizeAppWithEdgeResizeLeft() {
        testApp.edgeResize(
            wmHelper,
            motionEventHelper,
            DesktopModeAppHelper.Edges.LEFT
        )
    }

    @Test
    open fun resizeAppWithEdgeResizeTop() {
        testApp.edgeResize(
            wmHelper,
            motionEventHelper,
            DesktopModeAppHelper.Edges.TOP
        )
    }

    @Test
    open fun resizeAppWithEdgeResizeBottom() {
        testApp.edgeResize(
            wmHelper,
            motionEventHelper,
            DesktopModeAppHelper.Edges.BOTTOM
        )
    }

    @After
    fun teardown() {
        testApp.exit(wmHelper)
    }
}
Loading