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

Commit 271e521b authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Migrate ResizeAppTo(Max|Min)imumWindowSize to legacy flicker test

Test: atest ResizeAppToMaximumWindowSizeFlickerTest
Test: atest ResizeAppToMinimumWindowSizeFlickerTest
Fixes: 418239107
Flag: EXEMPT migrating test
Change-Id: I32f14634feac4777b1290e61aee35b5300b8a5d8
parent cdad3b5d
Loading
Loading
Loading
Loading
+0 −52
Original line number Original line 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.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.DesktopModeFlickerScenarios.Companion.CORNER_RESIZE_TO_MAXIMUM_SIZE
import com.android.wm.shell.scenarios.MaximiseAppWithCornerResize
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Resize app window using corner resize to the greatest possible height and width in
 * landscape mode.
 *
 * Assert that the maximum window size constraint is maintained.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class ResizeAppToMaximumWindowSizeLandscape : MaximiseAppWithCornerResize(
    rotation = Rotation.ROTATION_90
) {
    @ExpectedScenarios(["CORNER_RESIZE_TO_MAXIMUM_SIZE"])
    @Test
    override fun resizeAppWithCornerResizeToMaximumSize() =
        super.resizeAppWithCornerResizeToMaximumSize()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(CORNER_RESIZE_TO_MAXIMUM_SIZE)
    }
}
+0 −49
Original line number Original line 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.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.CORNER_RESIZE_TO_MAXIMUM_SIZE
import com.android.wm.shell.scenarios.MaximiseAppWithCornerResize
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Resize app window using corner resize to the greatest possible height and width in
 * portrait mode.
 *
 * Assert that the maximum window size constraint is maintained.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class ResizeAppToMaximumWindowSizePortrait : MaximiseAppWithCornerResize() {
    @ExpectedScenarios(["CORNER_RESIZE_TO_MAXIMUM_SIZE"])
    @Test
    override fun resizeAppWithCornerResizeToMaximumSize() =
        super.resizeAppWithCornerResizeToMaximumSize()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(CORNER_RESIZE_TO_MAXIMUM_SIZE)
    }
}
+0 −52
Original line number Original line 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.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.DesktopModeFlickerScenarios.Companion.CORNER_RESIZE_TO_MINIMUM_SIZE
import com.android.wm.shell.scenarios.ResizeAppWithCornerResize
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Resize app window using corner resize to the smallest possible height and width in
 * landscape mode.
 *
 * Assert that the minimum window size constraint is maintained.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class ResizeAppToMinimumWindowSizeLandscape : ResizeAppWithCornerResize(
    rotation = Rotation.ROTATION_90,
    horizontalChange = -1500,
    verticalChange = 1500) {
    @ExpectedScenarios(["CORNER_RESIZE_TO_MINIMUM_SIZE"])
    @Test
    override fun resizeAppWithCornerResize() = super.resizeAppWithCornerResize()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(CORNER_RESIZE_TO_MINIMUM_SIZE)
    }
}
+0 −48
Original line number Original line 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.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.CORNER_RESIZE_TO_MINIMUM_SIZE
import com.android.wm.shell.scenarios.ResizeAppWithCornerResize
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Resize app window using corner resize to the smallest possible height and width in portrait mode.
 *
 * Assert that the minimum window size constraint is maintained.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class ResizeAppToMinimumWindowSizePortrait : ResizeAppWithCornerResize(horizontalChange = -1500,
    verticalChange = 1500) {
    @ExpectedScenarios(["CORNER_RESIZE_TO_MINIMUM_SIZE"])
    @Test
    override fun resizeAppWithCornerResize() = super.resizeAppWithCornerResize()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(CORNER_RESIZE_TO_MINIMUM_SIZE)
    }
}
+89 −0
Original line number Original line 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 com.android.wm.shell.scenarios.MaximiseAppWithCornerResize
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.appLayerHasMaxDisplayHeightAtEnd
import com.android.wm.shell.flicker.utils.appLayerHasMaxDisplayWidthAtEnd
import com.android.wm.shell.flicker.utils.resizeVeilKeepsIncreasingInSize

/**
 * Resize app window using corner resize to the greatest possible height and width.
 *
 * Assert that the maximum window size constraint is maintained.
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class ResizeAppToMaximumWindowSizeFlickerTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(
    flicker
) {
    inner class MaximizeStandardAppWithCornerResize : MaximiseAppWithCornerResize(
        rotation = flicker.scenario.startRotation
    )

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

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

    @Test
    fun appLayerHasMaxDisplayHeightAtEnd() = flicker.appLayerHasMaxDisplayHeightAtEnd(testApp)

    @Test
    fun appLayerHasMaxDisplayWidthAtEnd() = flicker.appLayerHasMaxDisplayWidthAtEnd(testApp)

    @Test
    fun resizeVeilKeepsIncreasingInSize() = flicker.resizeVeilKeepsIncreasingInSize(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
Loading