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

Commit e2b10545 authored by William Leshner's avatar William Leshner Committed by Android (Google) Code Review
Browse files

Merge "Log "go to dream" button taps." into main

parents 155ff2f3 654098d4
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -21,8 +21,10 @@ import android.provider.Settings
import android.service.dream.dreamManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.uiEventLoggerFake
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.shared.log.CommunalUiEvent
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.kosmos.collectLastValue
@@ -50,6 +52,7 @@ import org.mockito.kotlin.whenever
class CommunalToDreamButtonViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val uiEventLoggerFake = kosmos.uiEventLoggerFake
    private val underTest: CommunalToDreamButtonViewModel by lazy {
        kosmos.communalToDreamButtonViewModel
    }
@@ -119,4 +122,16 @@ class CommunalToDreamButtonViewModelTest : SysuiTestCase() {
                verify(activityStarter).postStartActivityDismissingKeyguard(any(), anyInt())
            }
        }

    @Test
    fun onShowDreamButtonTap_eventLogged() =
        with(kosmos) {
            runTest {
                underTest.onShowDreamButtonTap()
                runCurrent()

                assertThat(uiEventLoggerFake[0].eventId)
                    .isEqualTo(CommunalUiEvent.COMMUNAL_HUB_SHOW_DREAM_BUTTON_TAP.id)
            }
        }
}
+3 −1
Original line number Diff line number Diff line
@@ -67,7 +67,9 @@ enum class CommunalUiEvent(private val id: Int) : UiEventEnum {
    @UiEvent(doc = "User cancels the swipe gesture to exit the Communal Hub to go to Dream")
    COMMUNAL_HUB_TO_DREAM_SWIPE_CANCEL(1865),
    @UiEvent(doc = "A transition from Dream to Communal Hub starts due to dream awakening")
    DREAM_TO_COMMUNAL_HUB_DREAM_AWAKE_START(1866);
    DREAM_TO_COMMUNAL_HUB_DREAM_AWAKE_START(1866),
    @UiEvent(doc = "User long-pressed the button on Communal Hub to go to Dream")
    COMMUNAL_HUB_SHOW_DREAM_BUTTON_TAP(2065);

    override fun getId(): Int {
        return id
+4 −0
Original line number Diff line number Diff line
@@ -20,7 +20,9 @@ import android.annotation.SuppressLint
import android.app.DreamManager
import android.content.Intent
import android.provider.Settings
import com.android.internal.logging.UiEventLogger
import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.communal.shared.log.CommunalUiEvent
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.plugins.ActivityStarter
@@ -48,6 +50,7 @@ constructor(
    private val settingsInteractor: CommunalSettingsInteractor,
    private val activityStarter: ActivityStarter,
    private val dreamManager: DreamManager,
    private val uiEventLogger: UiEventLogger,
) : ExclusiveActivatable() {

    private val _requests = Channel<Unit>(Channel.BUFFERED)
@@ -59,6 +62,7 @@ constructor(

    /** Handle a tap on the "show dream" button. */
    fun onShowDreamButtonTap() {
        uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_SHOW_DREAM_BUTTON_TAP)
        _requests.trySend(Unit)
    }

+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.communal.ui.viewmodel

import android.service.dream.dreamManager
import com.android.internal.logging.uiEventLogger
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testDispatcher
@@ -31,5 +32,6 @@ val Kosmos.communalToDreamButtonViewModel by
            settingsInteractor = communalSettingsInteractor,
            activityStarter = activityStarter,
            dreamManager = dreamManager,
            uiEventLogger = uiEventLogger,
        )
    }