Commit 8ae04bcf by ibaker Committed by Oliver Woodman

Migrate usages of deprecated Window#tag

PiperOrigin-RevId: 321169585
parent 5a2e04ec
......@@ -55,7 +55,8 @@ public final class SilenceMediaSource extends BaseMediaSource {
/**
* Sets a tag for the media source which will be published in the {@link
* com.google.android.exoplayer2.Timeline} of the source as {@link
* com.google.android.exoplayer2.Timeline.Window#tag}.
* com.google.android.exoplayer2.MediaItem.PlaybackProperties#tag
* Window#mediaItem.playbackProperties.tag}.
*
* @param tag A tag for the media source.
* @return This factory, for convenience.
......
......@@ -80,7 +80,8 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
/**
* Sets a tag for the media source which will be published in the {@link Timeline} of the source
* as {@link Timeline.Window#tag}.
* as {@link com.google.android.exoplayer2.MediaItem.PlaybackProperties#tag
* Window#mediaItem.playbackProperties.tag}.
*
* @param tag A tag for the media source.
* @return This factory, for convenience.
......
......@@ -89,6 +89,7 @@ public final class SinglePeriodTimelineTest {
}
@Test
@SuppressWarnings("deprecation") // Testing deprecated Window.tag is still populated correctly.
public void setNullTag_returnsNullTag_butUsesDefaultUid() {
SinglePeriodTimeline timeline =
new SinglePeriodTimeline(
......@@ -100,6 +101,8 @@ public final class SinglePeriodTimelineTest {
new MediaItem.Builder().setUri(Uri.EMPTY).setTag(null).build());
assertThat(timeline.getWindow(/* windowIndex= */ 0, window).tag).isNull();
assertThat(timeline.getWindow(/* windowIndex= */ 0, window).mediaItem.playbackProperties.tag)
.isNull();
assertThat(timeline.getPeriod(/* periodIndex= */ 0, period, /* setIds= */ false).id).isNull();
assertThat(timeline.getPeriod(/* periodIndex= */ 0, period, /* setIds= */ true).id).isNull();
assertThat(timeline.getPeriod(/* periodIndex= */ 0, period, /* setIds= */ false).uid).isNull();
......@@ -108,6 +111,7 @@ public final class SinglePeriodTimelineTest {
}
@Test
@SuppressWarnings("deprecation") // Testing deprecated Window.tag is still populated correctly.
public void getWindow_setsTag() {
Object tag = new Object();
SinglePeriodTimeline timeline =
......
......@@ -18,11 +18,13 @@ package com.google.android.exoplayer2.testutil;
import static com.google.common.truth.Truth.assertThat;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import org.checkerframework.checker.nullness.compatqual.NullableType;
/** Unit test for {@link Timeline}. */
......@@ -57,7 +59,9 @@ public final class TimelineAsserts {
for (int i = 0; i < timeline.getWindowCount(); i++) {
timeline.getWindow(i, window);
if (expectedWindowTags[i] != null) {
assertThat(window.tag).isEqualTo(expectedWindowTags[i]);
MediaItem.PlaybackProperties playbackProperties = window.mediaItem.playbackProperties;
assertThat(playbackProperties).isNotNull();
assertThat(Util.castNonNull(playbackProperties).tag).isEqualTo(expectedWindowTags[i]);
}
}
}
......
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