Search in sources :

Example 11 with ExoPlayerTestRunner

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

the class ExoPlayerTest method stop_withoutReset_doesNotResetPosition_correctMasking.

@Test
public void stop_withoutReset_doesNotResetPosition_correctMasking() throws Exception {
    int[] currentMediaItemIndex = { C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET };
    long[] currentPosition = { C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET };
    long[] bufferedPosition = { C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET };
    long[] totalBufferedDuration = { C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET };
    final FakeMediaSource mediaSource = new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().seek(/* mediaItemIndex= */
    1, /* positionMs= */
    1000).waitForPlaybackState(Player.STATE_READY).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            currentMediaItemIndex[0] = player.getCurrentMediaItemIndex();
            currentPosition[0] = player.getCurrentPosition();
            bufferedPosition[0] = player.getBufferedPosition();
            totalBufferedDuration[0] = player.getTotalBufferedDuration();
            player.stop(/* reset= */
            false);
            currentMediaItemIndex[1] = player.getCurrentMediaItemIndex();
            currentPosition[1] = player.getCurrentPosition();
            bufferedPosition[1] = player.getBufferedPosition();
            totalBufferedDuration[1] = player.getTotalBufferedDuration();
        }
    }).waitForPlaybackState(Player.STATE_IDLE).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            currentMediaItemIndex[2] = player.getCurrentMediaItemIndex();
            currentPosition[2] = player.getCurrentPosition();
            bufferedPosition[2] = player.getBufferedPosition();
            totalBufferedDuration[2] = player.getTotalBufferedDuration();
        }
    }).build();
    ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder(context).setMediaSources(mediaSource, mediaSource).setActionSchedule(actionSchedule).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
    testRunner.assertTimelineChangeReasonsEqual(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
    testRunner.assertPositionDiscontinuityReasonsEqual(Player.DISCONTINUITY_REASON_SEEK);
    assertThat(currentMediaItemIndex[0]).isEqualTo(1);
    assertThat(currentPosition[0]).isEqualTo(1000);
    assertThat(bufferedPosition[0]).isEqualTo(10000);
    assertThat(totalBufferedDuration[0]).isEqualTo(9000);
    assertThat(currentMediaItemIndex[1]).isEqualTo(1);
    assertThat(currentPosition[1]).isEqualTo(1000);
    assertThat(bufferedPosition[1]).isEqualTo(1000);
    assertThat(totalBufferedDuration[1]).isEqualTo(0);
    assertThat(currentMediaItemIndex[2]).isEqualTo(1);
    assertThat(currentPosition[2]).isEqualTo(1000);
    assertThat(bufferedPosition[2]).isEqualTo(1000);
    assertThat(totalBufferedDuration[2]).isEqualTo(0);
}
Also used : FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) PlayerRunnable(com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) ExoPlayerTestRunner(com.google.android.exoplayer2.testutil.ExoPlayerTestRunner) Test(org.junit.Test)

Example 12 with ExoPlayerTestRunner

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

the class ExoPlayerTest method stopWithNoReset_modifyingPlaylistRemainsInIdleState_needsPrepareForBuffering.

