Merge changes I59ef37d2,Ia933b9c0

* changes:
  [Media TTT] Use the app's package name to fetch the icon content description.
  [Media TTT] Use the app's package name to fetch its icon.
This commit is contained in:
TreeHugger Robot
2022-02-10 20:22:58 +00:00
committed by Android (Google) Code Review
10 changed files with 125 additions and 135 deletions

View File

@@ -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"

View File

@@ -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.requireViewById<CachingIconView>(R.id.app_icon)
appIconView.contentDescription = chipState.getAppName(context)
val appIcon = chipState.getAppIcon(context)
val visibility = if (appIcon != null) {
View.VISIBLE
} else {
View.GONE
}
appIconView.setImageDrawable(appIcon)
appIconView.visibility = visibility
}
}

View File

@@ -16,15 +16,42 @@
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 appIconContentDescription a string to use as the content description for the icon.
* @property appPackageName the package name of the app playing the media. Will be used to fetch the
* app icon and app name.
*/
open class MediaTttChipState(
internal val appIconDrawable: Drawable,
internal val appIconContentDescription: String
)
internal val appPackageName: 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
}
}
/** Returns the name of the app playing the media or null if we can't find it. */
fun getAppName(context: Context): String? {
appPackageName ?: return null
return try {
context.packageManager.getApplicationInfo(
appPackageName, PackageManager.ApplicationInfoFlags.of(0)
).loadLabel(context.packageManager).toString()
} catch (e: PackageManager.NameNotFoundException) {
Log.w(TAG, "Cannot find name for package $appPackageName", e)
null
}
}
}
private val TAG = MediaTttChipState::class.simpleName!!

View File

@@ -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,5 @@ import com.android.systemui.media.taptotransfer.common.MediaTttChipState
* the receiver device.
*/
class ChipStateReceiver(
appIconDrawable: Drawable,
appIconContentDescription: String
) : MediaTttChipState(appIconDrawable, appIconContentDescription)
appPackageName: String?,
) : MediaTttChipState(appPackageName)

View File

@@ -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))
StatusBarManager.MEDIA_TRANSFER_RECEIVER_STATE_FAR_FROM_SENDER -> removeChip()
else ->
Log.e(RECEIVER_TAG, "Unhandled MediaTransferReceiverState $displayState")
@@ -82,4 +74,4 @@ class MediaTttChipControllerReceiver @Inject constructor(
}
}
private const val RECEIVER_TAG = "MediaTapToTransferReceiver"
private const val RECEIVER_TAG = "MediaTapToTransferRcvr"

View File

