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

Commit 55445a4b authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Track bubble app sessions

This change refactors BubbleSessionTracker to support logging session
duration per app. Also wire up the new events.

Bug: 438484702
Flag: EXEMPT new metric events
Test: atest BubbleSessionTrackerImplTest
Test: atest BubbleControllerTest
Test: atest BubbleControllerBubbleBarTest
Change-Id: Iece811e5e7615933d4338b14aab3d1a3224a7aa7
parent 452a02b8
Loading
Loading
Loading
Loading
+39 −17
Original line number Diff line number Diff line
@@ -271,11 +271,15 @@ class BubbleControllerBubbleBarTest {
        }
        // Log bubble dismissed via drag and there's a switch event
        assertThat(bubbleData.selectedBubbleKey).isEqualTo("key1")
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(2)
        assertThat(uiEventLoggerFake.eventId(0))
            .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_DRAG_BUBBLE.id)
        assertThat(uiEventLoggerFake.eventId(1))
            .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_BUBBLE_SWITCHED.id)
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(4)
        assertThat(uiEventLoggerFake.logs.map { it.eventId })
            .containsExactly(
                BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_DRAG_BUBBLE.id,
                BubbleLogger.Event.BUBBLE_BAR_BUBBLE_SWITCHED.id,
                BubbleLogger.Event.BUBBLE_BAR_SESSION_SWITCHED_FROM.id,
                BubbleLogger.Event.BUBBLE_BAR_SESSION_SWITCHED_TO.id
            )
            .inOrder()
    }

    @Test
@@ -350,28 +354,41 @@ class BubbleControllerBubbleBarTest {

        expandAndSelectBubble("key")

        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
        assertThat(uiEventLoggerFake.eventId(0))
            .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_EXPANDED.id)
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(2)
        assertThat(uiEventLoggerFake.logs.map { it.eventId })
            .containsExactly(
                BubbleLogger.Event.BUBBLE_BAR_EXPANDED.id,
                BubbleLogger.Event.BUBBLE_BAR_SESSION_STARTED.id
            )
            .inOrder()
        uiEventLoggerFake.logs.clear()

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

        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
        assertThat(uiEventLoggerFake.eventId(0))
            .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_COLLAPSED.id)
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(2)
        assertThat(uiEventLoggerFake.logs.map { it.eventId })
            .containsExactly(
                BubbleLogger.Event.BUBBLE_BAR_COLLAPSED.id,
                BubbleLogger.Event.BUBBLE_BAR_SESSION_ENDED.id
            )
            .inOrder()
    }

    @Test
    fun testEventLogging_bubbleBar_autoExpandingBubble() {
        addBubble("key", autoExpand = true)

        // 2 events: add bubble + expand
        // 3 events: add bubble + expand + session started
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(3)
        assertThat(uiEventLoggerFake.eventId(1))
            .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_EXPANDED.id)
        assertThat(uiEventLoggerFake.logs.map { it.eventId })
            .containsExactly(
                BubbleLogger.Event.BUBBLE_BAR_BUBBLE_POSTED.id,
                BubbleLogger.Event.BUBBLE_BAR_EXPANDED.id,
                BubbleLogger.Event.BUBBLE_BAR_SESSION_STARTED.id
            )
            .inOrder()
    }

    @Test
@@ -385,9 +402,14 @@ class BubbleControllerBubbleBarTest {
        // Select the next bubble
        expandAndSelectBubble("key1")

        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
        assertThat(uiEventLoggerFake.eventId(0))
            .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_BUBBLE_SWITCHED.id)
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(3)
        assertThat(uiEventLoggerFake.logs.map { it.eventId })
            .containsExactly(
                BubbleLogger.Event.BUBBLE_BAR_BUBBLE_SWITCHED.id,
                BubbleLogger.Event.BUBBLE_BAR_SESSION_SWITCHED_FROM.id,
                BubbleLogger.Event.BUBBLE_BAR_SESSION_SWITCHED_TO.id
            )
            .inOrder()
    }

    @Test
