Modernize bandwidth profile simulator.

Main improvement is to switch away from ExoPlayerTestRunner and to
split out the waiting component so that the same class can be used
from Robolectric tests in the future.

The only functional difference is that that BufferLengthLogAction
is removed completely because the data isn't used downstream and the
method of collecting this data is a bit arbitrary.

PiperOrigin-RevId: 355117850
This commit is contained in:
tonihei 2021-02-02 09:29:00 +00:00 committed by Oliver Woodman
parent 46b8b069ca
commit 05fddff84f

View file

@ -17,6 +17,7 @@ package com.google.android.exoplayer2.testutil;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import android.os.Build;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Looper;
@ -50,6 +51,7 @@ public class FakeClock implements Clock {
private static long messageIdProvider = 0;
private final boolean isRobolectric;
private final boolean isAutoAdvancing;
@GuardedBy("this")
@ -105,7 +107,10 @@ public class FakeClock implements Clock {
this.isAutoAdvancing = isAutoAdvancing;
this.handlerMessages = new ArrayList<>();
this.busyLoopers = new HashSet<>();
SystemClock.setCurrentTimeMillis(initialTimeMs);
this.isRobolectric = "robolectric".equals(Build.FINGERPRINT);
if (isRobolectric) {
SystemClock.setCurrentTimeMillis(initialTimeMs);
}
}
/**
@ -245,7 +250,9 @@ public class FakeClock implements Clock {
private synchronized void advanceTimeInternal(long timeDiffMs) {
timeSinceBootMs += timeDiffMs;
SystemClock.setCurrentTimeMillis(timeSinceBootMs);
if (isRobolectric) {
SystemClock.setCurrentTimeMillis(timeSinceBootMs);
}
}
private static synchronized long getNextMessageId() {