Merge "Move setIsDreaming(..); to be right after plugin.getView(parent);." into tm-qpr-dev
This commit is contained in:
@@ -145,9 +145,6 @@ class DreamSmartspaceController @Inject constructor(
|
|||||||
if (view !is View) {
|
if (view !is View) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
view.setIsDreaming(true)
|
|
||||||
|
|
||||||
return view
|
return view
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ interface SmartspaceViewComponent {
|
|||||||
):
|
):
|
||||||
BcSmartspaceDataPlugin.SmartspaceView {
|
BcSmartspaceDataPlugin.SmartspaceView {
|
||||||
val ssView = plugin.getView(parent)
|
val ssView = plugin.getView(parent)
|
||||||
|
// Currently, this is only used to provide SmartspaceView on Dream surface.
|
||||||
|
ssView.setIsDreaming(true)
|
||||||
ssView.registerDataProvider(plugin)
|
ssView.registerDataProvider(plugin)
|
||||||
|
|
||||||
ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter {
|
ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter {
|
||||||
|
|||||||
@@ -36,17 +36,17 @@ import com.android.systemui.util.mockito.any
|
|||||||
import com.android.systemui.util.mockito.eq
|
import com.android.systemui.util.mockito.eq
|
||||||
import com.android.systemui.util.mockito.withArgCaptor
|
import com.android.systemui.util.mockito.withArgCaptor
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import java.util.Optional
|
||||||
|
import java.util.concurrent.Executor
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Spy
|
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
import org.mockito.Mockito.`when`
|
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
import java.util.Optional
|
import org.mockito.Spy
|
||||||
import java.util.concurrent.Executor
|
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner::class)
|
@RunWith(AndroidTestingRunner::class)
|
||||||
@@ -87,6 +87,34 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
private lateinit var controller: DreamSmartspaceController
|
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
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
@@ -129,34 +157,6 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
verify(session).close()
|
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.
|
* Ensures session begins when a view is attached.
|
||||||
*/
|
*/
|
||||||
@@ -180,16 +180,4 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
verify(session).close()
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user