Commit 3fbfc0ec by gyumin Committed by Ian Baker

Fix Timeline.toBundle for empty timeline

PiperOrigin-RevId: 364513299
parent bb1261da
......@@ -1291,7 +1291,9 @@ public abstract class Timeline implements Bundleable {
}
int[] shuffledWindowIndices = new int[windowCount];
shuffledWindowIndices[0] = getFirstWindowIndex(/* shuffleModeEnabled= */ true);
if (windowCount > 0) {
shuffledWindowIndices[0] = getFirstWindowIndex(/* shuffleModeEnabled= */ true);
}
for (int i = 1; i < windowCount; i++) {
shuffledWindowIndices[i] =
getNextWindowIndex(
......
......@@ -279,6 +279,11 @@ public class TimelineTest {
}
@Test
public void roundtripViaBundle_ofEmptyTimeline_returnsEmptyTimeline() {
TimelineAsserts.assertEmpty(Timeline.CREATOR.fromBundle(Timeline.EMPTY.toBundle()));
}
@Test
public void roundtripViaBundle_ofWindow_yieldsEqualInstanceExceptUidAndManifest() {
Timeline.Window window = new Timeline.Window();
window.uid = new Object();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment