mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Clarify usage of default period-in-window offset in tests.
Using the default offset as a magic constant makes tests hard to understand. Improve that by looking up the value from the timeline or setting it explicitly in multiple places, so the relationship becomes clear. PiperOrigin-RevId: 316421977
This commit is contained in:
parent
3ec4ec4dac
commit
cd54e3e584
1 changed files with 12 additions and 3 deletions
|
|
@ -489,7 +489,7 @@ public final class ExoPlayerTest {
|
||||||
public void adGroupWithLoadErrorIsSkipped() throws Exception {
|
public void adGroupWithLoadErrorIsSkipped() throws Exception {
|
||||||
AdPlaybackState initialAdPlaybackState =
|
AdPlaybackState initialAdPlaybackState =
|
||||||
FakeTimeline.createAdPlaybackState(
|
FakeTimeline.createAdPlaybackState(
|
||||||
/* adsPerAdGroup= */ 1, /* adGroupTimesUs=... */
|
/* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */
|
||||||
TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US
|
TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US
|
||||||
+ 5 * C.MICROS_PER_SECOND);
|
+ 5 * C.MICROS_PER_SECOND);
|
||||||
Timeline fakeTimeline =
|
Timeline fakeTimeline =
|
||||||
|
|
@ -499,7 +499,11 @@ public final class ExoPlayerTest {
|
||||||
/* id= */ 0,
|
/* id= */ 0,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
|
/* isLive= */ false,
|
||||||
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ C.MICROS_PER_SECOND,
|
/* durationUs= */ C.MICROS_PER_SECOND,
|
||||||
|
/* defaultPositionUs= */ 0,
|
||||||
|
TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US,
|
||||||
initialAdPlaybackState));
|
initialAdPlaybackState));
|
||||||
AdPlaybackState errorAdPlaybackState = initialAdPlaybackState.withAdLoadError(0, 0);
|
AdPlaybackState errorAdPlaybackState = initialAdPlaybackState.withAdLoadError(0, 0);
|
||||||
final Timeline adErrorTimeline =
|
final Timeline adErrorTimeline =
|
||||||
|
|
@ -509,7 +513,11 @@ public final class ExoPlayerTest {
|
||||||
/* id= */ 0,
|
/* id= */ 0,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
|
/* isLive= */ false,
|
||||||
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ C.MICROS_PER_SECOND,
|
/* durationUs= */ C.MICROS_PER_SECOND,
|
||||||
|
/* defaultPositionUs= */ 0,
|
||||||
|
TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US,
|
||||||
errorAdPlaybackState));
|
errorAdPlaybackState));
|
||||||
final FakeMediaSource fakeMediaSource =
|
final FakeMediaSource fakeMediaSource =
|
||||||
new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT);
|
new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT);
|
||||||
|
|
@ -660,7 +668,7 @@ public final class ExoPlayerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void internalDiscontinuityAtInitialPosition() throws Exception {
|
public void internalDiscontinuityAtInitialPosition() throws Exception {
|
||||||
FakeTimeline timeline = new FakeTimeline(1);
|
FakeTimeline timeline = new FakeTimeline(/* windowCount= */ 1);
|
||||||
FakeMediaSource mediaSource =
|
FakeMediaSource mediaSource =
|
||||||
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) {
|
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -672,8 +680,9 @@ public final class ExoPlayerTest {
|
||||||
EventDispatcher eventDispatcher,
|
EventDispatcher eventDispatcher,
|
||||||
@Nullable TransferListener transferListener) {
|
@Nullable TransferListener transferListener) {
|
||||||
FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, eventDispatcher);
|
FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, eventDispatcher);
|
||||||
|
// Set a discontinuity at the position this period is supposed to start at anyway.
|
||||||
mediaPeriod.setDiscontinuityPositionUs(
|
mediaPeriod.setDiscontinuityPositionUs(
|
||||||
TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US);
|
timeline.getWindow(/* windowIndex= */ 0, new Window()).positionInFirstPeriodUs);
|
||||||
return mediaPeriod;
|
return mediaPeriod;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue