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

Commit 03d47298 authored by Darrell Shi's avatar Darrell Shi Committed by Android (Google) Code Review
Browse files

Merge changes I9498dc7d,I10c02d0a,Ie3d8cac9 into main

* changes:
  Cache smartspace timer creation time
  Listen for ongoing updates when communal enabled
  Introduce communal smartspace repository
parents fb8ceebd 2ce526f3
Loading
Loading
Loading
Loading
+89 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2024 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.systemui.communal

import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.fakeCommunalSmartspaceRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.setCommunalEnabled
import com.android.systemui.flags.Flags
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@EnableFlags(FLAG_COMMUNAL_HUB)
@RunWith(AndroidJUnit4::class)
class CommunalOngoingContentStartableTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope

    private val mediaRepository = kosmos.fakeCommunalMediaRepository
    private val smartspaceRepository = kosmos.fakeCommunalSmartspaceRepository
    private val featureFlags =
        kosmos.fakeFeatureFlagsClassic.apply { set(Flags.COMMUNAL_SERVICE_ENABLED, true) }

    private lateinit var underTest: CommunalOngoingContentStartable

    @Before
    fun setUp() {
        underTest =
            CommunalOngoingContentStartable(
                bgScope = kosmos.applicationCoroutineScope,
                communalInteractor = kosmos.communalInteractor,
                communalMediaRepository = mediaRepository,
                communalSmartspaceRepository = smartspaceRepository,
                featureFlags = featureFlags,
            )
    }

    @Test
    fun testListenForOngoingContentWhenCommunalIsEnabled() =
        testScope.runTest {
            underTest.start()
            runCurrent()

            assertThat(mediaRepository.isListening()).isFalse()
            assertThat(smartspaceRepository.isListening()).isFalse()

            kosmos.setCommunalEnabled(true)
            runCurrent()

            assertThat(mediaRepository.isListening()).isTrue()
            assertThat(smartspaceRepository.isListening()).isTrue()

            kosmos.setCommunalEnabled(false)
            runCurrent()

            assertThat(mediaRepository.isListening()).isFalse()
            assertThat(smartspaceRepository.isListening()).isFalse()
        }
}
+17 −18
Original line number Original line Diff line number Diff line
@@ -20,46 +20,41 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.media.controls.domain.pipeline.MediaDataManager
import com.android.systemui.media.controls.domain.pipeline.MediaDataManager
import com.android.systemui.media.controls.shared.model.MediaData
import com.android.systemui.media.controls.shared.model.MediaData
import com.android.systemui.util.mockito.KotlinArgumentCaptor
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Before
import org.junit.Test
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.verify
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.mock


@OptIn(ExperimentalCoroutinesApi::class)
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4::class)
@android.platform.test.annotations.EnabledOnRavenwood
@android.platform.test.annotations.EnabledOnRavenwood
class CommunalMediaRepositoryImplTest : SysuiTestCase() {
class CommunalMediaRepositoryImplTest : SysuiTestCase() {
    @Mock private lateinit var mediaDataManager: MediaDataManager
    private val mediaDataManager = mock<MediaDataManager>()
    @Mock private lateinit var mediaData: MediaData
    private val mediaData = mock<MediaData>()
    @Mock private lateinit var tableLogBuffer: TableLogBuffer
    private val tableLogBuffer = mock<TableLogBuffer>()


    private lateinit var underTest: CommunalMediaRepositoryImpl
    private lateinit var underTest: CommunalMediaRepositoryImpl


    private val mediaDataListenerCaptor: KotlinArgumentCaptor<MediaDataManager.Listener> by lazy {
    private val mediaDataListenerCaptor = argumentCaptor<MediaDataManager.Listener>()
        KotlinArgumentCaptor(MediaDataManager.Listener::class.java)
    }


    private val testDispatcher = StandardTestDispatcher()
    private val kosmos = testKosmos()
    private val testScope = TestScope(testDispatcher)
    private val testScope = kosmos.testScope


