Fix test flakiness
The test currently resets the time too far in the past and then has to run through ~30000 additional iterations of doSomeWork to reach the end, sometimes triggering the test timeout. Fix it by resetting the time to the intended start position when transitioning items. PiperOrigin-RevId: 633918706
This commit is contained in:
parent
e4f0ff8177
commit
67554395cb
@ -11141,7 +11141,7 @@ public class ExoPlayerTest {
|
|||||||
@Override
|
@Override
|
||||||
protected void onStreamChanged(
|
protected void onStreamChanged(
|
||||||
Format[] formats, long startPositionUs, long offsetUs, MediaPeriodId mediaPeriodId) {
|
Format[] formats, long startPositionUs, long offsetUs, MediaPeriodId mediaPeriodId) {
|
||||||
this.positionUs = offsetUs;
|
this.positionUs = startPositionUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -14688,22 +14688,22 @@ public class ExoPlayerTest {
|
|||||||
AdPlaybackState.NONE));
|
AdPlaybackState.NONE));
|
||||||
FakeMediaClockRenderer audioRenderer =
|
FakeMediaClockRenderer audioRenderer =
|
||||||
new FakeMediaClockRenderer(C.TRACK_TYPE_AUDIO) {
|
new FakeMediaClockRenderer(C.TRACK_TYPE_AUDIO) {
|
||||||
private long offsetUs;
|
private long startPositionUs;
|
||||||
private long positionUs;
|
private long positionUs;
|
||||||
private boolean hasPendingReportedSkippedSilence;
|
private boolean hasPendingReportedSkippedSilence;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStreamChanged(
|
protected void onStreamChanged(
|
||||||
Format[] formats, long startPositionUs, long offsetUs, MediaPeriodId mediaPeriodId) {
|
Format[] formats, long startPositionUs, long offsetUs, MediaPeriodId mediaPeriodId) {
|
||||||
this.offsetUs = offsetUs;
|
this.startPositionUs = startPositionUs;
|
||||||
this.positionUs = offsetUs;
|
this.positionUs = startPositionUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getPositionUs() {
|
public long getPositionUs() {
|
||||||
// Continuously increase position to let playback progress, and simulate the silence
|
// Continuously increase position to let playback progress, and simulate the silence
|
||||||
// skip until it reaches some points of time.
|
// skip until it reaches some points of time.
|
||||||
if (positionUs - offsetUs == 10_000) {
|
if (positionUs - startPositionUs == 10_000) {
|
||||||
hasPendingReportedSkippedSilence = true;
|
hasPendingReportedSkippedSilence = true;
|
||||||
positionUs += 30_000;
|
positionUs += 30_000;
|
||||||
} else {
|
} else {
|
||||||
@ -14758,7 +14758,7 @@ public class ExoPlayerTest {
|
|||||||
@Override
|
@Override
|
||||||
protected void onStreamChanged(
|
protected void onStreamChanged(
|
||||||
Format[] formats, long startPositionUs, long offsetUs, MediaPeriodId mediaPeriodId) {
|
Format[] formats, long startPositionUs, long offsetUs, MediaPeriodId mediaPeriodId) {
|
||||||
positionUs = offsetUs;
|
positionUs = startPositionUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -14770,7 +14770,7 @@ public class ExoPlayerTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSkippedSilenceSinceLastCall() {
|
public boolean hasSkippedSilenceSinceLastCall() {
|
||||||
// Contuniuosly report skipped silences to ensure they will overlap with other
|
// Continuously report skipped silences to ensure they will overlap with other
|
||||||
// discontinuities like AUTO_TRANSITION.
|
// discontinuities like AUTO_TRANSITION.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user