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

Commit 807d89a7 authored by Yuichiro Hanada's avatar Yuichiro Hanada
Browse files

Add flicker tests for the minimize button

Flag: EXEMPT adding tests
Bug: 373973157
Test: atest WMShellFlickerTestsDesktopMode
Change-Id: I5ce717e6329eb71a7b0cad1f41e22b52613546da
parent 5d4b0eca
Loading
Loading
Loading
Loading
+55 −1
Original line number Diff line number Diff line
@@ -23,8 +23,9 @@ import android.tools.flicker.assertors.assertions.AppLayerIncreasesInSize
import android.tools.flicker.assertors.assertions.AppLayerIsInvisibleAtEnd
import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAlways
import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAtStart
import android.tools.flicker.assertors.assertions.AppWindowBecomesVisible
import android.tools.flicker.assertors.assertions.AppWindowAlignsWithOnlyOneDisplayCornerAtEnd
import android.tools.flicker.assertors.assertions.AppWindowBecomesInvisible
import android.tools.flicker.assertors.assertions.AppWindowBecomesVisible
import android.tools.flicker.assertors.assertions.AppWindowCoversLeftHalfScreenAtEnd
import android.tools.flicker.assertors.assertions.AppWindowCoversRightHalfScreenAtEnd
import android.tools.flicker.assertors.assertions.AppWindowHasDesktopModeInitialBoundsAtTheEnd
@@ -44,6 +45,7 @@ import android.tools.flicker.assertors.assertions.LauncherWindowReplacesAppAsTop
import android.tools.flicker.config.AssertionTemplates
import android.tools.flicker.config.FlickerConfigEntry
import android.tools.flicker.config.ScenarioId
import android.tools.flicker.config.common.Components.LAUNCHER
import android.tools.flicker.config.desktopmode.Components.DESKTOP_MODE_APP
import android.tools.flicker.config.desktopmode.Components.DESKTOP_WALLPAPER
import android.tools.flicker.config.desktopmode.Components.NON_RESIZABLE_APP
@@ -365,5 +367,57 @@ class DesktopModeFlickerScenarios {
                            AppWindowAlignsWithOnlyOneDisplayCornerAtEnd(DESKTOP_MODE_APP)
                        ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
            )

        val MINIMIZE_APP =
            FlickerConfigEntry(
                scenarioId = ScenarioId("MINIMIZE_APP"),
                extractor =
                ShellTransitionScenarioExtractor(
                    transitionMatcher =
                    object : ITransitionMatcher {
                        override fun findAll(
                            transitions: Collection<Transition>
                        ): Collection<Transition> {
                            return transitions
                                .filter { it.type == TransitionType.MINIMIZE }
                                .sortedByDescending { it.id }
                                .drop(1)
                        }
                    }
                ),
                assertions =
                AssertionTemplates.COMMON_ASSERTIONS +
                    listOf(
                        AppWindowOnTopAtStart(DESKTOP_MODE_APP),
                        AppWindowBecomesInvisible(DESKTOP_MODE_APP),
                    ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING })
            )

        val MINIMIZE_LAST_APP =
            FlickerConfigEntry(
                scenarioId = ScenarioId("MINIMIZE_LAST_APP"),
                extractor =
                ShellTransitionScenarioExtractor(
                    transitionMatcher =
                    object : ITransitionMatcher {
                        override fun findAll(
                            transitions: Collection<Transition>
                        ): Collection<Transition> {
                            val lastTransition =
                                transitions
                                .filter { it.type == TransitionType.MINIMIZE }
                                .maxByOrNull { it.id }!!
                            return listOf(lastTransition)
                        }
                    }
                ),
                assertions =
                AssertionTemplates.COMMON_ASSERTIONS +
                    listOf(
                        AppWindowOnTopAtStart(DESKTOP_MODE_APP),
                        AppWindowBecomesInvisible(DESKTOP_MODE_APP),
                        AppWindowOnTopAtEnd(LAUNCHER),
                    ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING })
            )
    }
}
+52 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.flicker

import android.tools.Rotation.ROTATION_90
import android.tools.flicker.FlickerConfig
import android.tools.flicker.annotation.ExpectedScenarios
import android.tools.flicker.annotation.FlickerConfigProvider
import android.tools.flicker.config.FlickerConfig
import android.tools.flicker.config.FlickerServiceConfig
import android.tools.flicker.junit.FlickerServiceJUnit4ClassRunner
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.MINIMIZE_APP
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.MINIMIZE_LAST_APP
import com.android.wm.shell.scenarios.MinimizeAppWindows
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Minimize app windows by pressing the minimize button.
 *
 * Assert that the app windows gets hidden.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class MinimizeAppsLandscape : MinimizeAppWindows(rotation = ROTATION_90) {
    @ExpectedScenarios(["MINIMIZE_APP", "MINIMIZE_LAST_APP"])
    @Test
    override fun minimizeAllAppWindows() = super.minimizeAllAppWindows()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig()
                .use(FlickerServiceConfig.DEFAULT)
                .use(MINIMIZE_APP)
                .use(MINIMIZE_LAST_APP)
    }
}
+51 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.flicker

import android.tools.flicker.FlickerConfig
import android.tools.flicker.annotation.ExpectedScenarios
import android.tools.flicker.annotation.FlickerConfigProvider
import android.tools.flicker.config.FlickerConfig
import android.tools.flicker.config.FlickerServiceConfig
import android.tools.flicker.junit.FlickerServiceJUnit4ClassRunner
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.MINIMIZE_APP
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.MINIMIZE_LAST_APP
import com.android.wm.shell.scenarios.MinimizeAppWindows
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Minimize app windows by pressing the minimize button.
 *
 * Assert that the app windows gets hidden.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class MinimizeAppsPortrait : MinimizeAppWindows() {
    @ExpectedScenarios(["MINIMIZE_APP", "MINIMIZE_LAST_APP"])
    @Test
    override fun minimizeAllAppWindows() = super.minimizeAllAppWindows()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig()
                .use(FlickerServiceConfig.DEFAULT)
                .use(MINIMIZE_APP)
                .use(MINIMIZE_LAST_APP)
    }
}