    @Before
    @Before
    fun setUp() {
    fun setUp() {
        MockitoAnnotations.initMocks(this)

        underTest =
        underTest =
            CommunalMediaRepositoryImpl(
            CommunalMediaRepositoryImpl(
                mediaDataManager,
                mediaDataManager,
@@ -78,6 +73,8 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
    @Test
    @Test
    fun mediaModel_updatesWhenMediaDataLoaded() =
    fun mediaModel_updatesWhenMediaDataLoaded() =
        testScope.runTest {
        testScope.runTest {
            underTest.startListening()

            // Listener is added
            // Listener is added
            verify(mediaDataManager).addListener(mediaDataListenerCaptor.capture())
            verify(mediaDataManager).addListener(mediaDataListenerCaptor.capture())


@@ -89,7 +86,7 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
            // Change to media available and notify the listener.
            // Change to media available and notify the listener.
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true)
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true)
            whenever(mediaData.createdTimestampMillis).thenReturn(1234L)
            whenever(mediaData.createdTimestampMillis).thenReturn(1234L)
            mediaDataListenerCaptor.value.onMediaDataLoaded("key", null, mediaData)
            mediaDataListenerCaptor.firstValue.onMediaDataLoaded("key", null, mediaData)
            runCurrent()
            runCurrent()


            // Media active now returns true.
            // Media active now returns true.
@@ -100,12 +97,14 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
    @Test
    @Test
    fun mediaModel_updatesWhenMediaDataRemoved() =
    fun mediaModel_updatesWhenMediaDataRemoved() =
        testScope.runTest {
        testScope.runTest {
            underTest.startListening()

            // Listener is added
            // Listener is added
            verify(mediaDataManager).addListener(mediaDataListenerCaptor.capture())
            verify(mediaDataManager).addListener(mediaDataListenerCaptor.capture())


            // Change to media available and notify the listener.
            // Change to media available and notify the listener.
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true)
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true)
            mediaDataListenerCaptor.value.onMediaDataLoaded("key", null, mediaData)
            mediaDataListenerCaptor.firstValue.onMediaDataLoaded("key", null, mediaData)
            runCurrent()
            runCurrent()


            // Media active now returns true.
            // Media active now returns true.
@@ -114,7 +113,7 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {


            // Change to media unavailable and notify the listener.
            // Change to media unavailable and notify the listener.
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(false)
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(false)
            mediaDataListenerCaptor.value.onMediaDataRemoved("key", false)
            mediaDataListenerCaptor.firstValue.onMediaDataRemoved("key", false)
            runCurrent()
            runCurrent()


            // Media active now returns false.
            // Media active now returns false.
+319 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2024 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.systemui.communal.data.repository

import android.app.smartspace.SmartspaceTarget
import android.app.smartspace.flags.Flags.FLAG_REMOTE_VIEWS
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.smartspace.CommunalSmartspaceController
import com.android.systemui.concurrency.fakeExecutor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceTargetListener
import com.android.systemui.testKosmos
import com.android.systemui.util.time.fakeSystemClock
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify

@SmallTest
@OptIn(ExperimentalCoroutinesApi::class)
@RunWith(AndroidJUnit4::class)
class CommunalSmartspaceRepositoryImplTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope

    private val listenerCaptor = argumentCaptor<SmartspaceTargetListener>()

    private val smartspaceController = mock<CommunalSmartspaceController>()
    private val fakeExecutor = kosmos.fakeExecutor
    private val systemClock = kosmos.fakeSystemClock

    private lateinit var underTest: CommunalSmartspaceRepositoryImpl

    @Before
    fun setUp() {
        underTest =
            CommunalSmartspaceRepositoryImpl(
                smartspaceController,
                fakeExecutor,
                systemClock,
            )
    }

    @DisableFlags(FLAG_REMOTE_VIEWS)
    @Test
    fun startListening_remoteViewsFlagDisabled_doNotListenForSmartspaceUpdates() =
        testScope.runTest {
            underTest.startListening()
            fakeExecutor.runAllReady()

            verify(smartspaceController, never()).addListener(any())
        }

    @EnableFlags(FLAG_REMOTE_VIEWS)
    @Test
    fun startListening_remoteViewsFlagEnabled_listenForSmartspaceUpdates() =
        testScope.runTest {
            underTest.startListening()
            fakeExecutor.runAllReady()

            // Verify listener added
            val listener = captureSmartspaceTargetListener()

            underTest.stopListening()
            fakeExecutor.runAllReady()

            // Verify listener removed
            verify(smartspaceController).removeListener(listener)
        }

    @EnableFlags(FLAG_REMOTE_VIEWS)
    @Test
    fun communalTimers_onlyShowTimersWithRemoteViews() =
        testScope.runTest {
            underTest.startListening()

            val communalTimers by collectLastValue(underTest.timers)
            runCurrent()
            fakeExecutor.runAllReady()

            with(captureSmartspaceTargetListener()) {
                onSmartspaceTargetsUpdated(
                    listOf(
                        // Invalid. Not a timer
                        mock<SmartspaceTarget> {
                            on { smartspaceTargetId }.doReturn("weather")
                            on { featureType }.doReturn(SmartspaceTarget.FEATURE_WEATHER)
                        },
                        // Invalid. RemoteViews absent
                        mock<SmartspaceTarget> {
                            on { smartspaceTargetId }.doReturn("timer-0-started")
                            on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                            on { remoteViews }.doReturn(null)
                            on { creationTimeMillis }.doReturn(1000)
                        },
                        // Valid
                        mock<SmartspaceTarget> {
                            on { smartspaceTargetId }.doReturn("timer-1-started")
                            on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                            on { remoteViews }.doReturn(mock())
                            on { creationTimeMillis }.doReturn(2000)
                        },
                    )
                )
            }
            runCurrent()

            // Verify that only the valid target is listed
            assertThat(communalTimers).hasSize(1)
            assertThat(communalTimers?.first()?.smartspaceTargetId).isEqualTo("timer-1-started")
        }

    @EnableFlags(FLAG_REMOTE_VIEWS)
    @Test
    fun communalTimers_cacheCreationTime() =
        testScope.runTest {
            underTest.startListening()

            val communalTimers by collectLastValue(underTest.timers)
            runCurrent()
            fakeExecutor.runAllReady()

            val listener = captureSmartspaceTargetListener()
            listener.onSmartspaceTargetsUpdated(
                listOf(
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-0-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(1000)
                    },
                )
            )
            runCurrent()

            // Verify that the creation time is the current time, not the creation time passed in
            // the target, because this value can be inaccurate (due to b/318535930).
            val currentTime = systemClock.currentTimeMillis()
            assertThat(communalTimers?.get(0)?.createdTimestampMillis).isEqualTo(currentTime)
            assertThat(communalTimers?.get(0)?.createdTimestampMillis).isNotEqualTo(1000)

            // A second timer is added.
            listener.onSmartspaceTargetsUpdated(
                listOf(
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-0-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(2000)
                    },
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-1-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(3000)
                    },
                )
            )
            runCurrent()

            // Verify that the created timestamp for the first time is consistent
            assertThat(communalTimers?.get(0)?.createdTimestampMillis).isEqualTo(currentTime)

            // Verify that the second timer has a new creation time
            assertThat(communalTimers?.get(1)?.createdTimestampMillis)
                .isEqualTo(systemClock.currentTimeMillis())
        }

    @EnableFlags(FLAG_REMOTE_VIEWS)
    @Test
    fun communalTimers_creationTimeRemovedFromCacheWhenTimerRemoved() =
        testScope.runTest {
            underTest.startListening()

            val communalTimers by collectLastValue(underTest.timers)
            runCurrent()
            fakeExecutor.runAllReady()

            // Start timer 0
            val listener = captureSmartspaceTargetListener()
            listener.onSmartspaceTargetsUpdated(
                listOf(
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-0-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(1000)
                    },
                )
            )
            runCurrent()

            // Verify timer 0 creation time
            val expectedCreationTimeForTimer0 = systemClock.currentTimeMillis()
            assertThat(communalTimers?.first()?.createdTimestampMillis)
                .isEqualTo(expectedCreationTimeForTimer0)

            // Advance some time
            systemClock.advanceTime(1000)

            // Start timer 1
            listener.onSmartspaceTargetsUpdated(
                listOf(
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-0-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(1000)
                    },
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-1-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(2000)
                    },
                )
            )
            runCurrent()

