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

Commit 3efc8096 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Add test setup rule back to the scenarios.

This is so that functional tests that just inherit the scenario will
also have the correct test setup rule and orientation during the test.

Bug: 408170368
Test: atest OpenAppFromAllAppsFlickerTest
Test: atest OpenAppFromTaskbarFlickerTest
Flag: EXEMPT test correction
Change-Id: Ieafba0f990e15b5f41b1eab30cdf9affb5672ca4
parent 271e521b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -39,10 +39,12 @@ import com.android.wm.shell.scenarios.OpenAppFromAllApps
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class OpenAppFromAllAppsFlickerTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(flicker) {
    inner class OpenAppFromAllAppsScenario : OpenAppFromAllApps(flicker.scenario.startRotation)

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = OpenAppFromAllApps()
    val scenario = OpenAppFromAllAppsScenario()
    private val openedApp = scenario.calculatorApp

    override val transition: FlickerBuilder.() -> Unit
+3 −1
Original line number Diff line number Diff line
@@ -39,10 +39,12 @@ import com.android.wm.shell.flicker.utils.cascadingEffectAppliedAtEnd
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class OpenAppFromTaskbarFlickerTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(flicker) {
    inner class OpenAppFromTaskbarScenario : OpenAppFromTaskbar(flicker.scenario.startRotation)

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = OpenAppFromTaskbar()
    val scenario = OpenAppFromTaskbarScenario()
    private val openedApp = scenario.browserApp

    override val transition: FlickerBuilder.() -> Unit
+13 −2
Original line number Diff line number Diff line
@@ -17,7 +17,10 @@
package com.android.wm.shell.scenarios

import android.app.Instrumentation
import android.tools.NavBar
import android.tools.PlatformConsts.DEFAULT_DISPLAY
import android.tools.flicker.rules.ChangeDisplayOrientationRule
import android.tools.Rotation
import android.tools.device.apphelpers.CalculatorAppHelper
import android.tools.traces.parsers.WindowManagerStateHelper
import androidx.test.platform.app.InstrumentationRegistry
@@ -25,14 +28,17 @@ 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.Utils
import com.android.wm.shell.shared.desktopmode.DesktopState
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test

open class OpenAppFromAllApps() : TestScenarioBase() {
@Ignore("Test Base Class")
abstract class OpenAppFromAllApps(val rotation: Rotation = Rotation.ROTATION_0) : TestScenarioBase() {

    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val tapl = LauncherInstrumentation()
@@ -41,6 +47,9 @@ open class OpenAppFromAllApps() : TestScenarioBase() {
    private val testApp = DesktopModeAppHelper(SimpleAppHelper(instrumentation))
    val calculatorApp = CalculatorAppHelper(instrumentation)

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

    @Before
    fun setup() {
        Assume.assumeTrue(
@@ -48,7 +57,9 @@ open class OpenAppFromAllApps() : TestScenarioBase() {
                .isDesktopModeSupportedOnDisplay(DEFAULT_DISPLAY)
        )
        tapl.setEnableRotation(true)
        tapl.setExpectedRotation(rotation.value)
        tapl.enableTransientTaskbar(false)
        ChangeDisplayOrientationRule.setRotation(rotation)
        testApp.enterDesktopMode(wmHelper, device)
        tapl.showTaskbarIfHidden()
    }
+15 −2
Original line number Diff line number Diff line
@@ -17,22 +17,29 @@
package com.android.wm.shell.scenarios

import android.app.Instrumentation
import android.tools.NavBar
import android.tools.Rotation
import android.tools.PlatformConsts.DEFAULT_DISPLAY
import android.tools.device.apphelpers.BrowserAppHelper
import android.tools.flicker.rules.ChangeDisplayOrientationRule
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.Utils
import com.android.wm.shell.shared.desktopmode.DesktopState
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test

open class OpenAppFromTaskbar() : TestScenarioBase() {
@Ignore("Test Base Class")
abstract class OpenAppFromTaskbar(val rotation: Rotation = Rotation.ROTATION_0) : TestScenarioBase() {

    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val tapl = LauncherInstrumentation()
    private val wmHelper = WindowManagerStateHelper(instrumentation)
@@ -40,6 +47,10 @@ open class OpenAppFromTaskbar() : TestScenarioBase() {
    private val testApp = DesktopModeAppHelper(SimpleAppHelper(instrumentation))
    val browserApp = BrowserAppHelper(instrumentation)

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

    @Before
    fun setup() {
        Assume.assumeTrue(
@@ -47,7 +58,9 @@ open class OpenAppFromTaskbar() : TestScenarioBase() {
                .isDesktopModeSupportedOnDisplay(DEFAULT_DISPLAY)
        )
        tapl.setEnableRotation(true)
        tapl.setExpectedRotation(rotation.value)
        tapl.enableTransientTaskbar(false)
        ChangeDisplayOrientationRule.setRotation(rotation)
        testApp.enterDesktopMode(wmHelper, device)
        tapl.showTaskbarIfHidden()
    }