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

Commit dc84a25a authored by Michael Mikhail's avatar Michael Mikhail Committed by Automerger Merge Worker
Browse files

Merge "[Media TTT] Use a default name if blank string is given" into...

Merge "[Media TTT] Use a default name if blank string is given" into tm-qpr-dev am: fdb815d7 am: 682376ec

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20870164



Change-Id: Icd1ff8ed2401e41b32a87fd8c62487d72d00594b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 9be94347 682376ec
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2470,6 +2470,8 @@
    <string name="media_transfer_failed">Something went wrong. Try again.</string>
    <!-- Text to indicate that a media transfer is currently in-progress, aka loading. [CHAR LIMIT=NONE] -->
    <string name="media_transfer_loading">Loading</string>
    <!-- Default name of the device. [CHAR LIMIT=30] -->
    <string name="media_ttt_default_device_type">tablet</string>

    <!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] -->
    <string name="controls_error_timeout">Inactive, check app</string>
+6 −1
Original line number Diff line number Diff line
@@ -150,7 +150,12 @@ constructor(
        logger: MediaTttLogger<ChipbarInfo>,
    ): ChipbarInfo {
        val packageName = routeInfo.clientPackageName
        val otherDeviceName = routeInfo.name.toString()
        val otherDeviceName =
            if (routeInfo.name.isBlank()) {
                context.getString(R.string.media_ttt_default_device_type)
            } else {
                routeInfo.name.toString()
            }

        return ChipbarInfo(
            // Display the app's icon as the start icon
+37 −0
Original line number Diff line number Diff line
@@ -205,6 +205,21 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        verify(vibratorHelper).vibrate(any<VibrationEffect>())
    }

    @Test
    fun commandQueueCallback_almostCloseToStartCast_deviceNameBlank_showsDefaultDeviceName() {
        commandQueueCallback.updateMediaTapToTransferSenderDisplay(
            StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_ALMOST_CLOSE_TO_START_CAST,
            routeInfoWithBlankDeviceName,
            null,
        )

        val chipbarView = getChipbarView()
        assertThat(chipbarView.getChipText())
            .contains(context.getString(R.string.media_ttt_default_device_type))
        assertThat(chipbarView.getChipText())
            .isNotEqualTo(ChipStateSender.ALMOST_CLOSE_TO_START_CAST.getExpectedStateText())
    }

    @Test
    fun commandQueueCallback_almostCloseToEndCast_triggersCorrectChip() {
        commandQueueCallback.updateMediaTapToTransferSenderDisplay(
@@ -247,6 +262,21 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        verify(vibratorHelper).vibrate(any<VibrationEffect>())
    }

    @Test
    fun commandQueueCallback_transferToReceiverTriggered_deviceNameBlank_showsDefaultDeviceName() {
        commandQueueCallback.updateMediaTapToTransferSenderDisplay(
            StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_TRIGGERED,
            routeInfoWithBlankDeviceName,
            null,
        )

        val chipbarView = getChipbarView()
        assertThat(chipbarView.getChipText())
            .contains(context.getString(R.string.media_ttt_default_device_type))
        assertThat(chipbarView.getChipText())
            .isNotEqualTo(ChipStateSender.TRANSFER_TO_RECEIVER_TRIGGERED.getExpectedStateText())
    }

    @Test
    fun commandQueueCallback_transferToThisDeviceTriggered_triggersCorrectChip() {
        commandQueueCallback.updateMediaTapToTransferSenderDisplay(
@@ -934,6 +964,7 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {

private const val APP_NAME = "Fake app name"
private const val OTHER_DEVICE_NAME = "My Tablet"
private const val BLANK_DEVICE_NAME = " "
private const val PACKAGE_NAME = "com.android.systemui"
private const val TIMEOUT = 10000

@@ -942,3 +973,9 @@ private val routeInfo =
        .addFeature("feature")
        .setClientPackageName(PACKAGE_NAME)
        .build()

private val routeInfoWithBlankDeviceName =
    MediaRoute2Info.Builder("id", BLANK_DEVICE_NAME)
        .addFeature("feature")
        .setClientPackageName(PACKAGE_NAME)
        .build()