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

Commit b504a04e authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Test launching app to bubble using task trampoline" into main

parents cd5c50af 877bb138
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ test_module_config {
        "com.android.wm.shell.flicker.bubbles.DismissExpandedBubbleViaBubbleBarTest",
        "com.android.wm.shell.flicker.bubbles.DismissExpandedBubbleViaBubbleViewTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleFromHomeScreenTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleFromHomeScreenTrampolineTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleViaBubbleMenuTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleViaDragToBubbleBarTest",
        "com.android.wm.shell.flicker.bubbles.EnterBubbleViaOverflowMenuTest",
@@ -157,6 +158,13 @@ test_module_config {
    include_filters: ["com.android.wm.shell.flicker.bubbles.EnterBubbleFromHomeScreenTest"],
}

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

test_module_config {
    name: "WMShellExplicitFlickerTestsBubbles-EnterBubbleViaBubbleMenuTest",
    base: "WMShellExplicitFlickerTestsBubbles",
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@
      "name": "WMShellExplicitFlickerTestsBubbles-EnterBubbleFromHomeScreenTest",
      "keywords": ["device"]
    },
    {
      "name": "WMShellExplicitFlickerTestsBubbles-EnterBubbleFromHomeScreenTrampolineTest",
      "keywords": ["device"]
    },
    {
      "name": "WMShellExplicitFlickerTestsBubbles-EnterBubbleViaBubbleMenuTest",
      "keywords": ["device"]
+46 −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.tools.device.apphelpers.StandardAppHelper
import android.tools.traces.parsers.toFlickerComponent
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions

/**
 * The base class for Bubble flicker tests that bubble an app that launches via a trampoline task
 */
abstract class BubbleFlickerTrampolineTestBase : BubbleFlickerTestBase() {

    override val testApp = trampolineFinishApp

    companion object {
        val trampolineStartingApp: StandardAppHelper =
            SimpleAppHelper(
                instrumentation,
                launcherName = ActivityOptions.TrampolineStartActivity.LABEL,
                component = ActivityOptions.TrampolineStartActivity.COMPONENT.toFlickerComponent(),
            )

        val trampolineFinishApp: StandardAppHelper =
            SimpleAppHelper(
                instrumentation,
                launcherName = ActivityOptions.TrampolineFinishActivity.LABEL,
                component = ActivityOptions.TrampolineFinishActivity.COMPONENT.toFlickerComponent(),
            )
    }
}
+88 −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.RecordTraceWithTransitionRule
import org.junit.FixMethodOrder
import org.junit.Rule
import org.junit.runners.MethodSorters

/**
 * Test entering bubble for an app that launches via trampoline task. Bubble is launched via
 * clicking bubble menu from the home screen.
 *
 * To run this test:
 *     `atest WMShellExplicitFlickerTestsBubbles:EnterBubbleFromHomeScreenTrampolineTest`
 *
 * Actions:
 * ```
 *     Long press [TrampolineStartActivity] icon on the home screen to show [AppIconMenu].
 *     Click the bubble menu to launch [TrampolineStartActivity] into bubble.
 * ```
 *
 * Verified tests:
 * - [BubbleFlickerTestBase]
 * - [EnterBubbleTestCases]
 */
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE)
@RequiresDevice
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Presubmit
open class EnterBubbleFromHomeScreenTrampolineTest :
    BubbleFlickerTrampolineTestBase(), EnterBubbleTestCases {

    companion object {
        private val recordTraceWithTransitionRule =
            RecordTraceWithTransitionRule(
                transition = {
                    launchBubbleViaBubbleMenu(
                        trampolineStartingApp,
                        tapl,
                        wmHelper,
                        FROM_HOME_SCREEN,
                    )
                },
                tearDownAfterTransition = {
                    trampolineFinishApp.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(trampolineStartingApp.appName)
                    tapl.workspace.deleteAppIcon(testAppIcon)
                },
            )

        private val navBar = NavBar.MODE_GESTURAL
    }

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

    override val traceDataReader
        get() = recordTraceWithTransitionRule.reader
}
+2 −2
Original line number Diff line number Diff line
@@ -412,7 +412,7 @@
        <activity
            android:name=".TrampolineStartActivity"
            android:exported="true"
            android:label=".TrampolineStartActivity">
            android:label="TrampolineStartActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER"/>
@@ -421,7 +421,7 @@
        <activity
            android:name=".TrampolineFinishActivity"
            android:exported="true"
            android:label=".TrampolineFinishActivity" />
            android:label="TrampolineFinishActivity" />
        <activity
            android:name=".ScrollToFinishActivity"
            android:exported="true"