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

Commit 1e43c3b4 authored by Xiaowen Lei's avatar Xiaowen Lei Committed by Android (Google) Code Review
Browse files

Merge "Move `setIsDreaming(..);` to be right after `plugin.getView(parent);`." into tm-qpr-dev

parents 86fe9ea9 10ef287c
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -145,9 +145,6 @@ class DreamSmartspaceController @Inject constructor(
            if (view !is View) {
                return null
            }

            view.setIsDreaming(true)

            return view
        } else {
            null
+3 −1
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ interface SmartspaceViewComponent {
        ):
                BcSmartspaceDataPlugin.SmartspaceView {
            val ssView = plugin.getView(parent)
            // Currently, this is only used to provide SmartspaceView on Dream surface.
            ssView.setIsDreaming(true)
            ssView.registerDataProvider(plugin)

            ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter {
+33 −45
Original line number Diff line number Diff line
@@ -36,17 +36,17 @@ import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.withArgCaptor
import com.google.common.truth.Truth.assertThat
import java.util.Optional
import java.util.concurrent.Executor
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Spy
import org.mockito.Mockito
import org.mockito.Mockito.`when`
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
import java.util.Optional
import java.util.concurrent.Executor
import org.mockito.Spy

@SmallTest
@RunWith(AndroidTestingRunner::class)
@@ -87,6 +87,34 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {

    private lateinit var controller: DreamSmartspaceController

    /**
     * A class which implements SmartspaceView and extends View. This is mocked to provide the right
     * object inheritance and interface implementation used in DreamSmartspaceController
     */
    private class TestView(context: Context?) : View(context), SmartspaceView {
        override fun registerDataProvider(plugin: BcSmartspaceDataPlugin?) {}

        override fun setPrimaryTextColor(color: Int) {}

        override fun setIsDreaming(isDreaming: Boolean) {}

        override fun setDozeAmount(amount: Float) {}

        override fun setIntentStarter(intentStarter: BcSmartspaceDataPlugin.IntentStarter?) {}

        override fun setFalsingManager(falsingManager: FalsingManager?) {}

        override fun setDnd(image: Drawable?, description: String?) {}

        override fun setNextAlarm(image: Drawable?, description: String?) {}

        override fun setMediaTarget(target: SmartspaceTarget?) {}

        override fun getSelectedPage(): Int { return 0; }

        override fun getCurrentCardTopPadding(): Int { return 0; }
    }

    @Before
    fun setup() {
        MockitoAnnotations.initMocks(this)
@@ -129,34 +157,6 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {
        verify(session).close()
    }

    /**
     * A class which implements SmartspaceView and extends View. This is mocked to provide the right
     * object inheritance and interface implementation used in DreamSmartspaceController
     */
    private class TestView(context: Context?) : View(context), SmartspaceView {
        override fun registerDataProvider(plugin: BcSmartspaceDataPlugin?) {}

        override fun setPrimaryTextColor(color: Int) {}

        override fun setIsDreaming(isDreaming: Boolean) {}

        override fun setDozeAmount(amount: Float) {}

        override fun setIntentStarter(intentStarter: BcSmartspaceDataPlugin.IntentStarter?) {}

        override fun setFalsingManager(falsingManager: FalsingManager?) {}

        override fun setDnd(image: Drawable?, description: String?) {}

        override fun setNextAlarm(image: Drawable?, description: String?) {}

        override fun setMediaTarget(target: SmartspaceTarget?) {}

        override fun getSelectedPage(): Int { return 0; }

        override fun getCurrentCardTopPadding(): Int { return 0; }
    }

    /**
     * Ensures session begins when a view is attached.
     */
@@ -180,16 +180,4 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {

        verify(session).close()
    }

    /**
     * Ensures setIsDreaming(true) is called when the view is built.
     */
    @Test
    fun testSetIsDreamingTrueOnViewCreate() {
        `when`(precondition.conditionsMet()).thenReturn(true)

        controller.buildAndConnectView(Mockito.mock(ViewGroup::class.java))

        verify(smartspaceView).setIsDreaming(true)
    }
}