@@ -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,8 @@ import com.android.systemui.media.taptotransfer.common.MediaTttChipState
* contain additional information that is necessary for only that state.
*/
sealed class ChipStateSender(
appIconDrawable: Drawable,
appIconContentDescription: String
) : MediaTttChipState(appIconDrawable, appIconContentDescription) {
appPackageName: String?
) : MediaTttChipState(appPackageName) {
/** Returns a fully-formed string with the text that the chip should display. */
abstract fun getChipTextString(context: Context): String
@@ -60,10 +58,9 @@ sealed class ChipStateSender(
* @property otherDeviceName the name of the other device involved in the transfer.
*/
class AlmostCloseToStartCast(
appIconDrawable: Drawable,
appIconContentDescription: String,
appPackageName: String?,
private val otherDeviceName: String,
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
) : ChipStateSender(appPackageName) {
override fun getChipTextString(context: Context): String {
return context.getString(R.string.media_move_closer_to_start_cast, otherDeviceName)
}
@@ -77,10 +74,9 @@ class AlmostCloseToStartCast(
* @property otherDeviceName the name of the other device involved in the transfer.
*/
class AlmostCloseToEndCast(
appIconDrawable: Drawable,
appIconContentDescription: String,
appPackageName: String?,
private val otherDeviceName: String,
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
) : ChipStateSender(appPackageName) {
override fun getChipTextString(context: Context): String {
return context.getString(R.string.media_move_closer_to_end_cast, otherDeviceName)
}
@@ -93,10 +89,9 @@ class AlmostCloseToEndCast(
* @property otherDeviceName the name of the other device involved in the transfer.
*/
class TransferToReceiverTriggered(
appIconDrawable: Drawable,
appIconContentDescription: String,
appPackageName: String?,
private val otherDeviceName: String
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
) : ChipStateSender(appPackageName) {
override fun getChipTextString(context: Context): String {
return context.getString(R.string.media_transfer_playing_different_device, otherDeviceName)
}
@@ -109,9 +104,8 @@ class TransferToReceiverTriggered(
* sender) has been initiated (but not completed).
*/
class TransferToThisDeviceTriggered(
appIconDrawable: Drawable,
appIconContentDescription: String
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
appPackageName: String?,
) : ChipStateSender(appPackageName) {
override fun getChipTextString(context: Context): String {
return context.getString(R.string.media_transfer_playing_this_device)
}
@@ -127,11 +121,10 @@ class TransferToThisDeviceTriggered(
* undo button. The undo button will only be shown if this is non-null.
*/
class TransferToReceiverSucceeded(
appIconDrawable: Drawable,
appIconContentDescription: String,
appPackageName: String?,
private val otherDeviceName: String,
val undoCallback: IUndoMediaTransferCallback? = null
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
) : ChipStateSender(appPackageName) {
override fun getChipTextString(context: Context): String {
return context.getString(R.string.media_transfer_playing_different_device, otherDeviceName)
}
@@ -149,10 +142,7 @@ class TransferToReceiverSucceeded(
// but that may take too long to go through the binder and the user may be confused as
// to why the UI hasn't changed yet. So, we immediately change the UI here.
controllerSender.displayChip(
TransferToThisDeviceTriggered(
this.appIconDrawable,
this.appIconContentDescription
)
TransferToThisDeviceTriggered(this.appPackageName)
)
}
}
@@ -166,11 +156,10 @@ class TransferToReceiverSucceeded(
* undo button. The undo button will only be shown if this is non-null.
*/
class TransferToThisDeviceSucceeded(
appIconDrawable: Drawable,
appIconContentDescription: String,
appPackageName: String?,
private val otherDeviceName: String,
val undoCallback: IUndoMediaTransferCallback? = null
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
) : ChipStateSender(appPackageName) {
override fun getChipTextString(context: Context): String {
return context.getString(R.string.media_transfer_playing_this_device)
}
@@ -189,8 +178,7 @@ class TransferToThisDeviceSucceeded(
// to why the UI hasn't changed yet. So, we immediately change the UI here.
controllerSender.displayChip(
TransferToReceiverTriggered(
this.appIconDrawable,
this.appIconContentDescription,
this.appPackageName,
this.otherDeviceName
)
)
@@ -200,9 +188,8 @@ class TransferToThisDeviceSucceeded(
/** A state representing that a transfer has failed. */
class TransferFailed(
appIconDrawable: Drawable,
appIconContentDescription: String
) : ChipStateSender(appIconDrawable, appIconContentDescription) {
appPackageName: String?,
) : ChipStateSender(appPackageName) {
override fun getChipTextString(context: Context): String {
return context.getString(R.string.media_transfer_failed)
}

View File

@@ -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,
@@ -72,46 +64,24 @@ class MediaTttChipControllerSender @Inject constructor(
routeInfo: MediaRoute2Info,
undoCallback: IUndoMediaTransferCallback?
) {
// 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
)
AlmostCloseToStartCast(appPackageName, otherDeviceName)
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_ALMOST_CLOSE_TO_END_CAST ->
AlmostCloseToEndCast(
fakeAppIconDrawable, appIconContentDescription, otherDeviceName
)
AlmostCloseToEndCast(appPackageName, otherDeviceName)
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_TRIGGERED ->
TransferToReceiverTriggered(
fakeAppIconDrawable, appIconContentDescription, otherDeviceName
)
TransferToReceiverTriggered(appPackageName, otherDeviceName)
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_THIS_DEVICE_TRIGGERED ->
TransferToThisDeviceTriggered(
fakeAppIconDrawable, appIconContentDescription
)
TransferToThisDeviceTriggered(appPackageName)
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_SUCCEEDED ->
TransferToReceiverSucceeded(
fakeAppIconDrawable,
appIconContentDescription,
otherDeviceName,
undoCallback
)
TransferToReceiverSucceeded(appPackageName, otherDeviceName, undoCallback)
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_THIS_DEVICE_SUCCEEDED ->
TransferToThisDeviceSucceeded(
fakeAppIconDrawable,
appIconContentDescription,
otherDeviceName,
undoCallback
)
TransferToThisDeviceSucceeded(appPackageName, otherDeviceName, undoCallback)
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_FAILED,
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_THIS_DEVICE_FAILED ->
TransferFailed(
fakeAppIconDrawable, appIconContentDescription
)
TransferFailed(appPackageName)
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_FAR_FROM_RECEIVER -> {
removeChip()
null

View File

@@ -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)
controllerCommon.setIcon(state, chipView)
assertThat(chipView.getAppIconView().drawable).isEqualTo(drawable)
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(contentDescription)
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(chipView.getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
}
private fun getState() = MediaTttChipState(appIconDrawable, APP_ICON_CONTENT_DESCRIPTION)
private fun getState() = MediaTttChipState(PACKAGE_NAME)
private fun getChipView(): ViewGroup {
val viewCaptor = ArgumentCaptor.forClass(View::class.java)
@@ -122,4 +122,4 @@ class MediaTttChipControllerCommonTest : SysuiTestCase() {
}
}
private const val APP_ICON_CONTENT_DESCRIPTION = "Content description"
private const val PACKAGE_NAME = "com.android.systemui"

View File

@@ -17,7 +17,6 @@
package com.android.systemui.media.taptotransfer.receiver
import android.app.StatusBarManager
import android.graphics.drawable.Icon
import android.media.MediaRoute2Info
import android.view.View
import android.view.ViewGroup
@@ -98,13 +97,13 @@ class MediaTttChipControllerReceiverTest : SysuiTestCase() {
@Test
fun displayChip_chipContainsIcon() {
val drawable = Icon.createWithResource(context, R.drawable.ic_cake).loadDrawable(context)
val contentDescription = "Test description"
val state = ChipStateReceiver(PACKAGE_NAME)
controllerReceiver.displayChip(ChipStateReceiver(drawable, contentDescription))
controllerReceiver.displayChip(state)
assertThat(getChipView().getAppIconView().drawable).isEqualTo(drawable)
assertThat(getChipView().getAppIconView().contentDescription).isEqualTo(contentDescription)
assertThat(getChipView().getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(getChipView().getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
}
private fun getChipView(): ViewGroup {
@@ -117,6 +116,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()

View File

@@ -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,8 +192,9 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
controllerSender.displayChip(state)
val chipView = getChipView()
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(chipView.getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
assertThat(chipView.getUndoButton().visibility).isEqualTo(View.GONE)
@@ -211,8 +207,9 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
controllerSender.displayChip(state)
val chipView = getChipView()
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(chipView.getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
assertThat(chipView.getUndoButton().visibility).isEqualTo(View.GONE)
@@ -225,8 +222,9 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
controllerSender.displayChip(state)
val chipView = getChipView()
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(chipView.getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.VISIBLE)
assertThat(chipView.getUndoButton().visibility).isEqualTo(View.GONE)
@@ -239,8 +237,9 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
controllerSender.displayChip(state)
val chipView = getChipView()
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(chipView.getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.VISIBLE)
assertThat(chipView.getUndoButton().visibility).isEqualTo(View.GONE)
@@ -253,8 +252,9 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
controllerSender.displayChip(state)
val chipView = getChipView()
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(chipView.getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
assertThat(chipView.getFailureIcon().visibility).isEqualTo(View.GONE)
@@ -314,8 +314,9 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
controllerSender.displayChip(state)
val chipView = getChipView()
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(chipView.getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
assertThat(chipView.getFailureIcon().visibility).isEqualTo(View.GONE)
@@ -375,8 +376,9 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
controllerSender.displayChip(state)
val chipView = getChipView()
assertThat(chipView.getAppIconView().drawable).isEqualTo(appIconDrawable)
assertThat(chipView.getAppIconView().contentDescription).isEqualTo(APP_ICON_CONTENT_DESC)
assertThat(chipView.getAppIconView().drawable).isEqualTo(state.getAppIcon(context))
assertThat(chipView.getAppIconView().contentDescription)
.isEqualTo(state.getAppName(context))
assertThat(chipView.getChipText()).isEqualTo(state.getChipTextString(context))
assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
assertThat(chipView.getUndoButton().visibility).isEqualTo(View.GONE)
@@ -449,39 +451,40 @@ 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, 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, 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, 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)
/** 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, 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, 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)
}
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()