Commit a8ae98b1 by krocard Committed by Christos Tsilopoulos

Test that ExoPlayer can be built in a background thread

PiperOrigin-RevId: 318264209
parent aaa7fd11
...@@ -105,6 +105,7 @@ import org.junit.Before; ...@@ -105,6 +105,7 @@ import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode; import org.robolectric.annotation.LooperMode;
import org.robolectric.shadows.ShadowAudioManager; import org.robolectric.shadows.ShadowAudioManager;
...@@ -6766,6 +6767,20 @@ public final class ExoPlayerTest { ...@@ -6766,6 +6767,20 @@ public final class ExoPlayerTest {
assertThat(initialMediaItems).containsExactlyElementsIn(currentMediaItems); assertThat(initialMediaItems).containsExactlyElementsIn(currentMediaItems);
} }
// TODO: Revert to @Config(sdk = Config.ALL_SDKS) once b/143232359 is resolved
@Test
@Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.TARGET_SDK)
public void buildSimpleExoPlayerInBackgroundThread_doesNotThrow() throws Exception {
Thread builderThread = new Thread(() -> new SimpleExoPlayer.Builder(context).build());
AtomicReference<Throwable> builderThrow = new AtomicReference<>();
builderThread.setUncaughtExceptionHandler((thread, throwable) -> builderThrow.set(throwable));
builderThread.start();
builderThread.join();
assertThat(builderThrow.get()).isNull();
}
// Internal methods. // Internal methods.
private static ActionSchedule.Builder addSurfaceSwitch(ActionSchedule.Builder builder) { private static ActionSchedule.Builder addSurfaceSwitch(ActionSchedule.Builder builder) {
......
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