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

Commit 81cb0437 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Migrate snap resizing tests into legacy Flicker test

Test: atest SnapResize*
Flag: EXEMPT test migration
Fixes: 418236033
Fixes: 418237086
Fixes: 418237087
Change-Id: I6b1f259fd52c82fec8a53532ae6b1c7032d20227
parent d40f9b88
Loading
Loading
Loading
Loading
+0 −52
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 androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.SNAP_RESIZE_RIGHT_WITH_KEYBOARD
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithKeyboardShortcuts
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Snap resize app window using keyboard shortcut META + ].
 *
 * Assert that the app window fills the right half the display after being snap resized.
 */
@RequiresDevice
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class SnapResizeAppWindowRightWithKeyboard : SnapResizeAppWindowWithKeyboardShortcuts(
    toLeft = false
) {
    @ExpectedScenarios(["SNAP_RESIZE_RIGHT_WITH_KEYBOARD"])
    @Test
    override fun snapResizeAppWindowWithKeyboardShortcuts() =
        super.snapResizeAppWindowWithKeyboardShortcuts()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(SNAP_RESIZE_RIGHT_WITH_KEYBOARD)
    }
}
 No newline at end of file
+88 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 * Copyright (C) 2025 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.
@@ -14,19 +14,24 @@
 * limitations under the License.
 */

package com.android.wm.shell.flicker
package com.android.wm.shell.flicker.resizing

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 androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.SNAP_RESIZE_LEFT_WITH_BUTTON
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithButton
import android.platform.test.annotations.RequiresDevice
import android.tools.NavBar
import android.tools.flicker.assertions.FlickerTest
import android.tools.flicker.junit.FlickerParametersRunnerFactory
import android.tools.flicker.legacy.FlickerBuilder
import android.tools.flicker.legacy.LegacyFlickerTest
import android.tools.flicker.legacy.LegacyFlickerTestFactory
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.DesktopModeBaseTest
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import com.android.wm.shell.flicker.utils.appWindowCoversHalfScreenAtEnd
import com.android.wm.shell.flicker.utils.appWindowKeepVisible
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithButton

/**
 * Snap resize app window using the Snap Left button from the maximize menu.
@@ -34,16 +39,50 @@ import org.junit.runner.RunWith
 * Assert that the app window fills the left half the display after being snap resized.
 */
@RequiresDevice
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class SnapResizeAppWindowLeftWithButton : SnapResizeAppWindowWithButton(toLeft = true) {
    @ExpectedScenarios(["SNAP_RESIZE_LEFT_WITH_BUTTON"])
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class SnapResizeAppWindowLeftWithButtonFlickerTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(
    flicker
) {

    inner class SnapResizeAppWindowLeftWithButtonScenario : SnapResizeAppWindowWithButton(
        toLeft = true,
        rotation = flicker.scenario.startRotation
    )

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = SnapResizeAppWindowLeftWithButtonScenario()
    private val testApp = scenario.testApp

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
            }
            transitions {
                scenario.snapResizeAppWindowWithButton()
            }
            teardown {
                scenario.teardown()
            }
        }

    @Test
    override fun snapResizeAppWindowWithButton() = super.snapResizeAppWindowWithButton()
    fun appWindowCoversLeftHalfScreenAtEnd() =
        flicker.appWindowCoversHalfScreenAtEnd(testApp, isLeftHalf = true)

    @Test
    fun appWindowIsAlwaysVisible() = flicker.appWindowKeepVisible(testApp)

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(SNAP_RESIZE_LEFT_WITH_BUTTON)
        fun getParams(): Collection<FlickerTest> {
            return LegacyFlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
        }
    }
}
 No newline at end of file
+88 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 * Copyright (C) 2025 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.
@@ -14,19 +14,24 @@
 * limitations under the License.
 */

package com.android.wm.shell.flicker
package com.android.wm.shell.flicker.resizing

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 androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.SNAP_RESIZE_LEFT_WITH_DRAG
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithDrag
import android.platform.test.annotations.RequiresDevice
import android.tools.NavBar
import android.tools.flicker.assertions.FlickerTest
import android.tools.flicker.junit.FlickerParametersRunnerFactory
import android.tools.flicker.legacy.FlickerBuilder
import android.tools.flicker.legacy.LegacyFlickerTest
import android.tools.flicker.legacy.LegacyFlickerTestFactory
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.DesktopModeBaseTest
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import com.android.wm.shell.flicker.utils.appWindowCoversHalfScreenAtEnd
import com.android.wm.shell.flicker.utils.appWindowKeepVisible
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithDrag

/**
 * Snap resize app window by dragging it to the left edge of the screen.
@@ -34,16 +39,50 @@ import org.junit.runner.RunWith
 * Assert that the app window fills the left half the display after being snap resized.
 */