            // Verify timer 1 creation time is new
            val expectedCreationTimeForTimer1 = expectedCreationTimeForTimer0 + 1000
            assertThat(communalTimers?.get(1)?.createdTimestampMillis)
                .isEqualTo(expectedCreationTimeForTimer1)

            // Removed timer 0
            listener.onSmartspaceTargetsUpdated(
                listOf(
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-1-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(2000)
                    },
                )
            )
            runCurrent()

            // Verify timer 0 removed, and timer 1 creation time is correct
            assertThat(communalTimers).hasSize(1)
            assertThat(communalTimers?.first()?.createdTimestampMillis)
                .isEqualTo(expectedCreationTimeForTimer1)

            // Advance some time
            systemClock.advanceTime(1000)

            // Start timer 0 again. Technically this is a new timer, but timers can reused stable
            // ids.
            listener.onSmartspaceTargetsUpdated(
                listOf(
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-1-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(2000)
                    },
                    mock<SmartspaceTarget> {
                        on { smartspaceTargetId }.doReturn("timer-0-started")
                        on { featureType }.doReturn(SmartspaceTarget.FEATURE_TIMER)
                        on { remoteViews }.doReturn(mock())
                        on { creationTimeMillis }.doReturn(3000)
                    },
                )
            )
            runCurrent()

            // Verify new timer added, and timer 1 creation time is still correct
            assertThat(communalTimers).hasSize(2)
            assertThat(communalTimers?.get(0)?.createdTimestampMillis)
                .isEqualTo(expectedCreationTimeForTimer1)

            // Verify creation time for the new timer is new, meaning that cache for timer 0 was
            // removed when it was removed
            assertThat(communalTimers?.get(1)?.createdTimestampMillis)
                .isEqualTo(expectedCreationTimeForTimer1 + 1000)
        }

    @Test
    fun stableId() {
        assertThat(CommunalSmartspaceRepositoryImpl.stableId("timer-0-12345-started"))
            .isEqualTo("timer-0")
        assertThat(CommunalSmartspaceRepositoryImpl.stableId("timer-1-67890-paused"))
            .isEqualTo("timer-1")
        assertThat(CommunalSmartspaceRepositoryImpl.stableId("i_am_an_unexpected_id"))
            .isEqualTo("i_am_an_unexpected_id")
    }

    private fun captureSmartspaceTargetListener(): SmartspaceTargetListener {
        verify(smartspaceController).addListener(listenerCaptor.capture())
        return listenerCaptor.firstValue
    }
}
+16 −55

