mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Move SimpleExoPlayer.Builder unit test to a separate class
PiperOrigin-RevId: 318785458
This commit is contained in:
parent
8e09cf45c0
commit
6884dfb313
2 changed files with 46 additions and 15 deletions
|
|
@ -105,7 +105,6 @@ 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;
|
||||
|
||||
|
|
@ -6767,20 +6766,6 @@ 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) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.android.exoplayer2;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
/** Unit test for {@link SimpleExoPlayer}. */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class SimpleExoPlayerTest {
|
||||
|
||||
// TODO(b/143232359): Revert to @Config(sdk = Config.ALL_SDKS) once b/143232359 is resolved
|
||||
@Test
|
||||
@Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.TARGET_SDK)
|
||||
public void builder_inBackgroundThread_doesNotThrow() throws Exception {
|
||||
Thread builderThread =
|
||||
new Thread(
|
||||
() -> new SimpleExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build());
|
||||
AtomicReference<Throwable> builderThrow = new AtomicReference<>();
|
||||
builderThread.setUncaughtExceptionHandler((thread, throwable) -> builderThrow.set(throwable));
|
||||
|
||||
builderThread.start();
|
||||
builderThread.join();
|
||||
|
||||
assertThat(builderThrow.get()).isNull();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue