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

Commit f0e9f95d authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Verify enter bubble from home screen" into main

parents 039fa2cf ec866739
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ test_module_config {
        "com.android.wm.shell.flicker.bubbles.DismissExpandedBubbleViaBubbleBarTest",
        "com.android.wm.shell.flicker.bubbles.DismissExpandedBubbleViaBubbleBarHandleTest",
        "com.android.wm.shell.flicker.bubbles.DismissExpandedBubbleViaBubbleViewTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleFromHomeScreenTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleViaBubbleMenuTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleViaDragToBubbleBarTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleViaOverflowMenuTest",
@@ -131,6 +132,13 @@ test_module_config {
    include_filters: ["com.android.wm.shell.flicker.bubbles.EnterBubbleViaBubbleMenuTest"],
}

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

test_module_config {
    name: "WMShellExplicitFlickerTestsBubbles-EnterBubbleViaDragToBubbleBarTest",
    base: "WMShellExplicitFlickerTestsBubbles",
+3 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@
    {
      "name": "WMShellExplicitFlickerTestsBubbles-EnterBubbleViaBubbleMenuTest"
    },
    {
      "name": "WMShellExplicitFlickerTestsBubbles-EnterBubbleFromHomeScreenTest"
    },
    {
      "name": "WMShellExplicitFlickerTestsBubbles-EnterBubbleViaDragToBubbleBarTest"
    },
+84 −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.RequiresFlagsEnabled
import android.tools.NavBar
import androidx.test.filters.RequiresDevice
import com.android.wm.shell.Flags
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.bubbles.testcase.EnterBubbleTestCases
import com.android.wm.shell.flicker.bubbles.utils.ApplyPerParameterRule
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.BubbleLaunchSource.FROM_HOME_SCREEN
import com.android.wm.shell.flicker.bubbles.utils.BubbleFlickerTestHelper.launchBubbleViaBubbleMenu
import com.android.wm.shell.flicker.bubbles.utils.FlickerPropertyInitializer
import com.android.wm.shell.flicker.bubbles.utils.RecordTraceWithTransitionRule
import org.junit.FixMethodOrder
import org.junit.Rule
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Test entering bubble via clicking bubble menu from the home screen.
 *
 * To run this test: `atest WMShellExplicitFlickerTestsBubbles:EnterBubbleFromHomeScreenTest`
 *
 * Actions:
 * ```
 *     Long press [simpleApp] icon on the home screen to show [AppIconMenu].
 *     Click the bubble menu to launch [simpleApp] into bubble.
 * ```
 * Verified tests:
 * - [BubbleFlickerTestBase]
 * - [EnterBubbleTestCases]
 */
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE)
@RequiresDevice
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Presubmit
@RunWith(Parameterized::class)
open class EnterBubbleFromHomeScreenTest(navBar: NavBar) : BubbleFlickerTestBase(),
    EnterBubbleTestCases {

    companion object : FlickerPropertyInitializer() {
        private val recordTraceWithTransitionRule = RecordTraceWithTransitionRule(
            transition = { launchBubbleViaBubbleMenu(testApp, tapl, wmHelper, FROM_HOME_SCREEN) },
            tearDownAfterTransition = {
                testApp.exit(wmHelper)
                // Clean up the app icon that might have been added to the home screen during the
                // test transition.
                val testAppIcon = tapl.workspace.getWorkspaceAppIcon(testApp.appName)
                tapl.workspace.deleteAppIcon(testAppIcon)
            }
        )

        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun data(): List<NavBar> = listOf(NavBar.MODE_GESTURAL)
    }

    @get:Rule
    open val setUpRule = ApplyPerParameterRule(
        Utils.testSetupRule(navBar).around(recordTraceWithTransitionRule),
        params = arrayOf(navBar)
    )

    override val traceDataReader
        get() = recordTraceWithTransitionRule.reader
}
+9 −8
Original line number Diff line number Diff line
@@ -87,14 +87,12 @@ internal object BubbleFlickerTestHelper {
                    // If there's an icon on the homeScreen, just use it.
                    homeScreenIcon
                } else {
                    // Here we do a trick:
                    // We move the app icon from all apps to hotseat, and then drag it to a new
                    // created empty page of home screen.
                    SplitScreenUtils.createShortcutOnHotseatIfNotExist(tapl, appName)
                    val hotseatIcon = workspace.getHotseatAppIcon(appName)
                    val pageDelta = workspace.pageCount - workspace.currentPage
                    workspace.dragIcon(hotseatIcon, pageDelta)
                    workspace.getWorkspaceAppIcon(appName)
                    // If not, create a shortcut on the workspace by dragging it from all apps.
                    workspace
                        .switchToAllApps()
                        .getAppIcon(appName)
                        .dragToWorkspace(false /* startActivity */, false /* isWidgetShortcut */)
                    tapl.workspace.getWorkspaceAppIcon(appName)
                }
            }
        }
@@ -328,8 +326,11 @@ internal object BubbleFlickerTestHelper {
        }

        if (previousApp != null) {
            // If there's a previous app, the app will be expanded.
            waitAndAssertBubbleAppInExpandedState(testApp, wmHelper)
        } else {
            // Otherwise, if there's no previous app, the bubble bar or floating icon will be
            // dismissed.
            waitAndVerifyBubbleGone(wmHelper)
        }
    }