File changed.

Preview size limit exceeded, changes collapsed.

+14 −10
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.systemui.communal.view.viewmodel
package com.android.systemui.communal.view.viewmodel


import android.app.smartspace.SmartspaceTarget
import android.appwidget.AppWidgetProviderInfo
import android.appwidget.AppWidgetProviderInfo
import android.content.ActivityNotFoundException
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.Intent
@@ -32,10 +31,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.internal.logging.UiEventLogger
import com.android.internal.logging.UiEventLogger
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.model.CommunalSmartspaceTimer
import com.android.systemui.communal.data.repository.FakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.FakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.FakeCommunalSmartspaceRepository
import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.FakeCommunalWidgetRepository
import com.android.systemui.communal.data.repository.FakeCommunalWidgetRepository
import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.fakeCommunalSmartspaceRepository
import com.android.systemui.communal.data.repository.fakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.fakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository
import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
@@ -57,8 +59,6 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.log.logcatLogBuffer
import com.android.systemui.log.logcatLogBuffer
import com.android.systemui.media.controls.ui.view.MediaHost
import com.android.systemui.media.controls.ui.view.MediaHost
import com.android.systemui.settings.fakeUserTracker
import com.android.systemui.settings.fakeUserTracker
import com.android.systemui.smartspace.data.repository.FakeSmartspaceRepository
import com.android.systemui.smartspace.data.repository.fakeSmartspaceRepository
import com.android.systemui.testKosmos
import com.android.systemui.testKosmos
import com.android.systemui.user.data.repository.fakeUserRepository
import com.android.systemui.user.data.repository.fakeUserRepository
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.any
@@ -91,7 +91,7 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {


    private lateinit var tutorialRepository: FakeCommunalTutorialRepository
    private lateinit var tutorialRepository: FakeCommunalTutorialRepository
    private lateinit var widgetRepository: FakeCommunalWidgetRepository
    private lateinit var widgetRepository: FakeCommunalWidgetRepository
    private lateinit var smartspaceRepository: FakeSmartspaceRepository
    private lateinit var smartspaceRepository: FakeCommunalSmartspaceRepository
    private lateinit var mediaRepository: FakeCommunalMediaRepository
    private lateinit var mediaRepository: FakeCommunalMediaRepository
    private lateinit var communalSceneInteractor: CommunalSceneInteractor
    private lateinit var communalSceneInteractor: CommunalSceneInteractor


@@ -105,7 +105,7 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {


        tutorialRepository = kosmos.fakeCommunalTutorialRepository
        tutorialRepository = kosmos.fakeCommunalTutorialRepository
        widgetRepository = kosmos.fakeCommunalWidgetRepository
        widgetRepository = kosmos.fakeCommunalWidgetRepository
        smartspaceRepository = kosmos.fakeSmartspaceRepository
        smartspaceRepository = kosmos.fakeCommunalSmartspaceRepository
        mediaRepository = kosmos.fakeCommunalMediaRepository
        mediaRepository = kosmos.fakeCommunalMediaRepository
        communalSceneInteractor = kosmos.communalSceneInteractor
        communalSceneInteractor = kosmos.communalSceneInteractor
        kosmos.fakeUserRepository.setUserInfos(listOf(MAIN_USER_INFO))
        kosmos.fakeUserRepository.setUserInfos(listOf(MAIN_USER_INFO))
@@ -152,11 +152,15 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {
            widgetRepository.setCommunalWidgets(widgets)
            widgetRepository.setCommunalWidgets(widgets)


            // Smartspace available.
            // Smartspace available.
            val target = Mockito.mock(SmartspaceTarget::class.java)
            smartspaceRepository.setTimers(
            whenever(target.smartspaceTargetId).thenReturn("target")
                listOf(
            whenever(target.featureType).thenReturn(SmartspaceTarget.FEATURE_TIMER)
                    CommunalSmartspaceTimer(
            whenever(target.remoteViews).thenReturn(Mockito.mock(RemoteViews::class.java))
                        smartspaceTargetId = "target",
            smartspaceRepository.setCommunalSmartspaceTargets(listOf(target))
                        createdTimestampMillis = 0L,
                        remoteViews = Mockito.mock(RemoteViews::class.java),
                    )
                )
            )


            // Media playing.
            // Media playing.
            mediaRepository.mediaActive()
            mediaRepository.mediaActive()
Loading