mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Test parsing-during-extraction in ClippedPlaybackTest
We keep the previous parsing-during-rendering tests, even though they can be a bit flaky, because this is an important regression test. The regression risk is lower for this instrumentation test compared to robolectric tests with different `ShadowLooper` behaviour. #minor-release PiperOrigin-RevId: 600781035
This commit is contained in:
parent
acc78125d2
commit
a53f3451dd
@ -18,6 +18,7 @@ package androidx.media3.exoplayer;
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.MediaItem;
|
||||
@ -28,7 +29,7 @@ import androidx.media3.common.text.Cue;
|
||||
import androidx.media3.common.text.CueGroup;
|
||||
import androidx.media3.common.util.ConditionVariable;
|
||||
import androidx.media3.exoplayer.source.ClippingMediaSource;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import java.util.ArrayList;
|
||||
@ -36,14 +37,31 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
/**
|
||||
* Instrumentation tests for playback of clipped items using {@link MediaItem#clippingConfiguration}
|
||||
* or {@link ClippingMediaSource} directly.
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(Parameterized.class)
|
||||
public final class ClippedPlaybackTest {
|
||||
|
||||
@Parameters(name = "parseSubtitlesDuringExtraction={0}")
|
||||
public static ImmutableList<Boolean> params() {
|
||||
return ImmutableList.of(true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* We deliberately test both forms of subtitle parsing, to ensure that both work correctly with
|
||||
* clipping configurations. Parsing during rendering (i.e. not during extraction) can be a little
|
||||
* bit flaky, because playback can complete before the rendering/parsing is finished, and there is
|
||||
* no easy way to delay the completion of playback in this case. The parse-during-rendering flow
|
||||
* will be removed in a later release (b/289983417), which will resolve this flakiness.
|
||||
*/
|
||||
@Parameter public boolean parseSubtitlesDuringExtraction;
|
||||
|
||||
@Test
|
||||
public void subtitlesRespectClipping_singlePeriod() throws Exception {
|
||||
MediaItem mediaItem =
|
||||
@ -65,7 +83,14 @@ public final class ClippedPlaybackTest {
|
||||
getInstrumentation()
|
||||
.runOnMainSync(
|
||||
() -> {
|
||||
player.set(new ExoPlayer.Builder(getInstrumentation().getContext()).build());
|
||||
Context context = getInstrumentation().getContext();
|
||||
player.set(
|
||||
new ExoPlayer.Builder(context)
|
||||
.setMediaSourceFactory(
|
||||
new DefaultMediaSourceFactory(context)
|
||||
.experimentalParseSubtitlesDuringExtraction(
|
||||
parseSubtitlesDuringExtraction))
|
||||
.build());
|
||||
player.get().addListener(textCapturer);
|
||||
player.get().setMediaItem(mediaItem);
|
||||
player.get().prepare();
|
||||
@ -110,7 +135,14 @@ public final class ClippedPlaybackTest {
|
||||
getInstrumentation()
|
||||
.runOnMainSync(
|
||||
() -> {
|
||||
player.set(new ExoPlayer.Builder(getInstrumentation().getContext()).build());
|
||||
Context context = getInstrumentation().getContext();
|
||||
player.set(
|
||||
new ExoPlayer.Builder(context)
|
||||
.setMediaSourceFactory(
|
||||
new DefaultMediaSourceFactory(context)
|
||||
.experimentalParseSubtitlesDuringExtraction(
|
||||
parseSubtitlesDuringExtraction))
|
||||
.build());
|
||||
player.get().addListener(textCapturer);
|
||||
player.get().setMediaItems(mediaItems);
|
||||
player.get().prepare();
|
||||
|
Loading…
x
Reference in New Issue
Block a user