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

Commit abddbcc8 authored by Charles Chen's avatar Charles Chen
Browse files

Verify dismiss expanded bubbles via Bubble View

Test: atest
WMShellExplicitFlickerTestsBubbles:DismissExpandedBubbleTest
Flag: TEST_ONLY
Bug: 396020056

Change-Id: Ie38337bae599d973ded9fd196b91d79a09abd6f3
parent 3bb700e6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ test_module_config {
    base: "WMShellExplicitFlickerTestsBubbles",
    exclude_filters: [
        "com.android.wm.shell.flicker.bubbles.CollapseBubbleViaBackTest",
        "com.android.wm.shell.flicker.bubbles.DismissExpandedBubbleViaBubbleViewTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleViaBubbleMenuTest",
        "com.android.wm.shell.flicker.bubbles.ExpandBubbleViaBubbleStackTest",
    ],
@@ -65,6 +66,13 @@ test_module_config {
    test_suites: ["device-tests"],
}

test_module_config {
    name: "WMShellExplicitFlickerTestsBubbles-DismissExpandedBubbleViaBubbleViewTest",
    base: "WMShellExplicitFlickerTestsBubbles",
    include_filters: ["com.android.wm.shell.flicker.bubbles.DismissExpandedBubbleViaBubbleViewTest"],
    test_suites: ["device-tests"],
}

test_module_config {
    name: "WMShellExplicitFlickerTestsBubbles-EnterBubbleViaBubbleMenuTest",
    base: "WMShellExplicitFlickerTestsBubbles",
+5 −2
Original line number Diff line number Diff line
@@ -4,10 +4,13 @@
      "name": "WMShellExplicitFlickerTestsBubbles-CatchAll"
    },
    {
      "name": "WMShellExplicitFlickerTestsBubbles-EnterBubbleViaBubbleMenuTest"
      "name": "WMShellExplicitFlickerTestsBubbles-CollapseBubbleViaBackTest"
    },
    {
      "name": "WMShellExplicitFlickerTestsBubbles-CollapseBubbleViaBackTest"
      "name": "WMShellExplicitFlickerTestsBubbles-DismissExpandedBubbleViaBubbleViewTes"
    },
    {
      "name": "WMShellExplicitFlickerTestsBubbles-EnterBubbleViaBubbleMenuTest"
    },
    {
      "name": "WMShellExplicitFlickerTestsBubbles-ExpandBubbleViaBubbleStackTest"
+2 −3
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.wm.shell.flicker.bubbles
import android.platform.test.flag.junit.CheckFlagsRule
import android.platform.test.flag.junit.DeviceFlagsValueProvider
import android.tools.Tag
import android.tools.device.apphelpers.StandardAppHelper
import android.tools.flicker.assertions.SubjectsParser
import android.tools.flicker.subject.events.EventLogSubject
import android.tools.flicker.subject.layers.LayerTraceEntrySubject
@@ -104,8 +103,8 @@ abstract class BubbleFlickerTestBase : BubbleFlickerSubjects {
     */
    override val isGesturalNavBar = tapl.navigationModel == NavigationModel.ZERO_BUTTON

    override val testApp: StandardAppHelper
        get() = CollapseBubbleViaBackTest.testApp
    override val testApp
        get() = BubbleFlickerTestBase.testApp

    /**
     * Initialize subjects inherited from [FlickerSubject].
+23 −54
Original line number Diff line number Diff line
@@ -19,11 +19,10 @@ package com.android.wm.shell.flicker.bubbles
import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.RequiresDevice
import android.platform.test.annotations.RequiresFlagsEnabled
import android.tools.flicker.subject.events.EventLogSubject
import android.tools.traces.component.ComponentNameMatcher.Companion.LAUNCHER
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.wm.shell.Flags
import com.android.wm.shell.flicker.bubbles.testcase.BubbleStackAlwaysVisibleTestCases
import com.android.wm.shell.flicker.bubbles.testcase.BubbleAppBecomesNotExpandedTestCases
import com.android.wm.shell.flicker.bubbles.utils.FlickerPropertyInitializer
import com.android.wm.shell.flicker.bubbles.utils.RecordTraceWithTransitionRule
import com.android.wm.shell.flicker.bubbles.utils.collapseBubbleViaBackKey
@@ -53,14 +52,34 @@ import org.junit.runners.MethodSorters
 * Verified tests:
 * - [BubbleFlickerTestBase]
 * - [BubbleStackAlwaysVisibleTestCases]
 * - The focus changes to [LAUNCHER] from [testApp] and [LAUNCHER] becomes the top window
 * - [BubbleAppBecomesNotExpandedTestCases]
 */
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE)
@RunWith(AndroidJUnit4::class)
@RequiresDevice
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Presubmit
class CollapseBubbleViaBackTest : BubbleFlickerTestBase(), BubbleStackAlwaysVisibleTestCases {
class CollapseBubbleViaBackTest :
    BubbleFlickerTestBase(),
    BubbleStackAlwaysVisibleTestCases,
    BubbleAppBecomesNotExpandedTestCases
{

    /**
     * Verifies bubble app window becomes invisible at the end of the transition.
     */
    @Test
    fun appWindowIsInvisibleAtEnd() {
        wmStateSubjectAtEnd.isAppWindowInvisible(testApp)
    }

    /**
     * Verifies bubble app layer becomes invisible at the end of the transition.
     */
    @Test
    fun appLayerIsInvisibleAtEnd() {
        layerTraceEntrySubjectAtEnd.isInvisible(testApp, mustExist = true)
    }

    companion object : FlickerPropertyInitializer() {

@@ -78,54 +97,4 @@ class CollapseBubbleViaBackTest : BubbleFlickerTestBase(), BubbleStackAlwaysVisi

    override val traceDataReader
        get() = recordTraceWithTransitionRule.reader

// region launcher related tests

    /**
     * Verifies the focus changed from launcher to [testApp].
     */
    @Test
    fun focusChanges() {
        EventLogSubject(
            traceDataReader.readEventLogTrace() ?: error("Failed to read event log"),
            traceDataReader
        ).focusChanges(
            testApp.toWindowName(),
            LAUNCHER.toWindowName(),
        )
    }

    /**
     * Verifies the [testApp] replaces launcher to be the top window.
     */
    @Test
    fun launcherWindowReplacesTestAppAsTopWindow() {
        wmTraceSubject
            .isAppWindowOnTop(testApp)
            .then()
            .isAppWindowOnTop(LAUNCHER)
            .forAllEntries()
    }

    /**
     * Verifies [LAUNCHER] is the top window at the end of transition.
     */
    @Test
    fun launcherWindowAsTopWindowAtEnd() {
        wmStateSubjectAtEnd.isAppWindowOnTop(LAUNCHER)
    }

    /**
     * Verifies the [LAUNCHER] becomes the top window.
     */
    @Test
    fun launcherWindowBecomesTopWindow() {
        wmTraceSubject
            .isAppWindowNotOnTop(LAUNCHER)
            .then()
            .isAppWindowOnTop(LAUNCHER)
            .forAllEntries()
    }

// endregion
}
 No newline at end of file
+167 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.bubbles

import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.RequiresDevice
import android.platform.test.annotations.RequiresFlagsEnabled
import android.tools.traces.component.ComponentNameMatcher.Companion.BUBBLE
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.wm.shell.Flags
import com.android.wm.shell.flicker.bubbles.testcase.BubbleAppBecomesNotExpandedTestCases
import com.android.wm.shell.flicker.bubbles.utils.FlickerPropertyInitializer
import com.android.wm.shell.flicker.bubbles.utils.RecordTraceWithTransitionRule
import com.android.wm.shell.flicker.bubbles.utils.dismissBubbleViaBubbleView
import com.android.wm.shell.flicker.bubbles.utils.launchBubbleViaBubbleMenu
import com.android.wm.shell.flicker.bubbles.utils.setUpBeforeTransition
import org.junit.Assume.assumeFalse
import org.junit.Before
import org.junit.ClassRule
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters

/**
 * Test dismiss bubble via dragging bubble to the dismiss view when the bubble is in expanded state.
 *
 * To run this test: `atest WMShellExplicitFlickerTestsBubbles:DismissExpandedBubbleTest`
 *
 * Pre-steps:
 * ```
 *     Launch [simpleApp] into bubble
 * ```
 *
 * Actions:
 * ```
 *     Dismiss bubble via dragging bubble icon to the dismiss view
 * ```
 * Verified tests:
 * - [BubbleFlickerTestBase]
 * - [BubbleAppBecomesNotExpandedTestCases]
 * - [BUBBLE] is visible and then disappear
 */
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE)
@RunWith(AndroidJUnit4::class)
@RequiresDevice
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Presubmit
class DismissExpandedBubbleViaBubbleViewTest :
    BubbleFlickerTestBase(),
    BubbleAppBecomesNotExpandedTestCases
{

    companion object : FlickerPropertyInitializer() {

        @ClassRule
        @JvmField
        val recordTraceWithTransitionRule = RecordTraceWithTransitionRule(
            setUpBeforeTransition = {
                setUpBeforeTransition(instrumentation, wmHelper)
                launchBubbleViaBubbleMenu(testApp, tapl, wmHelper)
            },
            transition = { dismissBubbleViaBubbleView(uiDevice, wmHelper) }
        )
    }

    override val traceDataReader
        get() = recordTraceWithTransitionRule.reader

    // TODO(b/396020056): Verify expand bubble with bubble bar.
    @Before
    fun setUp() {
        assumeFalse(tapl.isTablet)
    }

// region Bubble stack related tests

    /**
     * Verifies [BUBBLE] window is gone at the end of the transition.
     */
    @Test
    fun bubbleWindowIsGoneAtEnd() {
        wmStateSubjectAtEnd.notContains(BUBBLE)
    }

    /**
     * Verifies [BUBBLE] layer is gone at the end of the transition.
     */
    @Test
    fun bubbleLayerIsGoneAtEnd() {
        layerTraceEntrySubjectAtEnd.notContains(BUBBLE)
    }

    /**
     * Verifies [BUBBLE] window was visible then disappear.
     */
    @Test
    fun bubbleWindowWasVisibleThenDisappear() {
        wmTraceSubject
            .isAboveAppWindowVisible(BUBBLE)
            .then()
            // bubble stack may be invisible before it's gone.
            .isAboveAppWindowInvisible(BUBBLE, isOptional = true)
            .notContains(BUBBLE)
            .forAllEntries()
    }

    /**
     * Verifies [BUBBLE] layer was visible then disappear.
     */
    @Test
    fun bubbleLayerWasVisibleThenDisappear() {
        layersTraceSubject
            .isVisible(BUBBLE)
            .then()
            // bubble stack may be invisible before it's gone.
            .isInvisible(BUBBLE, mustExist = true, isOptional = true)
            .then()
            .notContains(BUBBLE)
            .forAllEntries()
    }

// endregion

// region bubble app related tests

    /**
     * Verifies the [testApp] window has rounded corner at the start of the transition.
     */
    @Test
    fun appWindowHasRoundedCornerAtStart() {
        layerTraceEntrySubjectAtStart.hasRoundedCorners(testApp)
    }

    /**
     * Verifies bubble app window is gone at the end of the transition.
     */
    @Test
    fun appWindowIsGoneAtEnd() {
        wmStateSubjectAtEnd.notContains(testApp)
    }

    /**
     * Verifies bubble app layer is gone at the end of the transition.
     */
    @Test
    fun appLayerIsGoneAtEnd() {
        // TestApp may be gone if it's in dismissed state.
        layerTraceEntrySubjectAtEnd.notContains(testApp)
    }

// endregion
}
 No newline at end of file
Loading