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

Commit 5770e1f2 authored by Darrell Shi's avatar Darrell Shi
Browse files

Remove CommunalTutorialInteractorFactory

Bug: 319335645
Test: n/a
Flag: n/a
Change-Id: I3eecbb5dfcf784e1641792eae75c42316def62fd
parent ee95ed7c
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -24,13 +24,17 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.FakeCommunalRepository
import com.android.systemui.communal.data.repository.FakeCommunalRepository
import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.fakeCommunalRepository
import com.android.systemui.communal.data.repository.fakeCommunalTutorialRepository
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.kosmos.testScope
import com.android.systemui.settings.UserTracker
import com.android.systemui.settings.UserTracker
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.mock
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.test.TestScope
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
@@ -41,10 +45,11 @@ import org.mockito.MockitoAnnotations
@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4::class)
class CommunalTutorialInteractorTest : SysuiTestCase() {
class CommunalTutorialInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope


    @Mock private lateinit var userTracker: UserTracker
    @Mock private lateinit var userTracker: UserTracker


    private lateinit var testScope: TestScope
    private lateinit var underTest: CommunalTutorialInteractor
    private lateinit var underTest: CommunalTutorialInteractor
    private lateinit var keyguardRepository: FakeKeyguardRepository
    private lateinit var keyguardRepository: FakeKeyguardRepository
    private lateinit var communalTutorialRepository: FakeCommunalTutorialRepository
    private lateinit var communalTutorialRepository: FakeCommunalTutorialRepository
@@ -54,14 +59,11 @@ class CommunalTutorialInteractorTest : SysuiTestCase() {
    fun setUp() {
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        MockitoAnnotations.initMocks(this)


        testScope = TestScope()
        keyguardRepository = kosmos.fakeKeyguardRepository
        communalTutorialRepository = kosmos.fakeCommunalTutorialRepository
        communalRepository = kosmos.fakeCommunalRepository


        val withDeps = CommunalTutorialInteractorFactory.create(testScope)
        underTest = kosmos.communalTutorialInteractor
        keyguardRepository = withDeps.keyguardRepository
        communalTutorialRepository = withDeps.communalTutorialRepository
        communalRepository = withDeps.communalRepository

        underTest = withDeps.communalTutorialInteractor


        whenever(userTracker.userHandle).thenReturn(mock())
        whenever(userTracker.userHandle).thenReturn(mock())
    }
    }
+16 −9
Original line number Original line Diff line number Diff line
@@ -26,10 +26,12 @@ import com.android.systemui.communal.widgets.CommunalAppWidgetHost
import com.android.systemui.communal.widgets.EditWidgetsActivityStarter
import com.android.systemui.communal.widgets.EditWidgetsActivityStarter
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory
import com.android.systemui.smartspace.data.repository.FakeSmartspaceRepository
import com.android.systemui.smartspace.data.repository.FakeSmartspaceRepository
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.mock
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.TestScope


// TODO(b/319335645): get rid of me and use kosmos.
object CommunalInteractorFactory {
object CommunalInteractorFactory {


    @JvmOverloads
    @JvmOverloads
@@ -38,6 +40,7 @@ object CommunalInteractorFactory {
        testScope: TestScope = TestScope(),
        testScope: TestScope = TestScope(),
        communalRepository: FakeCommunalRepository =
        communalRepository: FakeCommunalRepository =
            FakeCommunalRepository(testScope.backgroundScope),
            FakeCommunalRepository(testScope.backgroundScope),
        keyguardRepository: FakeKeyguardRepository = FakeKeyguardRepository(),
        widgetRepository: FakeCommunalWidgetRepository =
        widgetRepository: FakeCommunalWidgetRepository =
            FakeCommunalWidgetRepository(testScope.backgroundScope),
            FakeCommunalWidgetRepository(testScope.backgroundScope),
        mediaRepository: FakeCommunalMediaRepository = FakeCommunalMediaRepository(),
        mediaRepository: FakeCommunalMediaRepository = FakeCommunalMediaRepository(),
@@ -47,12 +50,16 @@ object CommunalInteractorFactory {
        appWidgetHost: CommunalAppWidgetHost = mock(),
        appWidgetHost: CommunalAppWidgetHost = mock(),
        editWidgetsActivityStarter: EditWidgetsActivityStarter = mock(),
        editWidgetsActivityStarter: EditWidgetsActivityStarter = mock(),
    ): WithDependencies {
    ): WithDependencies {
        val withDeps =
        val keyguardInteractor =
            CommunalTutorialInteractorFactory.create(
            KeyguardInteractorFactory.create(repository = keyguardRepository).keyguardInteractor
                testScope = testScope,
        val communalTutorialInteractor =
                communalTutorialRepository = tutorialRepository,
            CommunalTutorialInteractor(
                communalRepository = communalRepository,
                testScope.backgroundScope,
                tutorialRepository,
                keyguardInteractor,
                communalRepository,
            )
            )

        return WithDependencies(
        return WithDependencies(
            testScope,
            testScope,
            communalRepository,
            communalRepository,
@@ -61,9 +68,9 @@ object CommunalInteractorFactory {
            mediaRepository,
            mediaRepository,
            smartspaceRepository,
            smartspaceRepository,
            tutorialRepository,
            tutorialRepository,
            withDeps.keyguardRepository,
            keyguardRepository,
            withDeps.keyguardInteractor,
            keyguardInteractor,
            withDeps.communalTutorialInteractor,
            communalTutorialInteractor,
            appWidgetHost,
            appWidgetHost,
            editWidgetsActivityStarter,
            editWidgetsActivityStarter,
            CommunalInteractor(
            CommunalInteractor(
@@ -73,7 +80,7 @@ object CommunalInteractorFactory {
                communalPrefsRepository,
                communalPrefsRepository,
                mediaRepository,
                mediaRepository,
                smartspaceRepository,
                smartspaceRepository,
                withDeps.keyguardInteractor,
                keyguardInteractor,
                appWidgetHost,
                appWidgetHost,
                editWidgetsActivityStarter,
                editWidgetsActivityStarter,
            ),
            ),
+0 −67
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2023 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.domain.interactor

import com.android.systemui.communal.data.repository.FakeCommunalRepository
import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory
import kotlinx.coroutines.test.TestScope

object CommunalTutorialInteractorFactory {

    @JvmOverloads
    @JvmStatic
    fun create(
        testScope: TestScope,
        communalTutorialRepository: FakeCommunalTutorialRepository =
            FakeCommunalTutorialRepository(),
        communalRepository: FakeCommunalRepository =
            FakeCommunalRepository(applicationScope = testScope.backgroundScope),
        keyguardRepository: FakeKeyguardRepository = FakeKeyguardRepository(),
        keyguardInteractor: KeyguardInteractor =
            KeyguardInteractorFactory.create(
                    repository = keyguardRepository,
                )
                .keyguardInteractor
    ): WithDependencies {
        return WithDependencies(
            testScope = testScope,
            communalRepository = communalRepository,
            communalTutorialRepository = communalTutorialRepository,
            keyguardRepository = keyguardRepository,
            keyguardInteractor = keyguardInteractor,
            communalTutorialInteractor =
                CommunalTutorialInteractor(
                    testScope.backgroundScope,
                    communalTutorialRepository,
                    keyguardInteractor,
                    communalRepository,
                )
        )
    }

    data class WithDependencies(
        val testScope: TestScope,
        val communalRepository: FakeCommunalRepository,
        val communalTutorialRepository: FakeCommunalTutorialRepository,
        val keyguardRepository: FakeKeyguardRepository,
        val keyguardInteractor: KeyguardInteractor,
        val communalTutorialInteractor: CommunalTutorialInteractor,
    )
}
+33 −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.domain.interactor

import com.android.systemui.communal.data.repository.communalRepository
import com.android.systemui.communal.data.repository.communalTutorialRepository
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.applicationCoroutineScope

val Kosmos.communalTutorialInteractor by
    Kosmos.Fixture {
        CommunalTutorialInteractor(
            scope = applicationCoroutineScope,
            communalTutorialRepository = communalTutorialRepository,
            keyguardInteractor = keyguardInteractor,
            communalRepository = communalRepository,
        )
    }