+0 −67
Original line number Diff line number Diff line
@@ -905,73 +905,6 @@ class BubbleControllerTest(flags: FlagsParameterization) {
            .that(overflowBubble.isInflated).isFalse()
    }

    @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
    @Test
    fun bubbleBarSessionTracked() {
        // switch to bubble bar
        bubblePositioner.update(deviceConfigUnfolded)
        bubblePositioner.isShowingInBubbleBar = true
        getInstrumentation().runOnMainSync {
            bubbleController.setLauncherHasBubbleBar(true)
            bubbleController.registerBubbleStateListener(FakeBubblesStateListener())
        }

        val bubble = createBubble("key")
        bubble.setShouldAutoExpand(true)
        getInstrumentation().runOnMainSync {
            bubbleController.inflateAndAdd(
                bubble,
                /* suppressFlyout= */ true,
                /* showInShade= */ true
            )
        }

        assertThat(bubbleData.isExpanded).isTrue()

        val sessionStartEvent = uiEventLoggerFake.logs.single {
            it.eventId == BubbleLogger.Event.BUBBLE_BAR_SESSION_STARTED.id
        }

        getInstrumentation().runOnMainSync {
            bubbleController.collapseStack()
            mainExecutor.flushAll()
        }

        val sessionEndEvent = uiEventLoggerFake.logs.single {
            it.eventId == BubbleLogger.Event.BUBBLE_BAR_SESSION_ENDED.id
        }
        assertThat(sessionStartEvent.instanceId).isEqualTo(sessionEndEvent.instanceId)
    }

    @Test
    fun floatingBubbleSessionTracked() {
        val bubble = createBubble("key")
        bubble.setShouldAutoExpand(true)
        getInstrumentation().runOnMainSync {
            bubbleController.inflateAndAdd(
                bubble,
                /* suppressFlyout= */ true,
                /* showInShade= */ true
            )
        }

        assertThat(bubbleData.isExpanded).isTrue()

        val sessionStartEvent = uiEventLoggerFake.logs.single {
            it.eventId == BubbleLogger.Event.BUBBLE_SESSION_STARTED.id
        }

        getInstrumentation().runOnMainSync {
            bubbleController.collapseStack()
            mainExecutor.flushAll()
        }

        val sessionEndEvent = uiEventLoggerFake.logs.single {
            it.eventId == BubbleLogger.Event.BUBBLE_SESSION_ENDED.id
        }
        assertThat(sessionStartEvent.instanceId).isEqualTo(sessionEndEvent.instanceId)
    }

    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()
+86 −10
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
import com.android.internal.logging.InstanceIdSequence
import com.android.internal.logging.testing.UiEventLoggerFake
import com.android.internal.protolog.ProtoLog
import com.android.launcher3.icons.BubbleIconFactory
@@ -43,6 +44,8 @@ import com.android.wm.shell.bubbles.BubbleStackView.SurfaceSynchronizer
import com.android.wm.shell.bubbles.Bubbles.BubbleExpandListener
import com.android.wm.shell.bubbles.Bubbles.SysuiProxy
import com.android.wm.shell.bubbles.animation.AnimatableScaleMatrix
import com.android.wm.shell.bubbles.logging.BubbleSessionTracker
import com.android.wm.shell.bubbles.logging.BubbleSessionTrackerImpl
import com.android.wm.shell.common.FloatingContentCoordinator
import com.android.wm.shell.common.TestShellExecutor
import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils
@@ -72,6 +75,7 @@ class BubbleStackViewTest {
    @get:Rule val animatorTestRule: AnimatorTestRule = AnimatorTestRule(this)

    private val context = ApplicationProvider.getApplicationContext<Context>()
    private val uiEventLoggerFake = UiEventLoggerFake()
    private lateinit var positioner: BubblePositioner
    private lateinit var bubbleLogger: BubbleLogger
    private lateinit var iconFactory: BubbleIconFactory
@@ -83,7 +87,8 @@ class BubbleStackViewTest {
    private lateinit var bubbleData: BubbleData
    private lateinit var bubbleStackViewManager: FakeBubbleStackViewManager
    private lateinit var surfaceSynchronizer: FakeSurfaceSynchronizer
    private var sysuiProxy = mock<SysuiProxy>()
    private lateinit var sessionTracker: BubbleSessionTracker
    private val sysuiProxy = mock<SysuiProxy>()

    @Before
    fun setUp() {
@@ -91,7 +96,7 @@ class BubbleStackViewTest {
        // Disable protolog tool when running the tests from studio
        ProtoLog.REQUIRE_PROTOLOGTOOL = false
        shellExecutor = TestShellExecutor()
        windowManager = context.getSystemService(WindowManager::class.java)
        windowManager = context.getSystemService(WindowManager::class.java)!!
        iconFactory =
            BubbleIconFactory(
                context,
@@ -103,7 +108,9 @@ class BubbleStackViewTest {
                )
            )
        positioner = BubblePositioner(context, windowManager)
        bubbleLogger = BubbleLogger(UiEventLoggerFake())
        bubbleLogger = BubbleLogger(uiEventLoggerFake)
        val instanceIdSequence = InstanceIdSequence(/* instanceIdMax= */ 10)
        sessionTracker = BubbleSessionTrackerImpl(instanceIdSequence, bubbleLogger)
        bubbleData =
            BubbleData(
                context,
@@ -126,7 +133,8 @@ class BubbleStackViewTest {
                surfaceSynchronizer,
                FloatingContentCoordinator(),
                { sysuiProxy },
                shellExecutor
                shellExecutor,
                sessionTracker,
            )

        context
@@ -191,6 +199,7 @@ class BubbleStackViewTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
        }

        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -214,6 +223,7 @@ class BubbleStackViewTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
        }

        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -247,6 +257,7 @@ class BubbleStackViewTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
        }

        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -277,6 +288,7 @@ class BubbleStackViewTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
        }

        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -305,6 +317,7 @@ class BubbleStackViewTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
        }

        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -353,6 +366,7 @@ class BubbleStackViewTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
        }

        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -398,6 +412,7 @@ class BubbleStackViewTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
        }

        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -427,6 +442,7 @@ class BubbleStackViewTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
        }

        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -682,7 +698,8 @@ class BubbleStackViewTest {
                        null,
                        FloatingContentCoordinator(),
                        { sysuiProxy },
                        shellExecutor
                        shellExecutor,
                        sessionTracker,
                )

        assertThat(bubbleData.overflowBubbles).isEmpty()
