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