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

This commit is contained in:
Xiaowen Lei
2022-06-23 16:41:09 +00:00
committed by Android (Google) Code Review
3 changed files with 36 additions and 49 deletions

View File

@@ -145,9 +145,6 @@ class DreamSmartspaceController @Inject constructor(
if (view !is View) {
return null
}
view.setIsDreaming(true)
return view
} else {
null

View File

@@ -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 {
@@ -81,4 +83,4 @@ interface SmartspaceViewComponent {
return ssView
}
}
}
}

View File

@@ -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)
}
}
}