Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar; import static android.app.Notification.CATEGORY_CALL; import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertEquals; Loading Loading @@ -196,6 +198,19 @@ public class StatusBarIconViewTest extends SysuiTestCase { // no crash, good } @Test public void testContentDescForNotification_noNotifContent() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(0) .setContentTitle("hello") .setCategory(CATEGORY_CALL) .build(); assertThat(NotificationContentDescription.contentDescForNotification(mContext, n) .toString()).startsWith("com.android.systemui.tests notification"); assertThat(NotificationContentDescription.contentDescForNotification(mContext, n) .toString()).doesNotContain("hello"); } @Test @EnableFlags({Flags.FLAG_MODES_UI, Flags.FLAG_MODES_UI_ICONS}) public void setIcon_withPreloaded_usesPreloaded() { Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationContentDescriptionTest.kt +1 −23 Original line number Diff line number Diff line Loading @@ -34,31 +34,9 @@ class NotificationContentDescriptionTest : SysuiTestCase() { private val TICKER = "this is a ticker" @Test fun notificationWithAllDifferentFields_descriptionIsTitle() { fun notificationWithAllDifferentFields_descriptionIsAppName() { val n = createNotification(TITLE, TEXT, TICKER) val description = contentDescForNotification(context, n) assertThat(description).isEqualTo(createDescriptionText(n, TITLE)) } @Test fun notificationWithAllDifferentFields_titleMatchesAppName_descriptionIsText() { val n = createNotification(getTestAppName(), TEXT, TICKER) val description = contentDescForNotification(context, n) assertThat(description).isEqualTo(createDescriptionText(n, TEXT)) } @Test fun notificationWithAllDifferentFields_titleMatchesAppNameNoText_descriptionIsTicker() { val n = createNotification(getTestAppName(), null, TICKER) val description = contentDescForNotification(context, n) assertThat(description).isEqualTo(createDescriptionText(n, TICKER)) } @Test fun notificationWithAllDifferentFields_titleMatchesAppNameNoTextNoTicker_descriptionEmpty() { val appName = getTestAppName() val n = createNotification(appName, null, null) val description = contentDescForNotification(context, n) assertThat(description).isEqualTo(createDescriptionText(n, "")) } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationContentDescription.kt +1 −10 Original line number Diff line number Diff line Loading @@ -28,14 +28,5 @@ import com.android.systemui.res.R @MainThread fun contentDescForNotification(c: Context, n: Notification): CharSequence { val appName = n.loadHeaderAppName(c) ?: "" val title = n.extras?.getCharSequence(Notification.EXTRA_TITLE) val text = n.extras?.getCharSequence(Notification.EXTRA_TEXT) val ticker = n.tickerText // Some apps just put the app name into the title val titleOrText = if (TextUtils.equals(title, appName)) text else title val desc = if (!TextUtils.isEmpty(titleOrText)) titleOrText else if (!TextUtils.isEmpty(ticker)) ticker else "" return c.getString(R.string.accessibility_desc_notification_icon, appName, desc) return c.getString(R.string.accessibility_desc_notification_icon, appName, "") } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar; import static android.app.Notification.CATEGORY_CALL; import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertEquals; Loading Loading @@ -196,6 +198,19 @@ public class StatusBarIconViewTest extends SysuiTestCase { // no crash, good } @Test public void testContentDescForNotification_noNotifContent() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(0) .setContentTitle("hello") .setCategory(CATEGORY_CALL) .build(); assertThat(NotificationContentDescription.contentDescForNotification(mContext, n) .toString()).startsWith("com.android.systemui.tests notification"); assertThat(NotificationContentDescription.contentDescForNotification(mContext, n) .toString()).doesNotContain("hello"); } @Test @EnableFlags({Flags.FLAG_MODES_UI, Flags.FLAG_MODES_UI_ICONS}) public void setIcon_withPreloaded_usesPreloaded() { Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationContentDescriptionTest.kt +1 −23 Original line number Diff line number Diff line Loading @@ -34,31 +34,9 @@ class NotificationContentDescriptionTest : SysuiTestCase() { private val TICKER = "this is a ticker" @Test fun notificationWithAllDifferentFields_descriptionIsTitle() { fun notificationWithAllDifferentFields_descriptionIsAppName() { val n = createNotification(TITLE, TEXT, TICKER) val description = contentDescForNotification(context, n) assertThat(description).isEqualTo(createDescriptionText(n, TITLE)) } @Test fun notificationWithAllDifferentFields_titleMatchesAppName_descriptionIsText() { val n = createNotification(getTestAppName(), TEXT, TICKER) val description = contentDescForNotification(context, n) assertThat(description).isEqualTo(createDescriptionText(n, TEXT)) } @Test fun notificationWithAllDifferentFields_titleMatchesAppNameNoText_descriptionIsTicker() { val n = createNotification(getTestAppName(), null, TICKER) val description = contentDescForNotification(context, n) assertThat(description).isEqualTo(createDescriptionText(n, TICKER)) } @Test fun notificationWithAllDifferentFields_titleMatchesAppNameNoTextNoTicker_descriptionEmpty() { val appName = getTestAppName() val n = createNotification(appName, null, null) val description = contentDescForNotification(context, n) assertThat(description).isEqualTo(createDescriptionText(n, "")) } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationContentDescription.kt +1 −10 Original line number Diff line number Diff line Loading @@ -28,14 +28,5 @@ import com.android.systemui.res.R @MainThread fun contentDescForNotification(c: Context, n: Notification): CharSequence { val appName = n.loadHeaderAppName(c) ?: "" val title = n.extras?.getCharSequence(Notification.EXTRA_TITLE) val text = n.extras?.getCharSequence(Notification.EXTRA_TEXT) val ticker = n.tickerText // Some apps just put the app name into the title val titleOrText = if (TextUtils.equals(title, appName)) text else title val desc = if (!TextUtils.isEmpty(titleOrText)) titleOrText else if (!TextUtils.isEmpty(ticker)) ticker else "" return c.getString(R.string.accessibility_desc_notification_icon, appName, desc) return c.getString(R.string.accessibility_desc_notification_icon, appName, "") }