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

Commit ca2b2f66 authored by Sergey Pinkevich's avatar Sergey Pinkevich Committed by Android (Google) Code Review
Browse files

Merge "[E2E test] Visual indicator in the taskbar for running/minimized apps" into main

parents 3cc1d52c fcc1eb33
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -61,9 +61,20 @@ abstract class TaskbarInDesktopMode(
        calculatorAppHelper
    )

    // This is a subset of the list above, having only apps that are reliable for identifying a
    // taskbar visual indicator using content description labels.
    private val appHelpersToTestTaskbarIndicator = listOf(
        simpleAppHelper,
        youtubeAppHelper,
        browserAppHelper,
    )

    private val appsMap: Map<DesktopModeAppHelper, StandardAppHelper> =
        appHelpers.associateBy { DesktopModeAppHelper(it) }

    private val appsToTestTaskbarIndicatorMap: Map<DesktopModeAppHelper, StandardAppHelper> =
        appHelpersToTestTaskbarIndicator.associateBy { DesktopModeAppHelper(it) }

    @Test
    open fun taskbarHasOpenedAppsIcons() {
        appsMap.entries.forEachIndexed { index, entry ->
@@ -79,10 +90,52 @@ abstract class TaskbarInDesktopMode(
        }
    }

    @Test
    open fun taskbarHasOpenedAppsVisualIndicators() {
        appsToTestTaskbarIndicatorMap.entries.forEachIndexed { index, entry ->
            val desktopApp = entry.key
            val appHelper = entry.value

            if (index == 0) {
                desktopApp.enterDesktopMode(wmHelper, device)
            } else {
                desktopApp.launchViaIntent(wmHelper)
            }

            val appIcon = tapl.launchedAppState.taskbar?.getAppIconForRunningApp(appHelper.appName)
            assertThat(appIcon).isNotNull()
            assertThat(appIcon?.appName?.split("\\s+".toRegex())?.last()).isEqualTo(ACTIVE_LABEL)
        }
    }

    @Test
    open fun taskbarHasMinimizedAppsVisualIndicators() {
        appsMap.entries.forEachIndexed { index, entry ->
            val desktopApp = entry.key
            val appHelper = entry.value

            if (index == 0) {
                desktopApp.enterDesktopMode(wmHelper, device)
            } else {
                desktopApp.launchViaIntent(wmHelper)
            }
            desktopApp.minimizeDesktopApp(wmHelper, device)

            val appIcon = tapl.launchedAppState.taskbar?.getAppIconForRunningApp(appHelper.appName)
            assertThat(appIcon).isNotNull()
            assertThat(appIcon?.appName?.split("\\s+".toRegex())?.last()).isEqualTo(MINIMIZED_LABEL)
        }
    }

    @After
    fun teardown() {
        appsMap.keys.reversed().forEach { desktopApp ->
            desktopApp.exit(wmHelper)
        }
    }

    private companion object {
        const val ACTIVE_LABEL = "Active"
        const val MINIMIZED_LABEL = "Minimised"
    }
}