# TimelineAsserts

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/TimelineAsserts.java+class:androidx.media3.test.utils.TimelineAsserts)

*** ** * ** ***


```
@UnstableApi
public final class TimelineAsserts
```

<br />

*** ** * ** ***

Assertion methods for `https://developer.android.com/reference/androidx/media3/common/Timeline`.

## Summary

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertAdGroupCounts(androidx.media3.common.Timeline,int...)(https://developer.android.com/reference/androidx/media3/common/Timeline timeline, int[] expectedAdGroupCounts)` Asserts that periods' `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdGroupCount()` are set correctly. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertEmpty(androidx.media3.common.Timeline)(https://developer.android.com/reference/androidx/media3/common/Timeline timeline)` Assert that timeline is empty (i.e. has no windows or periods). |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertEqualNextWindowIndices(androidx.media3.common.Timeline,androidx.media3.common.Timeline,int,boolean)( https://developer.android.com/reference/androidx/media3/common/Timeline expectedTimeline, https://developer.android.com/reference/androidx/media3/common/Timeline actualTimeline, @https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode, boolean shuffleModeEnabled )` Asserts that next window indices for each window of the actual timeline are equal to the indices of the expected timeline depending on the repeat mode and the shuffle mode. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertEqualPreviousWindowIndices(androidx.media3.common.Timeline,androidx.media3.common.Timeline,int,boolean)( https://developer.android.com/reference/androidx/media3/common/Timeline expectedTimeline, https://developer.android.com/reference/androidx/media3/common/Timeline actualTimeline, @https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode, boolean shuffleModeEnabled )` Asserts that previous window indices for each window of the actual timeline are equal to the indices of the expected timeline depending on the repeat mode and the shuffle mode. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertEqualsExceptIdsAndManifest(androidx.media3.common.Timeline,androidx.media3.common.Timeline)( https://developer.android.com/reference/androidx/media3/common/Timeline expectedTimeline, https://developer.android.com/reference/androidx/media3/common/Timeline actualTimeline )` Asserts that `https://developer.android.com/reference/androidx/media3/common/Timeline` are equal except `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#uid()`, `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#manifest()`, `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#id()`, and `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#uid()`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertNextWindowIndices(androidx.media3.common.Timeline,int,boolean,int...)( https://developer.android.com/reference/androidx/media3/common/Timeline timeline, @https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode, boolean shuffleModeEnabled, int[] expectedNextWindowIndices )` Asserts that next window indices for each window depending on the repeat mode and the shuffle mode are equal to the given sequence. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertPeriodCounts(androidx.media3.common.Timeline,int...)(https://developer.android.com/reference/androidx/media3/common/Timeline timeline, int[] expectedPeriodCounts)` Asserts that period counts for each window are set correctly. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertPeriodDurations(androidx.media3.common.Timeline,long...)(https://developer.android.com/reference/androidx/media3/common/Timeline timeline, long[] durationsUs)` Asserts that the durations of the periods in the `https://developer.android.com/reference/androidx/media3/common/Timeline` and the durations in the given sequence are equal. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertPeriodEqualsExceptIds(androidx.media3.common.Timeline.Period,androidx.media3.common.Timeline.Period)( https://developer.android.com/reference/androidx/media3/common/Timeline.Period expectedPeriod, https://developer.android.com/reference/androidx/media3/common/Timeline.Period actualPeriod )` Asserts that `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` are equal except `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#id()` and `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#uid()`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertPreviousWindowIndices(androidx.media3.common.Timeline,int,boolean,int...)( https://developer.android.com/reference/androidx/media3/common/Timeline timeline, @https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode, boolean shuffleModeEnabled, int[] expectedPreviousWindowIndices )` Asserts that previous window indices for each window depending on the repeat mode and the shuffle mode are equal to the given sequence. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertWindowEqualsExceptUidAndManifest(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Window)( https://developer.android.com/reference/androidx/media3/common/Timeline.Window expectedWindow, https://developer.android.com/reference/androidx/media3/common/Timeline.Window actualWindow )` Asserts that `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` are equal except `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#uid()` and `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#manifest()`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertWindowIsDynamic(androidx.media3.common.Timeline,boolean...)(https://developer.android.com/reference/androidx/media3/common/Timeline timeline, boolean[] windowIsDynamic)` Asserts that window properties `https://developer.android.com/reference/androidx/media3/common/Timeline.Window`.isDynamic are set correctly. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/TimelineAsserts#assertWindowTags(androidx.media3.common.Timeline,java.lang.Object...)( https://developer.android.com/reference/androidx/media3/common/Timeline timeline, @https://developer.android.com/reference/androidx/media3/common/util/NullableType Object[] expectedWindowTags )` Asserts that window tags are set correctly. |

## Public methods

### assertAdGroupCounts

```
public static void assertAdGroupCounts(Timeline timeline, int[] expectedAdGroupCounts)
```

Asserts that periods' `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdGroupCount()` are set correctly.

### assertEmpty

```
public static void assertEmpty(Timeline timeline)
```

Assert that timeline is empty (i.e. has no windows or periods).

### assertEqualNextWindowIndices

```
public static void assertEqualNextWindowIndices(
    Timeline expectedTimeline,
    Timeline actualTimeline,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled
)
```

Asserts that next window indices for each window of the actual timeline are equal to the indices of the expected timeline depending on the repeat mode and the shuffle mode.

### assertEqualPreviousWindowIndices

```
public static void assertEqualPreviousWindowIndices(
    Timeline expectedTimeline,
    Timeline actualTimeline,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled
)
```

Asserts that previous window indices for each window of the actual timeline are equal to the indices of the expected timeline depending on the repeat mode and the shuffle mode.

### assertEqualsExceptIdsAndManifest

```
public static void assertEqualsExceptIdsAndManifest(
    Timeline expectedTimeline,
    Timeline actualTimeline
)
```

Asserts that `https://developer.android.com/reference/androidx/media3/common/Timeline` are equal except `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#uid()`, `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#manifest()`, `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#id()`, and `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#uid()`.

### assertNextWindowIndices

```
public static void assertNextWindowIndices(
    Timeline timeline,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled,
    int[] expectedNextWindowIndices
)
```

Asserts that next window indices for each window depending on the repeat mode and the shuffle mode are equal to the given sequence.

### assertPeriodCounts

```
public static void assertPeriodCounts(Timeline timeline, int[] expectedPeriodCounts)
```

Asserts that period counts for each window are set correctly. Also asserts that `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#firstPeriodIndex()` and `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#lastPeriodIndex()` are set correctly, and it asserts the correct behavior of `https://developer.android.com/reference/androidx/media3/common/Timeline#getNextWindowIndex(int,int,boolean)`.

### assertPeriodDurations

```
public static void assertPeriodDurations(Timeline timeline, long[] durationsUs)
```

Asserts that the durations of the periods in the `https://developer.android.com/reference/androidx/media3/common/Timeline` and the durations in the given sequence are equal.

### assertPeriodEqualsExceptIds

```
public static void assertPeriodEqualsExceptIds(
    Timeline.Period expectedPeriod,
    Timeline.Period actualPeriod
)
```

Asserts that `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` are equal except `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#id()` and `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#uid()`.

### assertPreviousWindowIndices

```
public static void assertPreviousWindowIndices(
    Timeline timeline,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled,
    int[] expectedPreviousWindowIndices
)
```

Asserts that previous window indices for each window depending on the repeat mode and the shuffle mode are equal to the given sequence.

### assertWindowEqualsExceptUidAndManifest

```
public static void assertWindowEqualsExceptUidAndManifest(
    Timeline.Window expectedWindow,
    Timeline.Window actualWindow
)
```

Asserts that `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` are equal except `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#uid()` and `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#manifest()`.

### assertWindowIsDynamic

```
public static void assertWindowIsDynamic(Timeline timeline, boolean[] windowIsDynamic)
```

Asserts that window properties `https://developer.android.com/reference/androidx/media3/common/Timeline.Window`.isDynamic are set correctly.

### assertWindowTags

```
public static void assertWindowTags(
    Timeline timeline,
    @NullableType Object[] expectedWindowTags
)
```

Asserts that window tags are set correctly.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline timeline` | The timeline to read actual window tags from. |
| `@https://developer.android.com/reference/androidx/media3/common/util/NullableType Object[] expectedWindowTags` | A list of expected window tags. If a tag is unknown or not important `null` can be passed to skip this window. |