@@ -709,7 +726,8 @@ class BubbleStackViewTest {
                        null,
                        FloatingContentCoordinator(),
                        { sysuiProxy },
                        shellExecutor
                        shellExecutor,
                        sessionTracker,
                )
        val bubbleOverflow = bubbleData.overflow
        assertThat(bubbleStackView.getBubbleIndex(bubbleOverflow)).isGreaterThan(-1)
@@ -728,7 +746,8 @@ class BubbleStackViewTest {
                            null,
                            FloatingContentCoordinator(),
                            { sysuiProxy },
                            shellExecutor
                            shellExecutor,
                            sessionTracker,
                    )
        }
        assertThat(bubbleData.overflowBubbles).isEmpty()
@@ -1020,7 +1039,8 @@ class BubbleStackViewTest {
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble1)
            bubbleStackView.addBubble(bubble2)
            bubbleStackView.setExpanded(true)
            bubbleStackView.setSelectedBubble(bubble2)
            bubbleStackView.isExpanded = true
            shellExecutor.flushAll()
        }
        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -1061,6 +1081,7 @@ class BubbleStackViewTest {
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble1)
            bubbleStackView.addBubble(bubble2)
            bubbleStackView.setSelectedBubble(bubble2)
            bubbleStackView.setExpanded(true)
            shellExecutor.flushAll()
        }
@@ -1099,7 +1120,8 @@ class BubbleStackViewTest {
        val bubble = createAndInflateBubble()
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setExpanded(true)
            bubbleStackView.setSelectedBubble(bubble)
            bubbleStackView.isExpanded = true
            shellExecutor.flushAll()
        }
        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -1134,7 +1156,8 @@ class BubbleStackViewTest {
        val bubble = createAndInflateBubble()
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setExpanded(true)
            bubbleStackView.setSelectedBubble(bubble)
            bubbleStackView.isExpanded = true
            shellExecutor.flushAll()
        }
        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -1155,6 +1178,9 @@ class BubbleStackViewTest {
            // Add the same bubble back
            bubbleData.notificationEntryUpdated(bubble, false, true)
            bubbleStackView.addBubble(bubble)
            bubbleStackView.setSelectedBubble(bubble)
            // let the scrim animation finish
            animatorTestRule.advanceTimeBy(300)
            shellExecutor.flushAll()
        }
        InstrumentationRegistry.getInstrumentation().waitForIdleSync()
