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

Commit 620228d5 authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Restart SysUI before starting the suite

This CL enforces the SystemUI process to be restarted before running the
ConnectedDisplayCujSmokeTests to ensure it’s in a clean state.
Otherwise, prior tests may leave it dirty.

Flag: EXEMPT - test stabilization
Bug: 442453305
Bug: 442453913
Bug: 442454448
Bug: 442453123
Bug: 442453799
Test: atest WMShellSmokeTestsDesktopMode
Change-Id: I7bc7dbb1b8ebd8d6d865018b2fe855ccf4446095
parent 471dfb36
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.hardware.display.DisplayManager
import android.hardware.display.DisplayTopology
import android.hardware.input.InputManager
import android.os.Bundle
import android.platform.helpers.SysuiRestarter
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.RequiresFlagsEnabled
import android.platform.test.flag.junit.DeviceFlagsValueProvider
@@ -66,6 +67,7 @@ import org.junit.After
import org.junit.Assert.assertTrue
import org.junit.Assume
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -88,12 +90,8 @@ import java.time.Duration
@Postsubmit
class ConnectedDisplayCujSmokeTests {

    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val context = instrumentation.targetContext
    private val tapl = LauncherInstrumentation()
    private val wmHelper =
        WindowManagerStateHelper(instrumentation, retryIntervalMs = FLICKER_LIB_RETRY_INTERVAL_MS)
    private val device = UiDevice.getInstance(instrumentation)
    private val browserApp = BrowserAppHelper(instrumentation)
    private val clockApp = ClockAppHelper(instrumentation)
    private val desktopState = DesktopState.fromContext(context)
@@ -774,5 +772,25 @@ class ConnectedDisplayCujSmokeTests {
        // Following timeouts are adjusted for each platform by [platformAdjust()].
        val FLICKER_LIB_RETRY_INTERVAL_MS = Duration.ofMillis(500).platformAdjust().toMillis()
        val UIAUTOMATOR_TIMEOUT = Duration.ofSeconds(10).platformAdjust()

        val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
        val wmHelper =
            WindowManagerStateHelper(
                instrumentation,
                retryIntervalMs = FLICKER_LIB_RETRY_INTERVAL_MS
            )
        val device = UiDevice.getInstance(instrumentation)

        @JvmStatic
        @BeforeClass
        fun setupClass() {
            // Restart SystemUI to ensure it's in a clean state.
            SysuiRestarter.restartSystemUI(true)

            // Ensure launcher is visible.
            instrumentation.waitForIdleSync()
            By.pkg(device.launcherPackageName).depth(0).assertVisible(timeout = UIAUTOMATOR_TIMEOUT)
            wmHelper.StateSyncBuilder().withAppTransitionIdle().waitForAndVerify()
        }
    }
}