@Test
public void stopWithNoReset_modifyingPlaylistRemainsInIdleState_needsPrepareForBuffering() throws Exception {
    Timeline timeline = new FakeTimeline();
    FakeMediaSource secondMediaSource = new FakeMediaSource(timeline);
    int[] playbackStateHolder = new int[3];
    int[] windowCountHolder = new int[3];
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).waitForPlaybackState(Player.STATE_READY).stop(/* reset= */
    false).executeRunnable(new PlaybackStateCollector(/* index= */
    0, playbackStateHolder, windowCountHolder)).clearMediaItems().executeRunnable(new PlaybackStateCollector(/* index= */
    1, playbackStateHolder, windowCountHolder)).addMediaSources(secondMediaSource).executeRunnable(new PlaybackStateCollector(/* index= */
    2, playbackStateHolder, windowCountHolder)).prepare().waitForPlaybackState(Player.STATE_BUFFERING).waitForPlaybackState(Player.STATE_READY).waitForPlaybackState(Player.STATE_ENDED).build();
    ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context).setTimeline(timeline).setActionSchedule(actionSchedule).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
    assertArrayEquals(new int[] { Player.STATE_IDLE, Player.STATE_IDLE, Player.STATE_IDLE }, playbackStateHolder);
    assertArrayEquals(new int[] { 1, 0, 1 }, windowCountHolder);
    exoPlayerTestRunner.assertPlaybackStatesEqual(// first buffering
    Player.STATE_BUFFERING, Player.STATE_READY, // stop
    Player.STATE_IDLE, Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED);
    exoPlayerTestRunner.assertTimelinesSame(placeholderTimeline, timeline, Timeline.EMPTY, placeholderTimeline, timeline);
    exoPlayerTestRunner.assertTimelineChangeReasonsEqual(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, /* media item set (masked timeline) */
    Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, /* source prepared */
    Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, /* clear media items */
    Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, /* media item add (masked timeline) */
    Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
}
Also used : NoUidTimeline(com.google.android.exoplayer2.testutil.NoUidTimeline) SinglePeriodTimeline(com.google.android.exoplayer2.source.SinglePeriodTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) ExoPlayerTestRunner(com.google.android.exoplayer2.testutil.ExoPlayerTestRunner) Test(org.junit.Test)

Example 13 with ExoPlayerTestRunner

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

the class ExoPlayerTest method setMediaSources_whenIdle_noSeekEmpty_correctMaskingPlaybackState.

@Test
public void setMediaSources_whenIdle_noSeekEmpty_correctMaskingPlaybackState() throws Exception {
    final int[] maskingPlaybackStates = new int[1];
    Arrays.fill(maskingPlaybackStates, C.INDEX_UNSET);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            // Set an empty media item with no seek.
            player.setMediaSource(new ConcatenatingMediaSource());
            maskingPlaybackStates[0] = player.getPlaybackState();
        }
    }).setMediaSources(new FakeMediaSource()).prepare().waitForPlaybackState(Player.STATE_READY).build();
    ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context).skipSettingMediaSources().setActionSchedule(actionSchedule).build().start(/* doPrepare= */
    false).blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
    // Expect reset of masking to first media item.
    exoPlayerTestRunner.assertPlaybackStatesEqual(Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED);
    assertArrayEquals(new int[] { Player.STATE_IDLE }, maskingPlaybackStates);
    exoPlayerTestRunner.assertTimelineChangeReasonsEqual(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
}
Also used : FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) PlayerRunnable(com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) ExoPlayerTestRunner(com.google.android.exoplayer2.testutil.ExoPlayerTestRunner) Test(org.junit.Test)

Example 14 with ExoPlayerTestRunner

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

the class ExoPlayerTest method setMediaSources_whenIdle_correctMaskingPlaybackState.

@Test
public void setMediaSources_whenIdle_correctMaskingPlaybackState() throws Exception {
    final int[] maskingPlaybackStates = new int[4];
    Arrays.fill(maskingPlaybackStates, C.INDEX_UNSET);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            // Set empty media item with no seek.
            player.setMediaSource(new ConcatenatingMediaSource());
            maskingPlaybackStates[0] = player.getPlaybackState();
        }
    }).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            // Set media item with an implicit seek to the current position.
            player.setMediaSource(new FakeMediaSource());
            maskingPlaybackStates[1] = player.getPlaybackState();
        }
    }).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            // Set media item with an explicit seek.
            player.setMediaSource(new FakeMediaSource(), /* startPositionMs= */
            C.TIME_UNSET);
            maskingPlaybackStates[2] = player.getPlaybackState();
        }
    }).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            // Set empty media item with an explicit seek.
            player.setMediaSource(new ConcatenatingMediaSource(), /* startPositionMs= */
            C.TIME_UNSET);
            maskingPlaybackStates[3] = player.getPlaybackState();
        }
    }).prepare().build();
    ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context).skipSettingMediaSources().setActionSchedule(actionSchedule).build().start(/* doPrepare= */
    false).blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
    // Expect reset of masking to first media item.
    exoPlayerTestRunner.assertPlaybackStatesEqual(Player.STATE_ENDED);
    assertArrayEquals(new int[] { Player.STATE_IDLE, Player.STATE_IDLE, Player.STATE_IDLE, Player.STATE_IDLE }, maskingPlaybackStates);
    exoPlayerTestRunner.assertTimelineChangeReasonsEqual(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
}
Also used : FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) PlayerRunnable(com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) ExoPlayerTestRunner(com.google.android.exoplayer2.testutil.ExoPlayerTestRunner) Test(org.junit.Test)

