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

Commit bc460409 authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Count root tasks rather than windows

This CL changes cuj5e/p to count root tasks instead of windows.
The test cases use Chrome browser as a test app but Chrome may open a
popup upon its launch (e.g., Ad privacy check), which unexpectedly
increases the number of windows for the app.
What the test really wants to verify is that there is only one app
instance for the app. So counting a number of tasks should be more
appropriate.

Flag: EXEMPT - test fix
Bug: 440202064
Test: ConnectedDisplayCujSmokeTests
Change-Id: I6210f48af4f58f3866016d2acd49b799042ce4f3
parent aef5d8c6
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -276,14 +276,14 @@ class ConnectedDisplayCujSmokeTests {
    fun cuj5e() {
        browserApp.launchViaIntent()
        verifyActivityState(browserApp, WINDOWING_MODE_FULLSCREEN, DEFAULT_DISPLAY, visible = true)
        verifyWindowCount(browserApp, expectedCount = 1)
        verifyTaskCount(browserApp, expectedCount = 1)

        val externalDisplayId = connectedDisplayRule.setupTestDisplay()
        assertTaskbarVisible(externalDisplayId)

        launchAppFromTaskbar(externalDisplayId, browserApp)
        // TODO(b/418620963) - Check the display id of the app window here.
        verifyWindowCount(browserApp, expectedCount = 1)
        verifyTaskCount(browserApp, expectedCount = 1)
    }

    // Projected: All apps can be invoked on either display at any time, but will only ever be shown
@@ -293,14 +293,14 @@ class ConnectedDisplayCujSmokeTests {
    fun cuj5p() {
        launchAppFromAllApps(DEFAULT_DISPLAY, browserApp)
        verifyActivityState(browserApp, WINDOWING_MODE_FULLSCREEN, DEFAULT_DISPLAY, visible = true)
        verifyWindowCount(browserApp, expectedCount = 1)
        verifyTaskCount(browserApp, expectedCount = 1)

        val externalDisplayId = connectedDisplayRule.setupTestDisplay()
        assertTaskbarVisible(externalDisplayId)

        launchAppFromTaskbar(externalDisplayId, browserApp)
        verifyActivityState(browserApp, WINDOWING_MODE_FREEFORM, externalDisplayId, visible = true)
        verifyWindowCount(browserApp, expectedCount = 1)
        verifyTaskCount(browserApp, expectedCount = 1)
    }

    fun cuj6(skipAppHandleTest: Boolean = false) {
@@ -659,12 +659,13 @@ class ConnectedDisplayCujSmokeTests {
            .waitForAndVerify()
    }

    fun verifyWindowCount(componentMatcher: IComponentNameMatcher, expectedCount: Int) {
    fun verifyTaskCount(componentMatcher: IComponentNameMatcher, expectedCount: Int) {
        wmHelper.StateSyncBuilder()
            .withAppTransitionIdle()
            .add("${componentMatcher.packageName} has $expectedCount windows") { dump ->
                val appWindows = dump.wmState.appWindows
                appWindows.count { componentMatcher.windowMatchesAnyOf(it) } == expectedCount
            .add("${componentMatcher.packageName} has $expectedCount tasks") { dump ->
                dump.wmState.rootTasks.count {
                    it.containsActivity(componentMatcher)
                } == expectedCount
            }
            .waitForAndVerify()
    }