Loading core/tests/coretests/src/android/app/NotificationTest.java +77 −0 Original line number Original line Diff line number Diff line Loading @@ -2502,6 +2502,21 @@ public class NotificationTest { assertThat(progressStyle.getProgressSegments()).isEmpty(); assertThat(progressStyle.getProgressSegments()).isEmpty(); } } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_setProgressSegments() { final List<Notification.ProgressStyle.Segment> segments = List.of( new Notification.ProgressStyle.Segment(100).setColor(Color.WHITE), new Notification.ProgressStyle.Segment(50).setColor(Color.RED), new Notification.ProgressStyle.Segment(50).setColor(Color.BLUE) ); final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle(); progressStyle1.setProgressSegments(segments); assertThat(progressStyle1.getProgressSegments()).isEqualTo(segments); } @Test @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_addProgressPoint_dropsNegativePoints() { public void progressStyle_addProgressPoint_dropsNegativePoints() { Loading Loading @@ -2530,6 +2545,21 @@ public class NotificationTest { assertThat(progressStyle.getProgressPoints()).isEmpty(); assertThat(progressStyle.getProgressPoints()).isEmpty(); } } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_setProgressPoints() { final List<Notification.ProgressStyle.Point> points = List.of( new Notification.ProgressStyle.Point(0).setColor(Color.WHITE), new Notification.ProgressStyle.Point(50).setColor(Color.RED), new Notification.ProgressStyle.Point(100).setColor(Color.BLUE) ); final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle(); progressStyle1.setProgressPoints(points); assertThat(progressStyle1.getProgressPoints()).isEqualTo(points); } @Test @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_createProgressModel_ignoresPointsExceedingMax() { public void progressStyle_createProgressModel_ignoresPointsExceedingMax() { Loading Loading @@ -2671,6 +2701,14 @@ public class NotificationTest { assertThat(progressStyle1.isProgressIndeterminate()).isFalse(); assertThat(progressStyle1.isProgressIndeterminate()).isFalse(); } } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_setProgressIndeterminate() { final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle(); progressStyle1.setProgressIndeterminate(true); assertThat(progressStyle1.isProgressIndeterminate()).isTrue(); } @Test @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_styledByProgress_defaultValueTrue() { public void progressStyle_styledByProgress_defaultValueTrue() { Loading @@ -2678,6 +2716,45 @@ public class NotificationTest { assertThat(progressStyle1.isStyledByProgress()).isTrue(); assertThat(progressStyle1.isStyledByProgress()).isTrue(); } } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_setStyledByProgress() { final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle(); progressStyle1.setStyledByProgress(false); assertThat(progressStyle1.isStyledByProgress()).isFalse(); } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_point() { final int id = 1; final int position = 10; final int color = Color.RED; final Notification.ProgressStyle.Point point = new Notification.ProgressStyle.Point(position).setId(id).setColor(color); assertEquals(id, point.getId()); assertEquals(position, point.getPosition()); assertEquals(color, point.getColor()); } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_segment() { final int id = 1; final int length = 100; final int color = Color.RED; final Notification.ProgressStyle.Segment segment = new Notification.ProgressStyle.Segment(length).setId(id).setColor(color); assertEquals(id, segment.getId()); assertEquals(length, segment.getLength()); assertEquals(color, segment.getColor()); } private void assertValid(Notification.Colors c) { private void assertValid(Notification.Colors c) { // Assert that all colors are populated // Assert that all colors are populated assertThat(c.getBackgroundColor()).isNotEqualTo(Notification.COLOR_INVALID); assertThat(c.getBackgroundColor()).isNotEqualTo(Notification.COLOR_INVALID); Loading Loading
core/tests/coretests/src/android/app/NotificationTest.java +77 −0 Original line number Original line Diff line number Diff line Loading @@ -2502,6 +2502,21 @@ public class NotificationTest { assertThat(progressStyle.getProgressSegments()).isEmpty(); assertThat(progressStyle.getProgressSegments()).isEmpty(); } } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_setProgressSegments() { final List<Notification.ProgressStyle.Segment> segments = List.of( new Notification.ProgressStyle.Segment(100).setColor(Color.WHITE), new Notification.ProgressStyle.Segment(50).setColor(Color.RED), new Notification.ProgressStyle.Segment(50).setColor(Color.BLUE) ); final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle(); progressStyle1.setProgressSegments(segments); assertThat(progressStyle1.getProgressSegments()).isEqualTo(segments); } @Test @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_addProgressPoint_dropsNegativePoints() { public void progressStyle_addProgressPoint_dropsNegativePoints() { Loading Loading @@ -2530,6 +2545,21 @@ public class NotificationTest { assertThat(progressStyle.getProgressPoints()).isEmpty(); assertThat(progressStyle.getProgressPoints()).isEmpty(); } } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_setProgressPoints() { final List<Notification.ProgressStyle.Point> points = List.of( new Notification.ProgressStyle.Point(0).setColor(Color.WHITE), new Notification.ProgressStyle.Point(50).setColor(Color.RED), new Notification.ProgressStyle.Point(100).setColor(Color.BLUE) ); final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle(); progressStyle1.setProgressPoints(points); assertThat(progressStyle1.getProgressPoints()).isEqualTo(points); } @Test @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_createProgressModel_ignoresPointsExceedingMax() { public void progressStyle_createProgressModel_ignoresPointsExceedingMax() { Loading Loading @@ -2671,6 +2701,14 @@ public class NotificationTest { assertThat(progressStyle1.isProgressIndeterminate()).isFalse(); assertThat(progressStyle1.isProgressIndeterminate()).isFalse(); } } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_setProgressIndeterminate() { final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle(); progressStyle1.setProgressIndeterminate(true); assertThat(progressStyle1.isProgressIndeterminate()).isTrue(); } @Test @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_styledByProgress_defaultValueTrue() { public void progressStyle_styledByProgress_defaultValueTrue() { Loading @@ -2678,6 +2716,45 @@ public class NotificationTest { assertThat(progressStyle1.isStyledByProgress()).isTrue(); assertThat(progressStyle1.isStyledByProgress()).isTrue(); } } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_setStyledByProgress() { final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle(); progressStyle1.setStyledByProgress(false); assertThat(progressStyle1.isStyledByProgress()).isFalse(); } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_point() { final int id = 1; final int position = 10; final int color = Color.RED; final Notification.ProgressStyle.Point point = new Notification.ProgressStyle.Point(position).setId(id).setColor(color); assertEquals(id, point.getId()); assertEquals(position, point.getPosition()); assertEquals(color, point.getColor()); } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void progressStyle_segment() { final int id = 1; final int length = 100; final int color = Color.RED; final Notification.ProgressStyle.Segment segment = new Notification.ProgressStyle.Segment(length).setId(id).setColor(color); assertEquals(id, segment.getId()); assertEquals(length, segment.getLength()); assertEquals(color, segment.getColor()); } private void assertValid(Notification.Colors c) { private void assertValid(Notification.Colors c) { // Assert that all colors are populated // Assert that all colors are populated assertThat(c.getBackgroundColor()).isNotEqualTo(Notification.COLOR_INVALID); assertThat(c.getBackgroundColor()).isNotEqualTo(Notification.COLOR_INVALID); Loading