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

Commit 2980ee12 authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Make usages of communal hub trunk flag also read config flag" into main

parents ab7caa87 a4f4ada8
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -25,9 +25,13 @@ import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.ambient.touch.TouchHandler.TouchSession
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.shared.system.InputChannelCompat
import com.android.systemui.statusbar.phone.CentralSurfaces
import com.android.systemui.testKosmos
import com.google.common.truth.Truth
import java.util.Optional
import org.junit.Before
@@ -45,6 +49,8 @@ import org.mockito.kotlin.whenever
@SmallTest
@RunWith(AndroidJUnit4::class)
class ShadeTouchHandlerTest : SysuiTestCase() {
    private var kosmos = testKosmos()

    private var mCentralSurfaces = mock<CentralSurfaces>()
    private var mShadeViewController = mock<ShadeViewController>()
    private var mDreamManager = mock<DreamManager>()
@@ -62,6 +68,7 @@ class ShadeTouchHandlerTest : SysuiTestCase() {
                Optional.of(mCentralSurfaces),
                mShadeViewController,
                mDreamManager,
                kosmos.communalSettingsInteractor,
                TOUCH_HEIGHT
            )
    }
@@ -86,6 +93,8 @@ class ShadeTouchHandlerTest : SysuiTestCase() {
    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB)
    fun testSwipeDown_communalEnabled_sentToCentralSurfaces() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        swipe(Direction.DOWN)

        // Both motion events are sent for central surfaces to process.
@@ -117,6 +126,8 @@ class ShadeTouchHandlerTest : SysuiTestCase() {
    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB)
    fun testSwipeUp_communalEnabled_touchesNotSent() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        swipe(Direction.UP)

        // Motion events are not sent for central surfaces to process as the swipe is going in the
+6 −0
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.keyguardRepository
@@ -61,9 +64,12 @@ class CommunalDreamStartableTest : SysuiTestCase() {

    @Before
    fun setUp() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        underTest =
            CommunalDreamStartable(
                    powerInteractor = kosmos.powerInteractor,
                    communalSettingsInteractor = kosmos.communalSettingsInteractor,
                    keyguardInteractor = kosmos.keyguardInteractor,
                    keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor,
                    dreamManager = dreamManager,
+3 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ 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.communalSettingsInteractor
import com.android.systemui.communal.domain.interactor.setCommunalEnabled
import com.android.systemui.flags.Flags
import com.android.systemui.flags.fakeFeatureFlagsClassic
@@ -48,20 +49,19 @@ class CommunalOngoingContentStartableTest : SysuiTestCase() {

    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() {
        kosmos.fakeFeatureFlagsClassic.set(Flags.COMMUNAL_SERVICE_ENABLED, true)
        underTest =
            CommunalOngoingContentStartable(
                bgScope = kosmos.applicationCoroutineScope,
                communalInteractor = kosmos.communalInteractor,
                communalMediaRepository = mediaRepository,
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                communalSmartspaceRepository = smartspaceRepository,
                featureFlags = featureFlags,
            )
    }

+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.domain.interactor.setCommunalAvailable
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.coroutines.collectLastValue
@@ -78,6 +79,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
                CommunalSceneStartable(
                        dockManager = dockManager,
                        communalInteractor = communalInteractor,
                        communalSettingsInteractor = communalSettingsInteractor,
                        communalSceneInteractor = communalSceneInteractor,
                        keyguardTransitionInteractor = keyguardTransitionInteractor,
                        keyguardInteractor = keyguardInteractor,
+32 −0
Original line number Diff line number Diff line
@@ -66,6 +66,38 @@ class CommunalSettingsRepositoryImplTest : SysuiTestCase() {
        underTest = kosmos.communalSettingsRepository
    }

    @EnableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun getFlagEnabled_bothEnabled() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        assertThat(underTest.getFlagEnabled()).isTrue()
    }

    @DisableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun getFlagEnabled_bothDisabled() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, false)

        assertThat(underTest.getFlagEnabled()).isFalse()
    }

    @DisableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun getFlagEnabled_onlyClassicFlagEnabled() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        assertThat(underTest.getFlagEnabled()).isFalse()
    }

    @EnableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun getFlagEnabled_onlyTrunkFlagEnabled() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, false)

        assertThat(underTest.getFlagEnabled()).isFalse()
    }

    @EnableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun secondaryUserIsInvalid() =
Loading