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

Commit 0daa4841 authored by Charles Chen's avatar Charles Chen
Browse files

Fix LaunchMultipleBubbleTest faliure when running twice

The root cause is that BubbleController#onThemeChanged inflates
the overflow bubbles unexpectedly, which leads to Bubble launch
failure.

If the overfolow bubble is inflated unexpectedly before the bubble
launch, BubbleController thought it's inflated and tried to
select and expand the bubble without updating BubbleData.

This CL fixes the issue by skipping inflation overflow bubbles
for the #onThemeChanged case.

Fix: 430273288
Test: atest LaunchMultipleBubbleTest
Test: atest DismissExpandedBubbleViaBubbleBarTest
Test: atest DismissAllCollapsedBubbleAppsTest
Test: atest WMShellRobolectricTests:BubbleControllerTest
Test: atest WMShellMultivalentTestsOnDevice:BubbleControllerTest
Flag: EXEMPT bugfix
Change-Id: I3ae0959ac50868522cc61a288d5eab25e0c01c44
parent 2a22330b
Loading
Loading
Loading
Loading
+48 −8
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ import com.android.wm.shell.transition.Transitions.TRANSIT_CONVERT_TO_BUBBLE
import com.android.wm.shell.transition.Transitions.TransitionHandler
import com.android.wm.shell.unfold.ShellUnfoldProgressProvider
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import com.google.common.util.concurrent.MoreExecutors.directExecutor
import java.util.Optional
import java.util.concurrent.Executor
@@ -423,8 +424,8 @@ class BubbleControllerTest(flags: FlagsParameterization) {
        getInstrumentation().runOnMainSync {
            bubbleData.notificationEntryUpdated(
                bubble,
                true /* suppressFlyout */,
                true /* showInShade= */,
                true, /* suppressFlyout */
                true, /* showInShade= */
            )
        }

@@ -438,8 +439,8 @@ class BubbleControllerTest(flags: FlagsParameterization) {
        getInstrumentation().runOnMainSync {
            bubbleData.notificationEntryUpdated(
                bubble,
                true /* suppressFlyout */,
                true /* showInShade= */,
                true, /* suppressFlyout */
                true, /* showInShade= */
            )
        }

@@ -452,8 +453,8 @@ class BubbleControllerTest(flags: FlagsParameterization) {
        getInstrumentation().runOnMainSync {
            bubbleData.notificationEntryUpdated(
                bubble,
                true /* suppressFlyout */,
                true /* showInShade= */,
                true, /* suppressFlyout */
                true, /* showInShade= */
            )
        }

@@ -527,8 +528,8 @@ class BubbleControllerTest(flags: FlagsParameterization) {
        getInstrumentation().runOnMainSync {
            bubbleData.notificationEntryUpdated(
                bubble,
                true /* suppressFlyout */,
                true /* showInShade= */,
                true, /* suppressFlyout */
                true, /* showInShade= */
            )
        }

@@ -859,6 +860,45 @@ class BubbleControllerTest(flags: FlagsParameterization) {
        assertThat(bubbleController.layerView!!.visibility).isEqualTo(View.INVISIBLE)
    }

    @Test
    fun testOnThemeChanged_skipInflationForOverflowBubbles() {
        val taskInfo1 = ActivityManager.RunningTaskInfo().apply {
            taskId = 123
            baseActivity = COMPONENT
        }
        val bubble = createAppBubble(taskInfo1)
        val taskInfo2 = ActivityManager.RunningTaskInfo().apply {
            taskId = 124
            baseActivity = COMPONENT
        }
        val overflowBubble = createAppBubble(taskInfo2)
        getInstrumentation().runOnMainSync {
            bubbleController.inflateAndAdd(
                bubble,
                /* suppressFlyout= */ true,
                /* showInShade= */ true
            )
            bubbleController.inflateAndAdd(
                overflowBubble,
                /* suppressFlyout= */ true,
                /* showInShade= */ true
            )
            bubbleController.dismissBubble(overflowBubble, DISMISS_USER_GESTURE)
        }

        assertThat(bubbleData.hasBubbles()).isTrue()
        assertThat(bubbleData.hasOverflowBubbles()).isTrue()
        assertWithMessage("Overflow bubble should not be inflated since it's dismissed")
            .that(overflowBubble.isInflated).isFalse()

        getInstrumentation().runOnMainSync {
            bubbleController.onThemeChanged()
        }

        assertWithMessage("Overflow bubble should not be inflated even if #onThemeChanged")
            .that(overflowBubble.isInflated).isFalse()
    }

    private fun createBubble(key: String, taskId: Int = 0): Bubble {
        val icon = Icon.createWithResource(context.resources, R.drawable.bubble_ic_overflow_button)
        val shortcutInfo = ShortcutInfo.Builder(context, "fakeId").setIcon(icon).build()
+1 −1
Original line number Diff line number Diff line
@@ -1374,7 +1374,7 @@ public class BubbleController implements ConfigurationChangeListener,
                    mLayerView,
                    mBubbleIconFactory,
                    mAppInfoProvider,
                    false /* skipInflation */);
                    true /* skipInflation */);
        }
    }

+0 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.RequiresFlagsEnabled
import android.tools.NavBar
import android.tools.device.apphelpers.MessagingAppHelper
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import com.android.wm.shell.Flags
import com.android.wm.shell.Utils
@@ -56,7 +55,6 @@ import org.junit.runners.Parameterized
 * - [BubbleFlickerTestBase]
 * - [BubbleDismissesTestCases]
 */
@FlakyTest(bugId = 430273288)
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE)
@RequiresDevice
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+0 −2
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.tools.NavBar
import android.tools.device.apphelpers.MessagingAppHelper
import android.tools.traces.component.ComponentNameMatcher.Companion.LAUNCHER
import android.tools.traces.component.IComponentNameMatcher
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import com.android.wm.shell.Flags
import com.android.wm.shell.Utils
@@ -65,7 +64,6 @@ import org.junit.runners.Parameterized
 * - [BubbleAlwaysVisibleTestCases]
 * - [BubbleAppBecomesNotExpandedTestCases]
 */
@FlakyTest(bugId = 430273288)
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE, Flags.FLAG_ENABLE_BUBBLE_BAR)
@RequiresDevice
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+0 −2
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.platform.systemui_tapl.ui.Root
import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.RequiresFlagsEnabled
import android.tools.NavBar
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import com.android.wm.shell.Flags
import com.android.wm.shell.Utils
@@ -58,7 +57,6 @@ import org.junit.runners.Parameterized
 * - [BubbleFlickerTestBase]
 * - [MultipleBubbleExpandBubbleAppTestCases]
 */
@FlakyTest(bugId = 430273288)
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE)
@RequiresDevice
@FixMethodOrder(MethodSorters.NAME_ASCENDING)