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

Commit 8c3b2b5a authored by Justin Weir's avatar Justin Weir Committed by Android (Google) Code Review
Browse files

Merge changes Ie1d21324,Ic64d4c25,Ifa02960c,I16549d12 into main

* changes:
  [flexiglass] Disable NPVC and NPV when flexiglass is on
  Remove reference to NPVC
  Move shouldHideStatusBarIconsWhenExpanded to PanelExpansionInteractor
  Hydrate ShadeExpansionStateManager
parents 67042bb1 9f186a2d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public class UdfpsKeyguardViewLegacyControllerBaseTest extends SysuiTestCase {
        when(mKeyguardViewMediator.isAnimatingScreenOff()).thenReturn(false);
        when(mView.getUnpausedAlpha()).thenReturn(255);
        when(mShadeExpansionStateManager.addExpansionListener(any())).thenReturn(
                new ShadeExpansionChangeEvent(0, false, false, 0));
                new ShadeExpansionChangeEvent(0, false, false));
        mController = createUdfpsKeyguardViewController();
    }

+1 −1
Original line number Diff line number Diff line
@@ -376,7 +376,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
        // Ensure correct expansion passed in.
        ShadeExpansionChangeEvent event =
                new ShadeExpansionChangeEvent(
                        expansion, /* expanded= */ false, /* tracking= */ true, dragDownAmount);
                        expansion, /* expanded= */ false, /* tracking= */ true);
        verify(mScrimController).expand(event);
    }

