diff options
| -rw-r--r-- | core/tests/coretests/src/android/app/NotificationTest.java | 77 | 
1 files changed, 77 insertions, 0 deletions
diff --git a/core/tests/coretests/src/android/app/NotificationTest.java b/core/tests/coretests/src/android/app/NotificationTest.java index ca6ad6fae46e..7be6950fb613 100644 --- a/core/tests/coretests/src/android/app/NotificationTest.java +++ b/core/tests/coretests/src/android/app/NotificationTest.java @@ -2504,6 +2504,21 @@ public class NotificationTest {      @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 +    @EnableFlags(Flags.FLAG_API_RICH_ONGOING)      public void progressStyle_addProgressPoint_dropsNegativePoints() {          // GIVEN          final Notification.ProgressStyle progressStyle = new Notification.ProgressStyle(); @@ -2532,6 +2547,21 @@ public class NotificationTest {      @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 +    @EnableFlags(Flags.FLAG_API_RICH_ONGOING)      public void progressStyle_createProgressModel_ignoresPointsExceedingMax() {          // GIVEN          final Notification.ProgressStyle progressStyle = new Notification.ProgressStyle(); @@ -2673,11 +2703,58 @@ public class NotificationTest {      @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 +    @EnableFlags(Flags.FLAG_API_RICH_ONGOING)      public void progressStyle_styledByProgress_defaultValueTrue() {          final Notification.ProgressStyle progressStyle1 = new Notification.ProgressStyle();          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) {          // Assert that all colors are populated          assertThat(c.getBackgroundColor()).isNotEqualTo(Notification.COLOR_INVALID);  |