[Media TTT] Use the app's package name to fetch its icon.
Fixes: 216141279 Fixes: 216141276 Bug: 217418566 Test: Verify systemui's icon is shown on the chip Change-Id: Ia933b9c0187ea70a8fb262ad5be80d3ac0368e0d
This commit is contained in:
@@ -78,6 +78,7 @@ class MediaTttCommandLineHelper @Inject constructor(
|
||||
override fun execute(pw: PrintWriter, args: List<String>) {
|
||||
val routeInfo = MediaRoute2Info.Builder("id", args[0])
|
||||
.addFeature("feature")
|
||||
.setPackageName(TEST_PACKAGE_NAME)
|
||||
.build()
|
||||
|
||||
val commandName = args[1]
|
||||
@@ -137,6 +138,11 @@ class MediaTttCommandLineHelper @Inject constructor(
|
||||
override fun execute(pw: PrintWriter, args: List<String>) {
|
||||
val statusBarManager = context.getSystemService(Context.STATUS_BAR_SERVICE)
|
||||
as StatusBarManager
|
||||
val routeInfo = MediaRoute2Info.Builder("id", "Test Name")
|
||||
.addFeature("feature")
|
||||
.setPackageName(TEST_PACKAGE_NAME)
|
||||
.build()
|
||||
|
||||
when(val commandName = args[0]) {
|
||||
CLOSE_TO_SENDER_STATE ->
|
||||
statusBarManager.updateMediaTapToTransferReceiverDisplay(
|
||||
@@ -170,7 +176,4 @@ const val CLOSE_TO_SENDER_STATE = "CloseToSender"
|
||||
@VisibleForTesting
|
||||
const val FAR_FROM_SENDER_STATE = "FarFromSender"
|
||||
private const val CLI_TAG = "MediaTransferCli"
|
||||
|
||||
private val routeInfo = MediaRoute2Info.Builder("id", "Test Name")
|
||||
.addFeature("feature")
|
||||
.build()
|
||||
private const val TEST_PACKAGE_NAME = "com.android.systemui"
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.content.Context
|
||||
import android.graphics.PixelFormat
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import com.android.internal.widget.CachingIconView
|
||||
@@ -100,10 +101,17 @@ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>(
|
||||
* This is in the common superclass since both the sender and the receiver show an icon.
|
||||
*/
|
||||
internal fun setIcon(chipState: T, currentChipView: ViewGroup) {
|
||||
currentChipView.findViewById<CachingIconView>(R.id.app_icon).apply {
|
||||
this.setImageDrawable(chipState.appIconDrawable)
|
||||
this.contentDescription = chipState.appIconContentDescription
|
||||
val appIconView = currentChipView.findViewById<CachingIconView>(R.id.app_icon)
|
||||
appIconView.contentDescription = chipState.appIconContentDescription
|
||||
|
||||
val appIcon = chipState.getAppIcon(context)
|
||||
val visibility = if (appIcon != null) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
appIconView.setImageDrawable(appIcon)
|
||||
appIconView.visibility = visibility
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,31 @@
|
||||
|
||||
package com.android.systemui.media.taptotransfer.common
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.Log
|
||||
|
||||
/**
|
||||
* A superclass chip state that will be subclassed by the sender chip and receiver chip.
|
||||
*
|
||||
* @property appIconDrawable a drawable representing the icon of the app playing the media.
|
||||
* @property appPackageName the package name of the app playing the media. Will be used to fetch the
|
||||
* app icon.
|
||||
* @property appIconContentDescription a string to use as the content description for the icon.
|
||||
*/
|
||||
open class MediaTttChipState(
|
||||
internal val appIconDrawable: Drawable,
|
||||
internal val appPackageName: String?,
|
||||
internal val appIconContentDescription: String
|
||||
)
|
||||
) {
|
||||
fun getAppIcon(context: Context): Drawable? {
|
||||
appPackageName ?: return null
|
||||
return try {
|
||||
context.packageManager.getApplicationIcon(appPackageName)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
Log.w(TAG, "Cannot find icon for package $appPackageName", e)
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val TAG = MediaTttChipState::class.simpleName!!
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.systemui.media.taptotransfer.receiver
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import com.android.systemui.media.taptotransfer.common.MediaTttChipState
|
||||
|
||||
/**
|
||||
@@ -24,6 +23,6 @@ import com.android.systemui.media.taptotransfer.common.MediaTttChipState
|
||||
* the receiver device.
|
||||
*/
|
||||
class ChipStateReceiver(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String
|
||||
) : MediaTttChipState(appIconDrawable, appIconContentDescription)
|
||||
) : MediaTttChipState(appPackageName, appIconContentDescription)
|
||||
|
||||
@@ -18,8 +18,6 @@ package com.android.systemui.media.taptotransfer.receiver
|
||||
|
||||
import android.app.StatusBarManager
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Icon
|
||||
import android.media.MediaRoute2Info
|
||||
import android.util.Log
|
||||
import android.view.ViewGroup
|
||||
@@ -43,12 +41,6 @@ class MediaTttChipControllerReceiver @Inject constructor(
|
||||
) : MediaTttChipControllerCommon<ChipStateReceiver>(
|
||||
context, windowManager, R.layout.media_ttt_chip_receiver
|
||||
) {
|
||||
// TODO(b/216141279): Use app icon from media route info instead of this fake one.
|
||||
private val fakeAppIconDrawable =
|
||||
Icon.createWithResource(context, R.drawable.ic_avatar_user).loadDrawable(context).also {
|
||||
it.setTint(Color.YELLOW)
|
||||
}
|
||||
|
||||
private val commandQueueCallbacks = object : CommandQueue.Callbacks {
|
||||
override fun updateMediaTapToTransferReceiverDisplay(
|
||||
@StatusBarManager.MediaTransferReceiverState displayState: Int,
|
||||
@@ -70,7 +62,7 @@ class MediaTttChipControllerReceiver @Inject constructor(
|
||||
) {
|
||||
when(displayState) {
|
||||
StatusBarManager.MEDIA_TRANSFER_RECEIVER_STATE_CLOSE_TO_SENDER ->
|
||||
displayChip(ChipStateReceiver(fakeAppIconDrawable, routeInfo.name.toString()))
|
||||
displayChip(ChipStateReceiver(routeInfo.packageName, routeInfo.name.toString()))
|
||||
StatusBarManager.MEDIA_TRANSFER_RECEIVER_STATE_FAR_FROM_SENDER -> removeChip()
|
||||
else ->
|
||||
Log.e(RECEIVER_TAG, "Unhandled MediaTransferReceiverState $displayState")
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.systemui.media.taptotransfer.sender
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import com.android.internal.statusbar.IUndoMediaTransferCallback
|
||||
import com.android.systemui.R
|
||||
@@ -31,9 +30,9 @@ import com.android.systemui.media.taptotransfer.common.MediaTttChipState
|
||||
* contain additional information that is necessary for only that state.
|
||||
*/
|
||||
sealed class ChipStateSender(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String
|
||||
) : MediaTttChipState(appIconDrawable, appIconContentDescription) {
|
||||
) : MediaTttChipState(appPackageName, appIconContentDescription) {
|
||||
/** Returns a fully-formed string with the text that the chip should display. */
|
||||
abstract fun getChipTextString(context: Context): String
|
||||
|
||||
@@ -60,10 +59,10 @@ sealed class ChipStateSender(
|
||||
* @property otherDeviceName the name of the other device involved in the transfer.
|
||||
*/
|
||||
class AlmostCloseToStartCast(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String,
|
||||
private val otherDeviceName: String,
|
||||
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
|
||||
) : ChipStateSender(appPackageName, appIconContentDescription) {
|
||||
override fun getChipTextString(context: Context): String {
|
||||
return context.getString(R.string.media_move_closer_to_start_cast, otherDeviceName)
|
||||
}
|
||||
@@ -77,10 +76,10 @@ class AlmostCloseToStartCast(
|
||||
* @property otherDeviceName the name of the other device involved in the transfer.
|
||||
*/
|
||||
class AlmostCloseToEndCast(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String,
|
||||
private val otherDeviceName: String,
|
||||
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
|
||||
) : ChipStateSender(appPackageName, appIconContentDescription) {
|
||||
override fun getChipTextString(context: Context): String {
|
||||
return context.getString(R.string.media_move_closer_to_end_cast, otherDeviceName)
|
||||
}
|
||||
@@ -93,10 +92,10 @@ class AlmostCloseToEndCast(
|
||||
* @property otherDeviceName the name of the other device involved in the transfer.
|
||||
*/
|
||||
class TransferToReceiverTriggered(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String,
|
||||
private val otherDeviceName: String
|
||||
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
|
||||
) : ChipStateSender(appPackageName, appIconContentDescription) {
|
||||
override fun getChipTextString(context: Context): String {
|
||||
return context.getString(R.string.media_transfer_playing_different_device, otherDeviceName)
|
||||
}
|
||||
@@ -109,9 +108,9 @@ class TransferToReceiverTriggered(
|
||||
* sender) has been initiated (but not completed).
|
||||
*/
|
||||
class TransferToThisDeviceTriggered(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String
|
||||
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
|
||||
) : ChipStateSender(appPackageName, appIconContentDescription) {
|
||||
override fun getChipTextString(context: Context): String {
|
||||
return context.getString(R.string.media_transfer_playing_this_device)
|
||||
}
|
||||
@@ -127,11 +126,11 @@ class TransferToThisDeviceTriggered(
|
||||
* undo button. The undo button will only be shown if this is non-null.
|
||||
*/
|
||||
class TransferToReceiverSucceeded(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String,
|
||||
private val otherDeviceName: String,
|
||||
val undoCallback: IUndoMediaTransferCallback? = null
|
||||
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
|
||||
) : ChipStateSender(appPackageName, appIconContentDescription) {
|
||||
override fun getChipTextString(context: Context): String {
|
||||
return context.getString(R.string.media_transfer_playing_different_device, otherDeviceName)
|
||||
}
|
||||
@@ -150,7 +149,7 @@ class TransferToReceiverSucceeded(
|
||||
// to why the UI hasn't changed yet. So, we immediately change the UI here.
|
||||
controllerSender.displayChip(
|
||||
TransferToThisDeviceTriggered(
|
||||
this.appIconDrawable,
|
||||
this.appPackageName,
|
||||
this.appIconContentDescription
|
||||
)
|
||||
)
|
||||
@@ -166,11 +165,11 @@ class TransferToReceiverSucceeded(
|
||||
* undo button. The undo button will only be shown if this is non-null.
|
||||
*/
|
||||
class TransferToThisDeviceSucceeded(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String,
|
||||
private val otherDeviceName: String,
|
||||
val undoCallback: IUndoMediaTransferCallback? = null
|
||||
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
|
||||
) : ChipStateSender(appPackageName, appIconContentDescription) {
|
||||
override fun getChipTextString(context: Context): String {
|
||||
return context.getString(R.string.media_transfer_playing_this_device)
|
||||
}
|
||||
@@ -189,7 +188,7 @@ class TransferToThisDeviceSucceeded(
|
||||
// to why the UI hasn't changed yet. So, we immediately change the UI here.
|
||||
controllerSender.displayChip(
|
||||
TransferToReceiverTriggered(
|
||||
this.appIconDrawable,
|
||||
this.appPackageName,
|
||||
this.appIconContentDescription,
|
||||
this.otherDeviceName
|
||||
)
|
||||
@@ -200,9 +199,9 @@ class TransferToThisDeviceSucceeded(
|
||||
|
||||
/** A state representing that a transfer has failed. */
|
||||
class TransferFailed(
|
||||
appIconDrawable: Drawable,
|
||||
appPackageName: String?,
|
||||
appIconContentDescription: String
|
||||
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
|
||||
) : ChipStateSender(appPackageName, appIconContentDescription) {
|
||||
override fun getChipTextString(context: Context): String {
|
||||
return context.getString(R.string.media_transfer_failed)
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ package com.android.systemui.media.taptotransfer.sender
|
||||
|
||||
import android.app.StatusBarManager
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Icon
|
||||
import android.media.MediaRoute2Info
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
@@ -45,12 +43,6 @@ class MediaTttChipControllerSender @Inject constructor(
|
||||
) : MediaTttChipControllerCommon<ChipStateSender>(
|
||||
context, windowManager, R.layout.media_ttt_chip
|
||||
) {
|
||||
// TODO(b/216141276): Use app icon from media route info instead of this fake one.
|
||||
private val fakeAppIconDrawable =
|
||||
Icon.createWithResource(context, R.drawable.ic_avatar_user).loadDrawable(context).also {
|
||||
it.setTint(Color.YELLOW)
|
||||
}
|
||||
|
||||
private val commandQueueCallbacks = object : CommandQueue.Callbacks {
|
||||
override fun updateMediaTapToTransferSenderDisplay(
|
||||
@StatusBarManager.MediaTransferSenderState displayState: Int,
|
||||
@@ -75,34 +67,35 @@ class MediaTttChipControllerSender @Inject constructor(
|
||||
// TODO(b/217418566): This app icon content description is incorrect --
|
||||
// routeInfo.name is the name of the device, not the name of the app.
|
||||
val appIconContentDescription = routeInfo.name.toString()
|
||||
val appPackageName = routeInfo.packageName
|
||||
val otherDeviceName = routeInfo.name.toString()
|
||||
val chipState = when(displayState) {
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_ALMOST_CLOSE_TO_START_CAST ->
|
||||
AlmostCloseToStartCast(
|
||||
fakeAppIconDrawable, appIconContentDescription, otherDeviceName
|
||||
appPackageName, appIconContentDescription, otherDeviceName
|
||||
)
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_ALMOST_CLOSE_TO_END_CAST ->
|
||||
AlmostCloseToEndCast(
|
||||
fakeAppIconDrawable, appIconContentDescription, otherDeviceName
|
||||
appPackageName, appIconContentDescription, otherDeviceName
|
||||
)
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_TRIGGERED ->
|
||||
TransferToReceiverTriggered(
|
||||
fakeAppIconDrawable, appIconContentDescription, otherDeviceName
|
||||
appPackageName, appIconContentDescription, otherDeviceName
|
||||
)
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_THIS_DEVICE_TRIGGERED ->
|
||||
TransferToThisDeviceTriggered(
|
||||
fakeAppIconDrawable, appIconContentDescription
|
||||
appPackageName, appIconContentDescription
|
||||
)
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_SUCCEEDED ->
|
||||
TransferToReceiverSucceeded(
|
||||
fakeAppIconDrawable,
|
||||
appPackageName,
|
||||
appIconContentDescription,
|
||||
otherDeviceName,
|
||||
undoCallback
|
||||
)
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_THIS_DEVICE_SUCCEEDED ->
|
||||
TransferToThisDeviceSucceeded(
|
||||
fakeAppIconDrawable,
|
||||
appPackageName,
|
||||
appIconContentDescription,
|
||||
otherDeviceName,
|
||||
undoCallback
|
||||
@@ -110,7 +103,7 @@ class MediaTttChipControllerSender @Inject constructor(
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_FAILED,
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_THIS_DEVICE_FAILED ->
|
||||
TransferFailed(
|
||||
fakeAppIconDrawable, appIconContentDescription
|
||||
appPackageName, appIconContentDescription
|
||||
)
|
||||
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_FAR_FROM_RECEIVER -> {
|
||||
removeChip()
|
||||
|
||||
@@ -92,16 +92,16 @@ class MediaTttChipControllerCommonTest : SysuiTestCase() {
|
||||
fun setIcon_viewHasIconAndContentDescription() {
|
||||
controllerCommon.displayChip(getState())
|
||||
val chipView = getChipView()
|
||||
val drawable = Icon.createWithResource(context, R.drawable.ic_cake).loadDrawable(context)
|
||||
val contentDescription = "test description"
|
||||
|
||||
controllerCommon.setIcon(MediaTttChipState(drawable, contentDescription), chipView)
|
||||
val state = MediaTttChipState(PACKAGE_NAME, contentDescription)
|
||||
controllerCommon.setIcon(state, chipView)
|
||||
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(drawable)
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
|
||||
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(contentDescription)
|
||||
}
|
||||
|
||||
private fun getState() = MediaTttChipState(appIconDrawable, APP_ICON_CONTENT_DESCRIPTION)
|
||||
private fun getState() = MediaTttChipState(PACKAGE_NAME, APP_ICON_CONTENT_DESCRIPTION)
|
||||
|
||||
private fun getChipView(): ViewGroup {
|
||||
val viewCaptor = ArgumentCaptor.forClass(View::class.java)
|
||||
@@ -122,4 +122,5 @@ class MediaTttChipControllerCommonTest : SysuiTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
private const val PACKAGE_NAME = "com.android.systemui"
|
||||
private const val APP_ICON_CONTENT_DESCRIPTION = "Content description"
|
||||
|
||||
@@ -101,7 +101,7 @@ class MediaTttChipControllerReceiverTest : SysuiTestCase() {
|
||||
val drawable = Icon.createWithResource(context, R.drawable.ic_cake).loadDrawable(context)
|
||||
val contentDescription = "Test description"
|
||||
|
||||
controllerReceiver.displayChip(ChipStateReceiver(drawable, contentDescription))
|
||||
controllerReceiver.displayChip(ChipStateReceiver(PACKAGE_NAME, contentDescription))
|
||||
|
||||
assertThat(getChipView().getAppIconView().drawable).isEqualTo(drawable)
|
||||
assertThat(getChipView().getAppIconView().contentDescription).isEqualTo(contentDescription)
|
||||
@@ -117,6 +117,9 @@ class MediaTttChipControllerReceiverTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
private const val ROUTE_NAME = "Test name"
|
||||
private const val PACKAGE_NAME = "com.android.systemui"
|
||||
|
||||
private val routeInfo = MediaRoute2Info.Builder("id", ROUTE_NAME)
|
||||
.addFeature("feature")
|
||||
.setPackageName(PACKAGE_NAME)
|
||||
.build()
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package com.android.systemui.media.taptotransfer.sender
|
||||
|
||||
import android.app.StatusBarManager
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.Icon
|
||||
import android.media.MediaRoute2Info
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
@@ -44,8 +42,6 @@ import org.mockito.MockitoAnnotations
|
||||
@SmallTest
|
||||
@Ignore("b/216286227")
|
||||
class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
private lateinit var appIconDrawable: Drawable
|
||||
|
||||
private lateinit var controllerSender: MediaTttChipControllerSender
|
||||
|
||||
@Mock
|
||||
@@ -57,7 +53,6 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
appIconDrawable = Icon.createWithResource(context, R.drawable.ic_cake).loadDrawable(context)
|
||||
controllerSender = MediaTttChipControllerSender(commandQueue, context, windowManager)
|
||||
|
||||
val callbackCaptor = ArgumentCaptor.forClass(CommandQueue.Callbacks::class.java)
|
||||
@@ -197,7 +192,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
controllerSender.displayChip(state)
|
||||
|
||||
val chipView = getChipView()
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
|
||||
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
|
||||
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
|
||||
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
|
||||
@@ -211,7 +206,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
controllerSender.displayChip(state)
|
||||
|
||||
val chipView = getChipView()
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
|
||||
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
|
||||
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
|
||||
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
|
||||
@@ -225,7 +220,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
controllerSender.displayChip(state)
|
||||
|
||||
val chipView = getChipView()
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
|
||||
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
|
||||
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
|
||||
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.VISIBLE)
|
||||
@@ -239,7 +234,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
controllerSender.displayChip(state)
|
||||
|
||||
val chipView = getChipView()
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
|
||||
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
|
||||
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
|
||||
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.VISIBLE)
|
||||
@@ -253,7 +248,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
controllerSender.displayChip(state)
|
||||
|
||||
val chipView = getChipView()
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
|
||||
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
|
||||
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
|
||||
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
|
||||
@@ -314,7 +309,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
controllerSender.displayChip(state)
|
||||
|
||||
val chipView = getChipView()
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
|
||||
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
|
||||
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
|
||||
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
|
||||
@@ -375,7 +370,7 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
controllerSender.displayChip(state)
|
||||
|
||||
val chipView = getChipView()
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
|
||||
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
|
||||
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
|
||||
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
|
||||
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
|
||||
@@ -449,39 +444,41 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
||||
|
||||
/** Helper method providing default parameters to not clutter up the tests. */
|
||||
private fun almostCloseToStartCast() =
|
||||
AlmostCloseToStartCast(appIconDrawable, APP_ICON_CONTENT_DESC, DEVICE_NAME)
|
||||
AlmostCloseToStartCast(PACKAGE_NAME, APP_ICON_CONTENT_DESC, DEVICE_NAME)
|
||||
|
||||
/** Helper method providing default parameters to not clutter up the tests. */
|
||||
private fun almostCloseToEndCast() =
|
||||
AlmostCloseToEndCast(appIconDrawable, APP_ICON_CONTENT_DESC, DEVICE_NAME)
|
||||
AlmostCloseToEndCast(PACKAGE_NAME, APP_ICON_CONTENT_DESC, DEVICE_NAME)
|
||||
|
||||
/** Helper method providing default parameters to not clutter up the tests. */
|
||||
private fun transferToReceiverTriggered() =
|
||||
TransferToReceiverTriggered(appIconDrawable, APP_ICON_CONTENT_DESC, DEVICE_NAME)
|
||||
TransferToReceiverTriggered(PACKAGE_NAME, APP_ICON_CONTENT_DESC, DEVICE_NAME)
|
||||
|
||||
/** Helper method providing default parameters to not clutter up the tests. */
|
||||
private fun transferToThisDeviceTriggered() =
|
||||
TransferToThisDeviceTriggered(appIconDrawable, APP_ICON_CONTENT_DESC)
|
||||
TransferToThisDeviceTriggered(PACKAGE_NAME, APP_ICON_CONTENT_DESC)
|
||||
|
||||
/** Helper method providing default parameters to not clutter up the tests. */
|
||||
private fun transferToReceiverSucceeded(undoCallback: IUndoMediaTransferCallback? = null) =
|
||||
TransferToReceiverSucceeded(
|
||||
appIconDrawable, APP_ICON_CONTENT_DESC, DEVICE_NAME, undoCallback
|
||||
PACKAGE_NAME, APP_ICON_CONTENT_DESC, DEVICE_NAME, undoCallback
|
||||
)
|
||||
|
||||
/** Helper method providing default parameters to not clutter up the tests. */
|
||||
private fun transferToThisDeviceSucceeded(undoCallback: IUndoMediaTransferCallback? = null) =
|
||||
TransferToThisDeviceSucceeded(
|
||||
appIconDrawable, APP_ICON_CONTENT_DESC, DEVICE_NAME, undoCallback
|
||||
PACKAGE_NAME, APP_ICON_CONTENT_DESC, DEVICE_NAME, undoCallback
|
||||
)
|
||||
|
||||
/** Helper method providing default parameters to not clutter up the tests. */
|
||||
private fun transferFailed() = TransferFailed(appIconDrawable, APP_ICON_CONTENT_DESC)
|
||||
private fun transferFailed() = TransferFailed(PACKAGE_NAME, APP_ICON_CONTENT_DESC)
|
||||
}
|
||||
|
||||
private const val DEVICE_NAME = "My Tablet"
|
||||
private const val APP_ICON_CONTENT_DESC = "Content description"
|
||||
private const val PACKAGE_NAME = "com.android.systemui"
|
||||
|
||||
private val routeInfo = MediaRoute2Info.Builder("id", "Test Name")
|
||||
.addFeature("feature")
|
||||
.setPackageName(PACKAGE_NAME)
|
||||
.build()
|
||||
|
||||
Reference in New Issue
Block a user