@@ -383,7 +383,7 @@ public void setShortCriticalText() {
383383
384384 Notification notification = builder .build ();
385385 assertThat (NotificationCompat .getShortCriticalText (notification ))
386- .isEqualTo (shortCriticalText );
386+ .isEqualTo (shortCriticalText );
387387
388388 notification = builder .setShortCriticalText (null ).build ();
389389 assertThat (NotificationCompat .getShortCriticalText (notification )).isNull ();
@@ -1456,6 +1456,37 @@ public void testSetNotificationSilent_notSilenced() throws Throwable {
14561456 }
14571457 }
14581458
1459+ @ Test
1460+ public void testSetNotificationSilent_clonedNotificationIsSilent_noGroup () {
1461+ // Create a silent notification
1462+ Notification notification = new NotificationCompat .Builder (mContext ).setSilent (
1463+ true ).build ();
1464+ assertThat (NotificationCompat .isSilent (notification )).isTrue ();
1465+ // Check that the copy notification is also silent
1466+ Notification notificationCopy = new NotificationCompat .Builder (mContext ,
1467+ notification ).build ();
1468+ assertThat (NotificationCompat .isSilent (notificationCopy )).isTrue ();
1469+
1470+ if (Build .VERSION .SDK_INT >= 26 ) {
1471+ assertThat (notification .getGroup ()).isEqualTo (GROUP_KEY_SILENT );
1472+ assertThat (notificationCopy .getGroup ()).isEqualTo (GROUP_KEY_SILENT );
1473+ }
1474+ }
1475+
1476+ @ Test
1477+ public void testSetNotificationSilent_clonedNotificationIsSilent_grouped () {
1478+ // Create a silent notification
1479+ final String groupName = "testGrp" ;
1480+ Notification notification = new NotificationCompat .Builder (mContext ).setGroup (
1481+ groupName ).setSilent (true ).build ();
1482+ assertThat (NotificationCompat .isSilent (notification )).isTrue ();
1483+ // Check that the copy notification is also silent
1484+ Notification notificationCopy = new NotificationCompat .Builder (mContext ,
1485+ notification ).build ();
1486+ assertThat (NotificationCompat .isSilent (notificationCopy )).isTrue ();
1487+ assertThat (NotificationCompat .getGroup (notificationCopy )).isEqualTo (groupName );
1488+ }
1489+
14591490 @ Test
14601491 public void testGroupAlertBehavior_doesNotMuteIncorrectGroupNotifications () throws Throwable {
14611492 Notification n = new NotificationCompat .Builder (mActivityTestRule .getActivity ())
@@ -2488,8 +2519,8 @@ public void testCallStyle_preservesOneCustomAction() {
24882519 } else if (Build .VERSION .SDK_INT == 33 ) {
24892520 // Could be either, so check presence but not ordering.
24902521 assertThat (actionTitles ).containsExactly (
2491- mContext .getString (R .string .call_notification_hang_up_action ),
2492- customAction .title .toString ());
2522+ mContext .getString (R .string .call_notification_hang_up_action ),
2523+ customAction .title .toString ());
24932524 } else {
24942525 throw new AssertionError ("All SDK_INT values are covered!" );
24952526 }
@@ -2539,9 +2570,9 @@ public void testCallStyle_preservesTwoCustomActions() {
25392570 } else if (Build .VERSION .SDK_INT == 33 ) {
25402571 // Could be either, so check presence but not ordering.
25412572 assertThat (actionTitles ).containsExactly (
2542- mContext .getString (R .string .call_notification_hang_up_action ),
2543- customAction1 .title .toString (),
2544- customAction2 .title .toString ());
2573+ mContext .getString (R .string .call_notification_hang_up_action ),
2574+ customAction1 .title .toString (),
2575+ customAction2 .title .toString ());
25452576 } else {
25462577 throw new AssertionError ("All SDK_INT values are covered!" );
25472578 }
0 commit comments