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

Commit 37010de3 authored by dakinola's avatar dakinola Committed by Daniel Akinola
Browse files

Flicker Tests: Snap Resizing Non-Resizable Apps

Bug: 358327087
Test: atest SnapResizeNonResizableAppWindowLeftWithDrag
Flag: TEST_ONLY
Change-Id: I4688bd8e38b5c9615bfbfdef1f97ccd37a1d84cb
parent c3070f0e
Loading
Loading
Loading
Loading
+40 −19
Original line number Diff line number Diff line
@@ -24,14 +24,19 @@ import android.tools.flicker.assertors.assertions.AppWindowBecomesVisible
import android.tools.flicker.assertors.assertions.AppWindowHasDesktopModeInitialBoundsAtTheEnd
import android.tools.flicker.assertors.assertions.AppWindowHasSizeOfAtLeast
import android.tools.flicker.assertors.assertions.AppWindowIsInvisibleAtEnd
import android.tools.flicker.assertors.assertions.AppWindowIsVisibleAlways
import android.tools.flicker.assertors.assertions.AppWindowMaintainsAspectRatioAlways
import android.tools.flicker.assertors.assertions.AppWindowOnTopAtEnd
import android.tools.flicker.assertors.assertions.AppWindowOnTopAtStart
import android.tools.flicker.assertors.assertions.AppWindowRemainInsideDisplayBounds
import android.tools.flicker.assertors.assertions.AppWindowReturnsToStartBoundsAndPosition
import android.tools.flicker.assertors.assertions.LauncherWindowReplacesAppAsTopWindow
import android.tools.flicker.config.AssertionTemplates
import android.tools.flicker.config.FlickerConfigEntry
import android.tools.flicker.config.ScenarioId
import android.tools.flicker.config.desktopmode.Components
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
import android.tools.flicker.extractors.ITransitionMatcher
import android.tools.flicker.extractors.ShellTransitionScenarioExtractor
import android.tools.flicker.extractors.TaggedCujTransitionMatcher
@@ -62,11 +67,9 @@ class DesktopModeFlickerScenarios {
                assertions =
                    AssertionTemplates.COMMON_ASSERTIONS +
                        listOf(
                                AppLayerIsVisibleAlways(Components.DESKTOP_MODE_APP),
                                AppWindowOnTopAtEnd(Components.DESKTOP_MODE_APP),
                                AppWindowHasDesktopModeInitialBoundsAtTheEnd(
                                    Components.DESKTOP_MODE_APP
                                ),
                            AppLayerIsVisibleAlways(DESKTOP_MODE_APP),
                            AppWindowOnTopAtEnd(DESKTOP_MODE_APP),
                            AppWindowHasDesktopModeInitialBoundsAtTheEnd(DESKTOP_MODE_APP),
                            AppWindowBecomesVisible(DESKTOP_WALLPAPER)
                        )
                            .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
@@ -97,11 +100,10 @@ class DesktopModeFlickerScenarios {
                assertions =
                    AssertionTemplates.COMMON_ASSERTIONS +
                        listOf(
                                AppWindowOnTopAtStart(Components.DESKTOP_MODE_APP),
                                AppLayerIsVisibleAtStart(Components.DESKTOP_MODE_APP),
                                AppLayerIsInvisibleAtEnd(Components.DESKTOP_MODE_APP),
                            )
                            .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
                            AppWindowOnTopAtStart(DESKTOP_MODE_APP),
                            AppLayerIsVisibleAtStart(DESKTOP_MODE_APP),
                            AppLayerIsInvisibleAtEnd(DESKTOP_MODE_APP)
                        ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
            )

        val CLOSE_LAST_APP =
@@ -125,8 +127,8 @@ class DesktopModeFlickerScenarios {
                assertions =
                    AssertionTemplates.COMMON_ASSERTIONS +
                        listOf(
                                AppWindowIsInvisibleAtEnd(Components.DESKTOP_MODE_APP),
                                LauncherWindowReplacesAppAsTopWindow(Components.DESKTOP_MODE_APP),
                            AppWindowIsInvisibleAtEnd(DESKTOP_MODE_APP),
                            LauncherWindowReplacesAppAsTopWindow(DESKTOP_MODE_APP),
                            AppWindowIsInvisibleAtEnd(DESKTOP_WALLPAPER)
                        )
                            .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
@@ -157,8 +159,27 @@ class DesktopModeFlickerScenarios {
                        .build(),
                assertions =
                AssertionTemplates.DESKTOP_MODE_APP_VISIBILITY_ASSERTIONS +
                        listOf(AppWindowHasSizeOfAtLeast(Components.DESKTOP_MODE_APP, 770, 700))
                        listOf(AppWindowHasSizeOfAtLeast(DESKTOP_MODE_APP, 770, 700))
                            .associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
            )

        val SNAP_RESIZE_WITH_DRAG_NON_RESIZABLE =
            FlickerConfigEntry(
                scenarioId = ScenarioId("SNAP_RESIZE_WITH_DRAG_NON_RESIZABLE"),
                extractor =
                TaggedScenarioExtractorBuilder()
                    .setTargetTag(CujType.CUJ_DESKTOP_MODE_SNAP_RESIZE)
                    .setTransitionMatcher(
                        TaggedCujTransitionMatcher(associatedTransitionRequired = false)
                    )
                    .build(),
                assertions = listOf(
                    AppWindowIsVisibleAlways(NON_RESIZABLE_APP),
                    AppWindowOnTopAtEnd(NON_RESIZABLE_APP),
                    AppWindowRemainInsideDisplayBounds(NON_RESIZABLE_APP),
                    AppWindowMaintainsAspectRatioAlways(NON_RESIZABLE_APP),
                    AppWindowReturnsToStartBoundsAndPosition(NON_RESIZABLE_APP)
                ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
            )
    }
}
+49 −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.SNAP_RESIZE_WITH_DRAG_NON_RESIZABLE
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithDrag
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Snap resize non-resizable app window by dragging it to the left edge of the screen.
 *
 * Assert that the app window keeps the same size and returns to its original pre-drag position.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class SnapResizeNonResizableAppWindowLeftWithDrag :
    SnapResizeAppWindowWithDrag(toLeft = true, isResizable = false) {
    @ExpectedScenarios(["SNAP_RESIZE_WITH_DRAG_NON_RESIZABLE"])
    @Test
    override fun snapResizeAppWindowWithDrag() = super.snapResizeAppWindowWithDrag()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT)
                .use(SNAP_RESIZE_WITH_DRAG_NON_RESIZABLE)
    }
}
 No newline at end of file
+49 −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.SNAP_RESIZE_WITH_DRAG_NON_RESIZABLE
import com.android.wm.shell.scenarios.SnapResizeAppWindowWithDrag
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Snap resize non-resizable app window by dragging it to the right edge of the screen.
 *
 * Assert that the app window keeps the same size and returns to its original pre-drag position.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class SnapResizeNonResizableAppWindowRightWithDrag :
    SnapResizeAppWindowWithDrag(toLeft = false, isResizable = false) {
    @ExpectedScenarios(["SNAP_RESIZE_WITH_DRAG_NON_RESIZABLE"])
    @Test
    override fun snapResizeAppWindowWithDrag() = super.snapResizeAppWindowWithDrag()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig().use(FlickerServiceConfig.DEFAULT)
                .use(SNAP_RESIZE_WITH_DRAG_NON_RESIZABLE)
    }
}
 No newline at end of file