Commit 05fddff8 by tonihei Committed by Oliver Woodman

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