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

Commit c1eb4481 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix bug: ProgressStyle.setProgressSegments doesn't set the segments." into main

parents 73a600cf b0431885
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -11296,7 +11296,11 @@ public class Notification implements Parcelable
         * @see Segment
         */
        public @NonNull ProgressStyle setProgressSegments(@NonNull List<Segment> progressSegments) {
            mProgressSegments = new ArrayList<>(progressSegments.size());
            if (mProgressSegments == null) {
                mProgressSegments = new ArrayList<>();
            }
            mProgressSegments.clear();
            mProgressSegments.addAll(progressSegments);
            return this;
        }
+16 −1
Original line number Diff line number Diff line
@@ -2397,10 +2397,25 @@ public class NotificationTest {
    public void progressStyle_getProgressMax_returnsSumOfSegmentLength() {
        final Notification.ProgressStyle progressStyle = new Notification.ProgressStyle();
        progressStyle
                .setProgressSegments(List.of(new Notification.ProgressStyle.Segment(15),
                        new Notification.ProgressStyle.Segment(25)))
                .addProgressSegment(new Notification.ProgressStyle.Segment(10))
                .addProgressSegment(new Notification.ProgressStyle.Segment(20));

        assertThat(progressStyle.getProgressMax()).isEqualTo(30);
        assertThat(progressStyle.getProgressMax()).isEqualTo(70);
    }

    @Test
    @EnableFlags(Flags.FLAG_API_RICH_ONGOING)
    public void progressStyle_getProgressMax_onSetProgressSegments_resets() {
        final Notification.ProgressStyle progressStyle = new Notification.ProgressStyle();
        progressStyle
                .addProgressSegment(new Notification.ProgressStyle.Segment(10))
                .addProgressSegment(new Notification.ProgressStyle.Segment(20))
                .setProgressSegments(List.of(new Notification.ProgressStyle.Segment(15),
                        new Notification.ProgressStyle.Segment(25)));

        assertThat(progressStyle.getProgressMax()).isEqualTo(40);
    }

    @Test