@RequiresDevice
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class SnapResizeAppWindowLeftWithDrag : SnapResizeAppWindowWithDrag(toLeft = true) {
    @ExpectedScenarios(["SNAP_RESIZE_LEFT_WITH_DRAG"])
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class SnapResizeAppWindowLeftWithDragFlickerTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(
    flicker
) {

    inner class SnapResizeAppWindowLeftWithDragScenario : SnapResizeAppWindowWithDrag(
        toLeft = true,
        rotation = flicker.scenario.startRotation
    )

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = SnapResizeAppWindowLeftWithDragScenario()
    private val testApp = scenario.testApp

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
            }
            transitions {
                scenario.snapResizeAppWindowWithDrag()
            }
            teardown {
                scenario.teardown()
            }
        }

    @Test
    override fun snapResizeAppWindowWithDrag() = super.snapResizeAppWindowWithDrag()
    fun appWindowCoversLeftHalfScreenAtEnd() =
        flicker.appWindowCoversHalfScreenAtEnd(testApp, isLeftHalf = true)

    @Test
    fun appWindowIsAlwaysVisible() = flicker.appWindowKeepVisible(testApp)

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(SNAP_RESIZE_LEFT_WITH_DRAG)
        fun getParams(): Collection<FlickerTest> {
            return LegacyFlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
        }
    }
}
 No newline at end of file
+88 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.resizing

import android.platform.test.annotations.RequiresDevice
import android.tools.NavBar
import android.tools.flicker.assertions.FlickerTest
import android.tools.flicker.junit.FlickerParametersRunnerFactory
import android.tools.flicker.legacy.FlickerBuilder
import android.tools.flicker.legacy.LegacyFlickerTest
import android.tools.flicker.legacy.LegacyFlickerTestFactory
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.DesktopModeBaseTest
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import com.android.wm.shell.flicker.utils.appWindowCoversHalfScreenAtEnd
import com.android.wm.shell.flicker.utils.appWindowKeepVisible
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithKeyboardShortcuts

/**
 * Snap resize app window using keyboard shortcut META + [.
 *
 * Assert that the app window fills the left half the display after being snap resized.
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class SnapResizeAppWindowLeftWithKeyboardFlickerTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(
    flicker
) {

    inner class SnapResizeAppWindowLeftWithKeyboardScenario : SnapResizeAppWindowWithKeyboardShortcuts(
        toLeft = true,
        rotation = flicker.scenario.startRotation
    )

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = SnapResizeAppWindowLeftWithKeyboardScenario()
    private val testApp = scenario.testApp

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
            }
            transitions {
                scenario.snapResizeAppWindowWithKeyboardShortcuts()
            }
            teardown {
                scenario.teardown()
            }
        }

    @Test
    fun appWindowCoversLeftHalfScreenAtEnd() =
        flicker.appWindowCoversHalfScreenAtEnd(testApp, isLeftHalf = true)

    @Test
    fun appWindowIsAlwaysVisible() = flicker.appWindowKeepVisible(testApp)

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerTest> {
            return LegacyFlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
        }
    }
}
 No newline at end of file
+88 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 * Copyright (C) 2025 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.
@@ -14,19 +14,24 @@
 * limitations under the License.
 */

package com.android.wm.shell.flicker
package com.android.wm.shell.flicker.resizing

import android.platform.test.annotations.RequiresDevice
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.DesktopModeFlickerScenarios.Companion.SNAP_RESIZE_RIGHT_WITH_BUTTON
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithButton
import android.tools.NavBar
import android.tools.flicker.assertions.FlickerTest
import android.tools.flicker.junit.FlickerParametersRunnerFactory
import android.tools.flicker.legacy.FlickerBuilder
import android.tools.flicker.legacy.LegacyFlickerTest
import android.tools.flicker.legacy.LegacyFlickerTestFactory
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.DesktopModeBaseTest
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import com.android.wm.shell.flicker.utils.appWindowCoversHalfScreenAtEnd
import com.android.wm.shell.flicker.utils.appWindowKeepVisible
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithButton

/**
 * Snap resize app window using the Snap Right button from the maximize menu.
@@ -34,16 +39,50 @@ import org.junit.runner.RunWith
 * Assert that the app window fills the right half the display after being snap resized.
 */
@RequiresDevice
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class SnapResizeAppWindowRightWithButton : SnapResizeAppWindowWithButton(toLeft = false) {
    @ExpectedScenarios(["SNAP_RESIZE_RIGHT_WITH_BUTTON"])
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class SnapResizeAppWindowRightWithButtonFlickerTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(
    flicker
) {

    inner class SnapResizeAppWindowRightWithButtonScenario : SnapResizeAppWindowWithButton(
        toLeft = false,
        rotation = flicker.scenario.startRotation
    )

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = SnapResizeAppWindowRightWithButtonScenario()
    private val testApp = scenario.testApp

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
            }
            transitions {
                scenario.snapResizeAppWindowWithButton()
            }
            teardown {
                scenario.teardown()
            }
        }

    @Test
    override fun snapResizeAppWindowWithButton() = super.snapResizeAppWindowWithButton()
    fun appWindowCoversRightHalfScreenAtEnd() =
        flicker.appWindowCoversHalfScreenAtEnd(testApp, isLeftHalf = false)

    @Test
    fun appWindowIsAlwaysVisible() = flicker.appWindowKeepVisible(testApp)

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(SNAP_RESIZE_RIGHT_WITH_BUTTON)
        fun getParams(): Collection<FlickerTest> {
            return LegacyFlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
        }
    }
}
 No newline at end of file
Loading