# 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)

*** ** * ** ***

<br />

```
@UnstableApi
class TimelineAsserts
```

<br />

*** ** * ** ***

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

## Summary

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

## Public functions

### assertAdGroupCounts

```
java-static fun assertAdGroupCounts(
    timeline: Timeline!,
    expectedAdGroupCounts: IntArray<Int>!
): Unit
```

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

### assertEmpty

```
java-static fun assertEmpty(timeline: Timeline!): Unit
```

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

### assertEqualNextWindowIndices

```
java-static fun assertEqualNextWindowIndices(
    expectedTimeline: Timeline!,
    actualTimeline: Timeline!,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
): Unit
```

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

```
java-static fun assertEqualPreviousWindowIndices(
    expectedTimeline: Timeline!,
    actualTimeline: Timeline!,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
): Unit
```

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

```
java-static fun assertEqualsExceptIdsAndManifest(
    expectedTimeline: Timeline!,
    actualTimeline: Timeline!
): Unit
```

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

### assertNextWindowIndices

```
java-static fun assertNextWindowIndices(
    timeline: Timeline!,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean,
    expectedNextWindowIndices: IntArray<Int>!
): Unit
```

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

### assertPeriodCounts

```
java-static fun assertPeriodCounts(
    timeline: Timeline!,
    expectedPeriodCounts: IntArray<Int>!
): Unit
```

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

### assertPeriodDurations

```
java-static fun assertPeriodDurations(timeline: Timeline!, durationsUs: LongArray<Long>!): Unit
```

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

### assertPeriodEqualsExceptIds

```
java-static fun assertPeriodEqualsExceptIds(
    expectedPeriod: Timeline.Period!,
    actualPeriod: Timeline.Period!
): Unit
```

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

### assertPreviousWindowIndices

```
java-static fun assertPreviousWindowIndices(
    timeline: Timeline!,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean,
    expectedPreviousWindowIndices: IntArray<Int>!
): Unit
```

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

### assertWindowEqualsExceptUidAndManifest

```
java-static fun assertWindowEqualsExceptUidAndManifest(
    expectedWindow: Timeline.Window!,
    actualWindow: Timeline.Window!
): Unit
```

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

### assertWindowIsDynamic

```
java-static fun assertWindowIsDynamic(
    timeline: Timeline!,
    windowIsDynamic: BooleanArray<Boolean>!
): Unit
```

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

### assertWindowTags

```
java-static fun assertWindowTags(
    timeline: Timeline!,
    @NullableType expectedWindowTags: Array<Any!>!
): Unit
```

Asserts that window tags are set correctly.

| Parameters |
|---|---|
| `timeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | The timeline to read actual window tags from. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType expectedWindowTags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!>!` | A list of expected window tags. If a tag is unknown or not important `null` can be passed to skip this window. |