Search in sources :

Example 6 with FakeClock

use of com.google.android.exoplayer2.testutil.FakeClock in project ExoPlayer by google.

the class MetadataRetrieverTest method setUp.

@Before
public void setUp() throws Exception {
    context = ApplicationProvider.getApplicationContext();
    clock = new FakeClock(/* isAutoAdvancing= */
    true);
}
Also used : FakeClock(com.google.android.exoplayer2.testutil.FakeClock) Before(org.junit.Before)

Example 7 with FakeClock

use of com.google.android.exoplayer2.testutil.FakeClock in project ExoPlayer by google.

the class MkvPlaybackTest method test.

@Test
public void test() throws Exception {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
    ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
    true)).build();
    // subtitle output is not flaky.
    for (int textRendererIndex = 0; textRendererIndex < player.getRendererCount(); textRendererIndex++) {
        if (player.getRendererType(textRendererIndex) == C.TRACK_TYPE_TEXT) {
            player.setTrackSelectionParameters(new DefaultTrackSelector.ParametersBuilder(applicationContext).setRendererDisabled(textRendererIndex, /* disabled= */
            true).build());
            break;
        }
    }
    player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */
    1)));
    PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
    player.setMediaItem(MediaItem.fromUri("asset:///media/mkv/" + inputFile));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/mkv/" + inputFile + ".dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) SurfaceTexture(android.graphics.SurfaceTexture) CapturingRenderersFactory(com.google.android.exoplayer2.testutil.CapturingRenderersFactory) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Surface(android.view.Surface) Test(org.junit.Test)

Example 8 with FakeClock

use of com.google.android.exoplayer2.testutil.FakeClock in project ExoPlayer by google.

the class Mp4PlaybackTest method test.

@Test
public void test() throws Exception {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(applicationContext);
    ExoPlayer player = new ExoPlayer.Builder(applicationContext, renderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
    true)).build();
    player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */
    1)));
    PlaybackOutput playbackOutput = PlaybackOutput.register(player, renderersFactory);
    player.setMediaItem(MediaItem.fromUri("asset:///media/mp4/" + inputFile));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/mp4/" + inputFile + ".dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) SurfaceTexture(android.graphics.SurfaceTexture) CapturingRenderersFactory(com.google.android.exoplayer2.testutil.CapturingRenderersFactory) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Surface(android.view.Surface) Test(org.junit.Test)

Example 9 with FakeClock

use of com.google.android.exoplayer2.testutil.FakeClock in project ExoPlayer by google.

the class PlaylistPlaybackTest method test_bypassOffThenOn.

@Test
public void test_bypassOffThenOn() throws Exception {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
    ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
    true)).build();
    PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
    player.addMediaItem(MediaItem.fromUri("asset:///media/mka/bear-opus.mka"));
    player.addMediaItem(MediaItem.fromUri("asset:///media/wav/sample.wav"));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/playlists/bypass-off-then-on.dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) CapturingRenderersFactory(com.google.android.exoplayer2.testutil.CapturingRenderersFactory) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Test(org.junit.Test)

Example 10 with FakeClock

use of com.google.android.exoplayer2.testutil.FakeClock in project ExoPlayer by google.

the class WavPlaybackTest method test.

@Test
public void test() throws Exception {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
    ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
    true)).build();
    PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
    player.setMediaItem(MediaItem.fromUri("asset:///media/wav/" + inputFile));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(ApplicationProvider.getApplicationContext(), playbackOutput, "playbackdumps/wav/" + inputFile + ".dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) CapturingRenderersFactory(com.google.android.exoplayer2.testutil.CapturingRenderersFactory) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)44 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)39 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)23 Context (android.content.Context)21 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)21 CapturingRenderersFactory (com.google.android.exoplayer2.testutil.CapturingRenderersFactory)21 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)16 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)15 SurfaceTexture (android.graphics.SurfaceTexture)13 Surface (android.view.Surface)13 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)12 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)10 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)10 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)10 HandlerThread (android.os.HandlerThread)9 TestPlayerRunHelper.playUntilStartOfMediaItem (com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilStartOfMediaItem)9 HandlerWrapper (com.google.android.exoplayer2.util.HandlerWrapper)9 MediaItem (com.google.android.exoplayer2.MediaItem)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 ApplicationProvider (androidx.test.core.app.ApplicationProvider)5