mirror of
https://github.com/androidx/media.git
synced 2025-05-06 23:20:42 +08:00
Test that ExoPlayer can be built in a background thread
PiperOrigin-RevId: 318264209
This commit is contained in:
parent
aaa7fd114e
commit
a8ae98b1bf
@ -105,6 +105,7 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.LooperMode;
|
||||
import org.robolectric.shadows.ShadowAudioManager;
|
||||
|
||||
@ -6766,6 +6767,20 @@ public final class ExoPlayerTest {
|
||||
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.
|
||||
|
||||
private static ActionSchedule.Builder addSurfaceSwitch(ActionSchedule.Builder builder) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user