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

Commit 5e065feb authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix getTaskId when BubbleTaskViewListener is enabled." into main

parents 7ccc5d9c c68008ed
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ android_robolectric_test {
        "androidx.test.ext.junit",
        "mockito-robolectric-prebuilt",
        "mockito-kotlin2",
        "platform-parametric-runner-lib",
        "truth",
        "flag-junit-base",
        "flag-junit",
@@ -74,6 +75,7 @@ android_test {
        "frameworks-base-testutils",
        "mockito-kotlin2",
        "mockito-target-extended-minus-junit4",
        "platform-parametric-runner-lib",
        "truth",
        "platform-test-annotations",
        "platform-test-rules",
+73 −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.bubbles

import android.content.ComponentName
import android.content.Context
import android.platform.test.flag.junit.FlagsParameterization
import android.platform.test.flag.junit.SetFlagsRule
import androidx.test.core.app.ApplicationProvider
import androidx.test.filters.SmallTest
import com.android.wm.shell.Flags
import com.android.wm.shell.taskview.TaskView
import com.google.common.truth.Truth.assertThat
import com.google.common.util.concurrent.MoreExecutors.directExecutor
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.mock
import platform.test.runner.parameterized.ParameterizedAndroidJunit4
import platform.test.runner.parameterized.Parameters

/** Tests for [BubbleExpandedView] */
@SmallTest
@RunWith(ParameterizedAndroidJunit4::class)
class BubbleExpandedViewTest(flags: FlagsParameterization) {

    @get:Rule
    val setFlagsRule = SetFlagsRule(flags)

    private val context = ApplicationProvider.getApplicationContext<Context>()
    private val componentName = ComponentName(context, "TestClass")

    @Test
    fun getTaskId_onTaskCreated_returnsCorrectTaskId() {
        val bubbleTaskView = BubbleTaskView(mock<TaskView>(), directExecutor())
        val expandedView = BubbleExpandedView(context).apply {
            initialize(
                mock<BubbleExpandedViewManager>(),
                mock<BubbleStackView>(),
                mock<BubblePositioner>(),
                false /* isOverflow */,
                bubbleTaskView,
            )
            setAnimating(true) // Skips setContentVisibility for testing.
        }

        bubbleTaskView.listener.onTaskCreated(123, componentName)

        assertThat(expandedView.getTaskId()).isEqualTo(123)
    }

    companion object {
        @JvmStatic
        @Parameters(name = "{0}")
        fun getParams() = FlagsParameterization.allCombinationsOf(
            Flags.FLAG_ENABLE_BUBBLE_TASK_VIEW_LISTENER,
        )
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -467,6 +467,11 @@ public class BubbleExpandedView extends LinearLayout {
                        new BubbleTaskViewListener.Callback() {
                            @Override
                            public void onTaskCreated() {
                                // The taskId is saved to use for removeTask,
                                // preventing appearance in recent tasks.
                                mTaskId = ((BubbleTaskViewListener) mCurrentTaskViewListener)
                                    .getTaskId();

                                setContentVisibility(true);
                            }