+2 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class BouncerlessScrimControllerTest extends SysuiTestCase {
        final BouncerlessScrimController scrimController =
                new BouncerlessScrimController(mExecutor, mPowerManager);
        scrimController.addCallback(mCallback);
        scrimController.expand(new ShadeExpansionChangeEvent(.5f, true, false, 0.0f));
        scrimController.expand(new ShadeExpansionChangeEvent(.5f, true, false));
        mExecutor.runAllReady();
        verify(mPowerManager).wakeUp(anyLong(), eq(PowerManager.WAKE_REASON_GESTURE), any());
        verify(mCallback).onWakeup();
@@ -71,7 +71,7 @@ public class BouncerlessScrimControllerTest extends SysuiTestCase {
                new BouncerlessScrimController(mExecutor, mPowerManager);
        scrimController.addCallback(mCallback);
        final ShadeExpansionChangeEvent expansionEvent =
                new ShadeExpansionChangeEvent(0.5f, false, false, 0.0f);
                new ShadeExpansionChangeEvent(0.5f, false, false);
        scrimController.expand(expansionEvent);
        mExecutor.runAllReady();
        verify(mCallback).onExpansion(eq(expansionEvent));
+35 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ class PanelExpansionInteractorImplTest : SysuiTestCase() {
    private val deviceEntryRepository = kosmos.fakeDeviceEntryRepository
    private val deviceUnlockedInteractor = kosmos.deviceUnlockedInteractor
    private val sceneInteractor = kosmos.sceneInteractor
    private val shadeAnimationInteractor = kosmos.shadeAnimationInteractor
    private val transitionState =
        MutableStateFlow<ObservableTransitionState>(
            ObservableTransitionState.Idle(Scenes.Lockscreen)
@@ -112,6 +113,40 @@ class PanelExpansionInteractorImplTest : SysuiTestCase() {
            changeScene(Scenes.Communal) { assertThat(panelExpansion).isEqualTo(1f) }
            assertThat(panelExpansion).isEqualTo(1f)
        }

    @Test
    @EnableSceneContainer
    fun shouldHideStatusBarIconsWhenExpanded_goneScene() =
        testScope.runTest {
            underTest = kosmos.panelExpansionInteractorImpl
            shadeAnimationInteractor.setIsLaunchingActivity(false)
            changeScene(Scenes.Gone)

            assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isFalse()
        }

    @Test
    @EnableSceneContainer
    fun shouldHideStatusBarIconsWhenExpanded_lockscreenScene() =
        testScope.runTest {
            underTest = kosmos.panelExpansionInteractorImpl
            shadeAnimationInteractor.setIsLaunchingActivity(false)
            changeScene(Scenes.Lockscreen)

            assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isTrue()
        }

    @Test
    @EnableSceneContainer
    fun shouldHideStatusBarIconsWhenExpanded_activityLaunch() =
        testScope.runTest {
            underTest = kosmos.panelExpansionInteractorImpl
            changeScene(Scenes.Gone)
            shadeAnimationInteractor.setIsLaunchingActivity(true)

            assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isFalse()
        }

    private fun TestScope.setUnlocked(isUnlocked: Boolean) {
        val isDeviceUnlocked by collectLastValue(deviceUnlockedInteractor.isDeviceUnlocked)
        deviceEntryRepository.setUnlocked(isUnlocked)
+107 −1
Original line number Diff line number Diff line
@@ -18,15 +18,32 @@ package com.android.systemui.shade.domain.startable

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.compose.animation.scene.SceneKey
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository
import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.fakeSceneDataSource
import com.android.systemui.shade.ShadeExpansionChangeEvent
import com.android.systemui.shade.ShadeExpansionListener
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith
@@ -34,11 +51,15 @@ import org.junit.runner.RunWith
@SmallTest
@RunWith(AndroidJUnit4::class)
class ShadeStartableTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val shadeInteractor = kosmos.shadeInteractor
    private val sceneInteractor = kosmos.sceneInteractor
    private val shadeExpansionStateManager = kosmos.shadeExpansionStateManager
    private val deviceEntryRepository = kosmos.fakeDeviceEntryRepository
    private val deviceUnlockedInteractor = kosmos.deviceUnlockedInteractor
    private val fakeConfigurationRepository = kosmos.fakeConfigurationRepository
    private val fakeSceneDataSource = kosmos.fakeSceneDataSource

    private val underTest = kosmos.shadeStartable

@@ -59,4 +80,89 @@ class ShadeStartableTest : SysuiTestCase() {
            fakeConfigurationRepository.onAnyConfigurationChange()
            assertThat(shadeMode).isEqualTo(ShadeMode.Single)
        }

    @Test
    @EnableSceneContainer
    fun hydrateShadeExpansionStateManager() =
        testScope.runTest {
            val expansionListener = mock<ShadeExpansionListener>()
            var latestChangeEvent: ShadeExpansionChangeEvent? = null
            whenever(expansionListener.onPanelExpansionChanged(any())).thenAnswer {
                latestChangeEvent = it.arguments[0] as ShadeExpansionChangeEvent
                Unit
            }
            shadeExpansionStateManager.addExpansionListener(expansionListener)

            underTest.start()

            setUnlocked(true)
            val transitionState =
                MutableStateFlow<ObservableTransitionState>(
                    ObservableTransitionState.Idle(Scenes.Gone)
                )
            sceneInteractor.setTransitionState(transitionState)

            changeScene(Scenes.Gone, transitionState)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            assertThat(currentScene).isEqualTo(Scenes.Gone)

            assertThat(latestChangeEvent)
                .isEqualTo(
                    ShadeExpansionChangeEvent(
                        fraction = 0f,
                        expanded = false,
                        tracking = false,
                    )
                )

            changeScene(Scenes.Shade, transitionState) { progress ->
                assertThat(latestChangeEvent?.fraction).isEqualTo(progress)
            }
        }

    private fun TestScope.setUnlocked(isUnlocked: Boolean) {
        val isDeviceUnlocked by collectLastValue(deviceUnlockedInteractor.isDeviceUnlocked)
        deviceEntryRepository.setUnlocked(isUnlocked)
        runCurrent()

        assertThat(isDeviceUnlocked).isEqualTo(isUnlocked)
    }

    private fun TestScope.changeScene(
        toScene: SceneKey,
        transitionState: MutableStateFlow<ObservableTransitionState>,
        assertDuringProgress: ((progress: Float) -> Unit) = {},
    ) {
        val currentScene by collectLastValue(sceneInteractor.currentScene)
        val progressFlow = MutableStateFlow(0f)
        transitionState.value =
            ObservableTransitionState.Transition(
                fromScene = checkNotNull(currentScene),
                toScene = toScene,
                progress = progressFlow,
                isInitiatedByUserInput = true,
                isUserInputOngoing = flowOf(true),
            )
        runCurrent()
        assertDuringProgress(progressFlow.value)

        progressFlow.value = 0.2f
        runCurrent()
        assertDuringProgress(progressFlow.value)

        progressFlow.value = 0.6f
        runCurrent()
        assertDuringProgress(progressFlow.value)

        progressFlow.value = 1f
        runCurrent()
        assertDuringProgress(progressFlow.value)

        transitionState.value = ObservableTransitionState.Idle(toScene)
        fakeSceneDataSource.changeScene(toScene)
        runCurrent()
        assertDuringProgress(progressFlow.value)

        assertThat(currentScene).isEqualTo(toScene)
    }
}
Loading