Example 15 with ExoPlayerTestRunner

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

the class ExoPlayerTest method loading_withLargeAllocationCausingOom_playsRemainingMediaAndThenThrows.

@Test
public void loading_withLargeAllocationCausingOom_playsRemainingMediaAndThenThrows() {
    Loader.Loadable loadable = new Loader.Loadable() {

        @SuppressWarnings("UnusedVariable")
        @Override
        public void load() throws IOException {
            // This test needs the allocation to cause an OOM.
            @SuppressWarnings("unused") byte[] largeBuffer = new byte[Integer.MAX_VALUE];
        }

        @Override
        public void cancelLoad() {
        }
    };
    // Create 3 samples without end of stream signal to test that all 3 samples are
    // still played before the sample stream exception is thrown.
    FakeSampleStreamItem sample = oneByteSample(TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US, C.BUFFER_FLAG_KEY_FRAME);
    FakeMediaPeriod.TrackDataFactory threeSamplesWithoutEos = (format, mediaPeriodId) -> ImmutableList.of(sample, sample, sample);
    MediaSource largeBufferAllocatingMediaSource = new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT) {

        @Override
        protected MediaPeriod createMediaPeriod(MediaPeriodId id, TrackGroupArray trackGroupArray, Allocator allocator, MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher, DrmSessionManager drmSessionManager, DrmSessionEventListener.EventDispatcher drmEventDispatcher, @Nullable TransferListener transferListener) {
            return new FakeMediaPeriod(trackGroupArray, allocator, threeSamplesWithoutEos, mediaSourceEventDispatcher, drmSessionManager, drmEventDispatcher, /* deferOnPrepared= */
            false) {

                private final Loader loader = new Loader("ExoPlayerTest");

                @Override
                public boolean continueLoading(long positionUs) {
                    super.continueLoading(positionUs);
                    if (!loader.isLoading()) {
                        loader.startLoading(loadable, new FakeLoaderCallback(), /* defaultMinRetryCount= */
                        1);
                    }
                    return true;
                }

                @Override
                protected FakeSampleStream createSampleStream(Allocator allocator, @Nullable MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher, DrmSessionManager drmSessionManager, DrmSessionEventListener.EventDispatcher drmEventDispatcher, Format initialFormat, List<FakeSampleStreamItem> fakeSampleStreamItems) {
                    return new FakeSampleStream(allocator, mediaSourceEventDispatcher, drmSessionManager, drmEventDispatcher, initialFormat, fakeSampleStreamItems) {

                        @Override
                        public void maybeThrowError() throws IOException {
                            loader.maybeThrowError();
                        }
                    };
                }
            };
        }
    };
    FakeRenderer renderer = new FakeRenderer(C.TRACK_TYPE_VIDEO);
    ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder(context).setMediaSources(largeBufferAllocatingMediaSource).setRenderers(renderer).build();
    ExoPlaybackException exception = assertThrows(ExoPlaybackException.class, () -> testRunner.start().blockUntilEnded(TIMEOUT_MS));
    assertThat(exception.type).isEqualTo(ExoPlaybackException.TYPE_SOURCE);
    assertThat(exception.getSourceException()).isInstanceOf(Loader.UnexpectedLoaderException.class);
    assertThat(exception.getSourceException().getCause()).isInstanceOf(OutOfMemoryError.class);
    assertThat(renderer.sampleBufferReadCount).isEqualTo(3);
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers(org.mockito.ArgumentMatchers) COMMAND_SEEK_TO_NEXT_MEDIA_ITEM(com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Uri(android.net.Uri) BinaryFrame(com.google.android.exoplayer2.metadata.id3.BinaryFrame) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) FakeTrackSelector(com.google.android.exoplayer2.testutil.FakeTrackSelector) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) NoUidTimeline(com.google.android.exoplayer2.testutil.NoUidTimeline) COMMAND_SEEK_TO_PREVIOUS(com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS) ExoPlayerTestRunner(com.google.android.exoplayer2.testutil.ExoPlayerTestRunner) TestPlayerRunHelper.runUntilTimelineChanged(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilTimelineChanged) MimeTypes(com.google.android.exoplayer2.util.MimeTypes) TestPlayerRunHelper.playUntilStartOfMediaItem(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilStartOfMediaItem) COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM(com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM) Looper(android.os.Looper) MediaPeriod(com.google.android.exoplayer2.source.MediaPeriod) FakeSampleStream(com.google.android.exoplayer2.testutil.FakeSampleStream) COMMAND_GET_TRACK_INFOS(com.google.android.exoplayer2.Player.COMMAND_GET_TRACK_INFOS) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame) TransferListener(com.google.android.exoplayer2.upstream.TransferListener) PlayerRunnable(com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable) Surface(android.view.Surface) DEFAULT_WINDOW_DURATION_US(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) Range(com.google.common.collect.Range) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) CountDownLatch(java.util.concurrent.CountDownLatch) COMMAND_STOP(com.google.android.exoplayer2.Player.COMMAND_STOP) Nullable(androidx.annotation.Nullable) ArgumentMatchers.anyFloat(org.mockito.ArgumentMatchers.anyFloat) ServerSideAdInsertionMediaSource(com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource) COMMAND_GET_TEXT(com.google.android.exoplayer2.Player.COMMAND_GET_TEXT) Mockito.mock(org.mockito.Mockito.mock) FakeAdaptiveMediaSource(com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource) TestPlayerRunHelper.runUntilPendingCommandsAreFullyHandled(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilPendingCommandsAreFullyHandled) Iterables(com.google.common.collect.Iterables) COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM(com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM) AdPlaybackState(com.google.android.exoplayer2.source.ads.AdPlaybackState) RunWith(org.junit.runner.RunWith) Config(org.robolectric.annotation.Config) SinglePeriodTimeline(com.google.android.exoplayer2.source.SinglePeriodTimeline) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) ArrayList(java.util.ArrayList) Listener(com.google.android.exoplayer2.Player.Listener) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) TestPlayerRunHelper.runUntilPositionDiscontinuity(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilPositionDiscontinuity) FakeChunkSource(com.google.android.exoplayer2.testutil.FakeChunkSource) MediaSourceEventListener(com.google.android.exoplayer2.source.MediaSourceEventListener) Before(org.junit.Before) DiscontinuityReason(com.google.android.exoplayer2.Player.DiscontinuityReason) COMMAND_GET_CURRENT_MEDIA_ITEM(com.google.android.exoplayer2.Player.COMMAND_GET_CURRENT_MEDIA_ITEM) Clock(com.google.android.exoplayer2.util.Clock) ShadowLooper(org.robolectric.shadows.ShadowLooper) COMMAND_GET_TIMELINE(com.google.android.exoplayer2.Player.COMMAND_GET_TIMELINE) PlayerTarget(com.google.android.exoplayer2.testutil.ActionSchedule.PlayerTarget) COMMAND_SET_TRACK_SELECTION_PARAMETERS(com.google.android.exoplayer2.Player.COMMAND_SET_TRACK_SELECTION_PARAMETERS) TestPlayerRunHelper.runUntilReceiveOffloadSchedulingEnabledNewState(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilReceiveOffloadSchedulingEnabledNewState) Mockito.times(org.mockito.Mockito.times) IOException(java.io.IOException) Test(org.junit.Test) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray) TestUtil.assertTimelinesSame(com.google.android.exoplayer2.testutil.TestUtil.assertTimelinesSame) TestPlayerRunHelper(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper) AtomicLong(java.util.concurrent.atomic.AtomicLong) Mockito.never(org.mockito.Mockito.never) COMMAND_SEEK_TO_DEFAULT_POSITION(com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_DEFAULT_POSITION) COMMAND_GET_AUDIO_ATTRIBUTES(com.google.android.exoplayer2.Player.COMMAND_GET_AUDIO_ATTRIBUTES) MaskingMediaSource(com.google.android.exoplayer2.source.MaskingMediaSource) Loader(com.google.android.exoplayer2.upstream.Loader) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) Mockito.reset(org.mockito.Mockito.reset) COMMAND_PREPARE(com.google.android.exoplayer2.Player.COMMAND_PREPARE) Assertions(com.google.android.exoplayer2.util.Assertions) COMMAND_CHANGE_MEDIA_ITEMS(com.google.android.exoplayer2.Player.COMMAND_CHANGE_MEDIA_ITEMS) Util(com.google.android.exoplayer2.util.Util) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) COMMAND_SEEK_TO_NEXT(com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) Random(java.util.Random) TestPlayerRunHelper.playUntilPosition(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilPosition) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) ApplicationProvider(androidx.test.core.app.ApplicationProvider) ArgumentMatcher(org.mockito.ArgumentMatcher) Allocation(com.google.android.exoplayer2.upstream.Allocation) COMMAND_SET_VOLUME(com.google.android.exoplayer2.Player.COMMAND_SET_VOLUME) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState) Mockito.atLeast(org.mockito.Mockito.atLeast) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) Assert.fail(org.junit.Assert.fail) COMMAND_SEEK_BACK(com.google.android.exoplayer2.Player.COMMAND_SEEK_BACK) MediaSource(com.google.android.exoplayer2.source.MediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) COMMAND_GET_MEDIA_ITEMS_METADATA(com.google.android.exoplayer2.Player.COMMAND_GET_MEDIA_ITEMS_METADATA) RobolectricUtil.runMainLooperUntil(com.google.android.exoplayer2.robolectric.RobolectricUtil.runMainLooperUntil) TestPlayerRunHelper.runUntilPlaybackState(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilPlaybackState) END_OF_STREAM_ITEM(com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.END_OF_STREAM_ITEM) COMMAND_ADJUST_DEVICE_VOLUME(com.google.android.exoplayer2.Player.COMMAND_ADJUST_DEVICE_VOLUME) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) Collectors(java.util.stream.Collectors) COMMAND_SET_REPEAT_MODE(com.google.android.exoplayer2.Player.COMMAND_SET_REPEAT_MODE) COMMAND_SET_SHUFFLE_MODE(com.google.android.exoplayer2.Player.COMMAND_SET_SHUFFLE_MODE) FakeSampleStreamItem.oneByteSample(com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.oneByteSample) List(java.util.List) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) COMMAND_GET_VOLUME(com.google.android.exoplayer2.Player.COMMAND_GET_VOLUME) Mockito.inOrder(org.mockito.Mockito.inOrder) FakeVideoRenderer(com.google.android.exoplayer2.testutil.FakeVideoRenderer) FakeAdaptiveDataSet(com.google.android.exoplayer2.testutil.FakeAdaptiveDataSet) COMMAND_PLAY_PAUSE(com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE) Action(com.google.android.exoplayer2.testutil.Action) AdditionalMatchers.not(org.mockito.AdditionalMatchers.not) AudioAttributes(com.google.android.exoplayer2.audio.AudioAttributes) Metadata(com.google.android.exoplayer2.metadata.Metadata) CompositeMediaSource(com.google.android.exoplayer2.source.CompositeMediaSource) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) AnalyticsListener(com.google.android.exoplayer2.analytics.AnalyticsListener) COMMAND_GET_DEVICE_VOLUME(com.google.android.exoplayer2.Player.COMMAND_GET_DEVICE_VOLUME) COMMAND_SEEK_FORWARD(com.google.android.exoplayer2.Player.COMMAND_SEEK_FORWARD) Context(android.content.Context) COMMAND_SEEK_TO_MEDIA_ITEM(com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_MEDIA_ITEM) COMMAND_SET_MEDIA_ITEMS_METADATA(com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEMS_METADATA) DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US) TimelineWindowDefinition(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition) Assert.assertThrows(org.junit.Assert.assertThrows) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Intent(android.content.Intent) AtomicReference(java.util.concurrent.atomic.AtomicReference) STATE_ENDED(com.google.android.exoplayer2.Player.STATE_ENDED) Shadows.shadowOf(org.robolectric.Shadows.shadowOf) AudioManager(android.media.AudioManager) HashSet(java.util.HashSet) ArgumentCaptor(org.mockito.ArgumentCaptor) ShadowAudioManager(org.robolectric.shadows.ShadowAudioManager) DrmSessionEventListener(com.google.android.exoplayer2.drm.DrmSessionEventListener) ImmutableList(com.google.common.collect.ImmutableList) TestPlayerRunHelper.runUntilSleepingForOffload(com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilSleepingForOffload) FakeRenderer(com.google.android.exoplayer2.testutil.FakeRenderer) COMMAND_SET_DEVICE_VOLUME(com.google.android.exoplayer2.Player.COMMAND_SET_DEVICE_VOLUME) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) ClippingMediaSource(com.google.android.exoplayer2.source.ClippingMediaSource) COMMAND_SET_SPEED_AND_PITCH(com.google.android.exoplayer2.Player.COMMAND_SET_SPEED_AND_PITCH) Allocator(com.google.android.exoplayer2.upstream.Allocator) SurfaceTexture(android.graphics.SurfaceTexture) COMMAND_SET_VIDEO_SURFACE(com.google.android.exoplayer2.Player.COMMAND_SET_VIDEO_SURFACE) Window(com.google.android.exoplayer2.Timeline.Window) FakeSampleStreamItem(com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem) InOrder(org.mockito.InOrder) PositionInfo(com.google.android.exoplayer2.Player.PositionInfo) Truth.assertThat(com.google.common.truth.Truth.assertThat) FakeMediaPeriod(com.google.android.exoplayer2.testutil.FakeMediaPeriod) Mockito.verify(org.mockito.Mockito.verify) FakeDataSource(com.google.android.exoplayer2.testutil.FakeDataSource) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) FakeMediaSourceFactory(com.google.android.exoplayer2.testutil.FakeMediaSourceFactory) Mockito(org.mockito.Mockito) FakeTrackSelection(com.google.android.exoplayer2.testutil.FakeTrackSelection) Collections(java.util.Collections) TransferListener(com.google.android.exoplayer2.upstream.TransferListener) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) Loader(com.google.android.exoplayer2.upstream.Loader) FakeRenderer(com.google.android.exoplayer2.testutil.FakeRenderer) FakeMediaPeriod(com.google.android.exoplayer2.testutil.FakeMediaPeriod) FakeSampleStreamItem(com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ExoPlayerTestRunner(com.google.android.exoplayer2.testutil.ExoPlayerTestRunner) Allocator(com.google.android.exoplayer2.upstream.Allocator) DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) FakeSampleStream(com.google.android.exoplayer2.testutil.FakeSampleStream) ServerSideAdInsertionMediaSource(com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource) FakeAdaptiveMediaSource(com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource) MaskingMediaSource(com.google.android.exoplayer2.source.MaskingMediaSource) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) CompositeMediaSource(com.google.android.exoplayer2.source.CompositeMediaSource) ClippingMediaSource(com.google.android.exoplayer2.source.ClippingMediaSource) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Nullable(androidx.annotation.Nullable) Test(org.junit.Test)

Aggregations

ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)51 Test (org.junit.Test)51 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)49 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)42 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)41 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)41 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)33 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)33 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)26 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)23 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)16 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)16 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)16 MediaSource (com.google.android.exoplayer2.source.MediaSource)16 ServerSideAdInsertionMediaSource (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource)16 FakeAdaptiveMediaSource (com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource)16 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)15 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)7 TransferListener (com.google.android.exoplayer2.upstream.TransferListener)7 IOException (java.io.IOException)7