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

Commit 127ac01e authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Display-aware overview item assertion

This CL fixes CUJ-7p which verifies the overview mode behavior on
projected mode.
In projected mode, CD’s and the internal display’s overviews are
triggered separately. Therefore, in CUJ-7p, we have to trigger the CD’s
overview explicitly by clicking the recents button on CD.
This test _was_ passing before accidentally just because the CD overview
implementation was not completed.

Flag: EXEMPT - test fix
Bug: 425190576
Test: ConnectedDisplayCujSmokeTests#cuj7p
Change-Id: I9f6231e513807fb18ac67007925ead4f0e7f52ae
parent 0bb424e4
Loading
Loading
Loading
Loading
+38 −13
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.tools.Rotation
import android.tools.device.apphelpers.BrowserAppHelper
import android.tools.device.apphelpers.ClockAppHelper
import android.tools.device.apphelpers.StandardAppHelper
import android.tools.helpers.RecentTasksUtils
import android.tools.helpers.SYSTEMUI_PACKAGE
import android.tools.traces.component.ComponentNameMatcher
import android.tools.traces.component.IComponentNameMatcher
@@ -376,7 +377,7 @@ class ConnectedDisplayCujSmokeTests {
        overview.flingBackward()
        assertTrue("Can't find a desktop overview item", overview.currentTask.isDesktop)
        overview.flingForward()
        assertOverviewItemVisible(clockApp)
        assertOverviewItemVisible(clockApp, DEFAULT_DISPLAY)
    }

    // Projected: On the external display, opening an app from a full screen view will switch back
@@ -386,11 +387,7 @@ class ConnectedDisplayCujSmokeTests {
    @ProjectedOnly
    fun cuj7p() {
        // Clear all tasks
        with(tapl.workspace.openOverviewFromRecentsKeyboardShortcut()) {
            if (hasTasks()) {
                dismissAllTasks()
            }
        }
        RecentTasksUtils.clearAllVisibleRecentTasks(instrumentation)

        val externalDisplayId = connectedDisplayRule.setupTestDisplay()
        assertTaskbarVisible(externalDisplayId)
@@ -421,11 +418,12 @@ class ConnectedDisplayCujSmokeTests {
        )

        // Verify the overview has both the fullscreen app and the desktop.
        val overview = tapl.workspace.openOverviewFromRecentsKeyboardShortcut()
        overview.flingBackward()
        assertTrue("Can't find a desktop overview item", overview.currentTask.isDesktop)
        overview.flingForward()
        assertOverviewItemVisible(browserApp)
        // In projected mode, an external display's overview opens independently from the internal
        // display's one. So we here need to explicitly tap the recent button on the external
        // display.
        clickRecentsButton(externalDisplayId)
        assertOverviewDesktopItemVisible(externalDisplayId)
        assertOverviewItemVisible(browserApp, externalDisplayId)
    }

    // Extended: Desktop Windows can be dragged across displays using a cursor when external display
@@ -632,7 +630,21 @@ class ConnectedDisplayCujSmokeTests {
        ) { "Unable to find view for $selector" }).click()
    }

    fun assertOverviewItemVisible(appHelper: StandardAppHelper) {
    fun assertOverviewDesktopItemVisible(displayId: Int) {
        assertNotNull(
            "Unable to find overview desktop item",
            device.wait(
                Until.findObjects(
                    By.res(
                        TestHelpers.getOverviewPackageName(),
                        TASK_VIEW_DESKTOP_RES_ID
                    ).displayId(displayId)
                ), TIMEOUT.inWholeMilliseconds
            )
        )
    }

    fun assertOverviewItemVisible(appHelper: StandardAppHelper, displayId: Int) {
        val objects =
            checkNotNull(
                device.wait(
@@ -640,7 +652,7 @@ class ConnectedDisplayCujSmokeTests {
                        By.res(
                            TestHelpers.getOverviewPackageName(),
                            TASK_VIEW_SINGLE_RES_ID
                        )
                        ).displayId(displayId)
                    ), TIMEOUT.inWholeMilliseconds
                )
            ) { "Unable to find overview item" }
@@ -714,6 +726,17 @@ class ConnectedDisplayCujSmokeTests {
        )
    }

    fun clickRecentsButton(displayId: Int) {
        val selector = By.res(device.launcherPackageName, RECENTS_BUTTON_RES_ID)
            .displayId(displayId)
        (checkNotNull(
            device.wait(
                Until.findObject(selector),
                TIMEOUT.inWholeMilliseconds
            )
        ) { "Unable to find view for $selector" }).click()
    }

    fun taskbarSelector(displayId: Int): BySelector =
        By.res(device.launcherPackageName, TASKBAR_RES_ID).displayId(displayId)

@@ -733,7 +756,9 @@ class ConnectedDisplayCujSmokeTests {
        const val FULLSCREEN_BUTTON_RES_ID = "fullscreen_button"
        const val DESKTOP_BUTTON_RES_ID = "desktop_button"
        const val TASK_VIEW_SINGLE_RES_ID = "task_view_single"
        const val TASK_VIEW_DESKTOP_RES_ID = "task_view_desktop"
        const val APPS_LIST_VIEW_RES_ID = "apps_list_view"
        const val RECENTS_BUTTON_RES_ID = "recent_apps"
        const val CLOSE_BUTTON = "close_window"
        const val DISPLAY_TOPOLOGY_PANE_CONTENT_RES_ID = "display_topology_pane_content"
        const val EXTERNAL_DISPLAY_TEXT = "External Display"