@@ -1170,6 +1196,56 @@ class BubbleStackViewTest {
        assertThat(bubbleStackView.bubbleCount).isEqualTo(1)
    }

    @Test
    fun sessionEventsLogged() {
        val bubble1 = createAndInflateChatBubble("key1")
        val bubble2 = createAndInflateChatBubble("key2")
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.addBubble(bubble1)
            bubbleStackView.addBubble(bubble2)
            bubbleStackView.setSelectedBubble(bubble2)
            bubbleStackView.isExpanded = true
            shellExecutor.flushAll()
        }
        InstrumentationRegistry.getInstrumentation().waitForIdleSync()

        val sessionStartEvent = uiEventLoggerFake.logs.single {
            it.eventId == BubbleLogger.Event.BUBBLE_SESSION_STARTED.id
        }

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.setSelectedBubble(bubble1)
            shellExecutor.flushAll()
        }
        InstrumentationRegistry.getInstrumentation().waitForIdleSync()

        val sessionSwitchedFromEvent = uiEventLoggerFake.logs.single {
            it.eventId == BubbleLogger.Event.BUBBLE_SESSION_SWITCHED_FROM.id
        }
        val sessionSwitchedToEvent = uiEventLoggerFake.logs.single {
            it.eventId == BubbleLogger.Event.BUBBLE_SESSION_SWITCHED_TO.id
        }

        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            bubbleStackView.isExpanded = false
            shellExecutor.flushAll()
        }
        InstrumentationRegistry.getInstrumentation().waitForIdleSync()

        val sessionEndEvent = uiEventLoggerFake.logs.single {
            it.eventId == BubbleLogger.Event.BUBBLE_SESSION_ENDED.id
        }

        val sessionInstanceIds =
            setOf(
                sessionStartEvent.instanceId,
                sessionSwitchedFromEvent.instanceId,
                sessionSwitchedToEvent.instanceId,
                sessionEndEvent.instanceId
            )
        assertThat(sessionInstanceIds).hasSize(1)
    }

    private fun createAndInflateChatBubble(key: String): Bubble {
        val icon = Icon.createWithResource(context.resources, R.drawable.bubble_ic_overflow_button)
        val shortcutInfo = ShortcutInfo.Builder(context, "fakeId").setIcon(icon).build()
+82 −12
Original line number Diff line number Diff line
@@ -25,8 +25,13 @@ import com.android.internal.protolog.ProtoLog
import com.android.wm.shell.bubbles.BubbleLogger
import com.android.wm.shell.bubbles.BubbleLogger.Event.BUBBLE_BAR_SESSION_ENDED
import com.android.wm.shell.bubbles.BubbleLogger.Event.BUBBLE_BAR_SESSION_STARTED
import com.android.wm.shell.bubbles.BubbleLogger.Event.BUBBLE_BAR_SESSION_SWITCHED_FROM
import com.android.wm.shell.bubbles.BubbleLogger.Event.BUBBLE_BAR_SESSION_SWITCHED_TO
import com.android.wm.shell.bubbles.BubbleLogger.Event.BUBBLE_SESSION_ENDED
import com.android.wm.shell.bubbles.BubbleLogger.Event.BUBBLE_SESSION_STARTED
import com.android.wm.shell.bubbles.BubbleLogger.Event.BUBBLE_SESSION_SWITCHED_FROM
import com.android.wm.shell.bubbles.BubbleLogger.Event.BUBBLE_SESSION_SWITCHED_TO
import com.android.wm.shell.bubbles.logging.BubbleSessionTracker.SessionEvent
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
@@ -50,9 +55,13 @@ class BubbleSessionTrackerImplTest {

    @Test
    fun startSession_logsNewSessionId() {
        bubbleSessionTracker.startBubbleBar()
        bubbleSessionTracker.stopBubbleBar()
        bubbleSessionTracker.startBubbleBar()
        bubbleSessionTracker.log(
            SessionEvent.Started(forBubbleBar = true, selectedBubblePackage = "app.package")
        )
        bubbleSessionTracker.log(SessionEvent.Ended(forBubbleBar = true))
        bubbleSessionTracker.log(
            SessionEvent.Started(forBubbleBar = true, selectedBubblePackage = "app.package")
        )

        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(3)
        val firstSessionStart = uiEventLoggerFake.logs.first()
@@ -64,8 +73,10 @@ class BubbleSessionTrackerImplTest {

    @Test
    fun endSession_logsSameSessionId() {
        bubbleSessionTracker.startBubbleBar()
        bubbleSessionTracker.stopBubbleBar()
        bubbleSessionTracker.log(
            SessionEvent.Started(forBubbleBar = true, selectedBubblePackage = "app.package")
        )
        bubbleSessionTracker.log(SessionEvent.Ended(forBubbleBar = true))

        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(2)
        val sessionStart = uiEventLoggerFake.logs.first()
@@ -76,26 +87,85 @@ class BubbleSessionTrackerImplTest {
    }

    @Test
    fun logCorrectEventId() {
        bubbleSessionTracker.startBubbleBar()
        bubbleSessionTracker.stopBubbleBar()
        bubbleSessionTracker.startFloating()
        bubbleSessionTracker.stopFloating()
    fun switchedBubble() {
        bubbleSessionTracker.log(
            SessionEvent.Started(forBubbleBar = true, selectedBubblePackage = "initial.package")
        )
        bubbleSessionTracker.log(
            SessionEvent.SwitchedBubble(forBubbleBar = true, toBubblePackage = "new.package")
        )
        bubbleSessionTracker.log(SessionEvent.Ended(forBubbleBar = true))

        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(4)

        with (uiEventLoggerFake.logs[0]) {
            assertThat(eventId).isEqualTo(BUBBLE_BAR_SESSION_STARTED.id)
            assertThat(packageName).isEqualTo("initial.package")
        }

        with (uiEventLoggerFake.logs[1]) {
            assertThat(eventId).isEqualTo(BUBBLE_BAR_SESSION_SWITCHED_FROM.id)
            assertThat(packageName).isEqualTo("initial.package")
        }

        with (uiEventLoggerFake.logs[2]) {
            assertThat(eventId).isEqualTo(BUBBLE_BAR_SESSION_SWITCHED_TO.id)
            assertThat(packageName).isEqualTo("new.package")
        }

        with (uiEventLoggerFake.logs[3]) {
            assertThat(eventId).isEqualTo(BUBBLE_BAR_SESSION_ENDED.id)
            assertThat(packageName).isEqualTo("new.package")
        }

        val loggedInstanceIds = uiEventLoggerFake.logs.map { it.instanceId }.toSet()
        assertThat(loggedInstanceIds).hasSize(1)
    }

    @Test
    fun logCorrectEventId() {
        bubbleSessionTracker.log(
            SessionEvent.Started(forBubbleBar = true, selectedBubblePackage = "app.package")
        )
        bubbleSessionTracker.log(
            SessionEvent.SwitchedBubble(forBubbleBar = true, toBubblePackage = "other.app.package")
        )
        bubbleSessionTracker.log(SessionEvent.Ended(forBubbleBar = true))
        bubbleSessionTracker.log(
            SessionEvent.Started(forBubbleBar = false, selectedBubblePackage = "app.package")
        )
        bubbleSessionTracker.log(
            SessionEvent.SwitchedBubble(forBubbleBar = false, toBubblePackage = "other.app.package")
        )
        bubbleSessionTracker.log(SessionEvent.Ended(forBubbleBar = false))

        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(8)
        assertThat(uiEventLoggerFake.logs.map { it.eventId })
            .containsExactly(
                BUBBLE_BAR_SESSION_STARTED.id,
                BUBBLE_BAR_SESSION_SWITCHED_FROM.id,
                BUBBLE_BAR_SESSION_SWITCHED_TO.id,
                BUBBLE_BAR_SESSION_ENDED.id,
                BUBBLE_SESSION_STARTED.id,
                BUBBLE_SESSION_SWITCHED_FROM.id,
                BUBBLE_SESSION_SWITCHED_TO.id,
                BUBBLE_SESSION_ENDED.id
            )
            .inOrder()
    }

    @Test
    fun stopSession_noActiveSession_shouldNotLog() {
        bubbleSessionTracker.stopBubbleBar()
    fun sessionEnded_noActiveSession_shouldNotLog() {
        bubbleSessionTracker.log(SessionEvent.Ended(forBubbleBar = true))

        assertThat(uiEventLoggerFake.logs).isEmpty()
    }

    @Test
    fun switchedBubble_noActiveSession_shouldNotLog() {
        bubbleSessionTracker.log(
            SessionEvent.SwitchedBubble(forBubbleBar = true, toBubblePackage = "app.package")
        )

        assertThat(uiEventLoggerFake.logs).isEmpty()
    }
+34 −18

File changed.

Preview size limit exceeded, changes collapsed.

Loading