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

Commit 1bfcf0c1 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Add test rotation and setup rules into TestScenarioBase.

Also refactor the subclasses to remove duplication of the test setup
methods.

Flag: EXEMPT test refactoring
Test: atest
Fixes: 422470242
Change-Id: Id54e75dc8559b1602ac39a5c20daffe907e0fb7f
parent 54ac6934
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -17,8 +17,10 @@
package com.android.wm.shell.flicker

import android.platform.test.rule.ScreenRecordRule
import android.tools.PlatformConsts.DEFAULT_DISPLAY
import android.tools.flicker.legacy.LegacyFlickerTest
import android.tools.flicker.rules.ChangeDisplayOrientationRule
import androidx.test.uiautomator.UiDevice

import org.junit.Assume
import org.junit.Before
@@ -31,6 +33,7 @@ import com.android.server.wm.flicker.statusBarLayerPositionAtStartAndEnd
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.taskBarLayerIsVisibleAtStartAndEnd
import com.android.server.wm.flicker.taskBarWindowIsAlwaysVisible
import com.android.wm.shell.shared.desktopmode.DesktopState
import org.junit.ClassRule

/**
@@ -52,11 +55,20 @@ abstract class DesktopModeBaseTest(flicker: LegacyFlickerTest) : BaseBenchmarkTe
    // Override this set with the test method names that you want to exclude from the test
    open val excludedTests: Set<String> = emptySet()

    private val device = UiDevice.getInstance(instrumentation)

    @Before
    fun setUp() {
        Assume.assumeTrue(
            DesktopState.fromContext(instrumentation.context)
                .isDesktopModeSupportedOnDisplay(DEFAULT_DISPLAY)
        )
        tapl.setEnableRotation(true)
        tapl.setExpectedRotation(flicker.scenario.startRotation.value)
        ChangeDisplayOrientationRule.setRotation(flicker.scenario.startRotation)
        Assume.assumeTrue(tapl.isTablet)
        device.executeShellCommand(
            "dumpsys activity service SystemUIService WMShell desktopmode removeAllDesks"
        )

        val currentTestMethodName = testName.methodName
        Assume.assumeFalse(
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class EnterDesktopWithAppHandleMenuFlickerTest(flicker: LegacyFlickerTest) :
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
                scenario.baseSetup()
            }
            transitions {
                scenario.enterDesktopWithAppHandleMenu()
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ class EnterDesktopWithDragFlickerTest(flicker: LegacyFlickerTest) :
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
                scenario.baseSetup()
            }
            transitions {
                scenario.enterDesktopWithDrag()
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class EnterSplitScreenWithAppHandleMenuFlickerTest(flicker: LegacyFlickerTest) :
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
                scenario.baseSetup()
            }
            transitions {
                scenario.enterSplitScreenFromAppHandle()
+1 −20
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@
package com.android.wm.shell.scenarios

import android.app.Instrumentation
import android.tools.flicker.rules.ChangeDisplayOrientationRule
import android.tools.NavBar
import android.tools.PlatformConsts.DEFAULT_DISPLAY
import android.tools.Rotation
import android.tools.traces.parsers.WindowManagerStateHelper
import androidx.test.platform.app.InstrumentationRegistry
@@ -29,20 +26,15 @@ import com.android.server.wm.flicker.helpers.DesktopModeAppHelper
import com.android.server.wm.flicker.helpers.MailAppHelper
import com.android.server.wm.flicker.helpers.NewTasksAppHelper
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

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

    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val tapl = LauncherInstrumentation()
@@ -52,19 +44,8 @@ abstract class AltTabSwitchInDesktopMode(
    private val secondApp = MailAppHelper(instrumentation)
    private val thirdApp = NewTasksAppHelper(instrumentation)

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

    @Before
    fun setup() {
        Assume.assumeTrue(
            DesktopState.fromContext(instrumentation.context)
                .isDesktopModeSupportedOnDisplay(DEFAULT_DISPLAY)
        )
        tapl.setEnableRotation(true)
        tapl.setExpectedRotation(rotation.value)
        tapl.enableTransientTaskbar(false)
        ChangeDisplayOrientationRule.setRotation(rotation)
        firstApp.enterDesktopMode(wmHelper, device)
        secondApp.launchViaIntent(wmHelper)
        thirdApp.launchViaIntent(wmHelper)
Loading