Search in sources :

Example 16 with LargeTest

use of androidx.test.filters.LargeTest in project ExoPlayer by google.

the class SessionPlayerConnectorTest method setRepeatMode_withRepeatAll_continuesToPlayPlaylistWithoutBeingCompleted.

@Test
@LargeTest
public void setRepeatMode_withRepeatAll_continuesToPlayPlaylistWithoutBeingCompleted() throws Exception {
    List<MediaItem> playlist = new ArrayList<>();
    playlist.add(TestUtils.createMediaItem(R.raw.video_1));
    playlist.add(TestUtils.createMediaItem(R.raw.video_2));
    playlist.add(TestUtils.createMediaItem(R.raw.video_3));
    int listSize = playlist.size();
    // Any value more than list size + 1, to see repeat mode with the recorded video.
    CopyOnWriteArrayList<MediaItem> currentMediaItemChanges = new CopyOnWriteArrayList<>();
    PlayerCallbackForPlaylist callback = new PlayerCallbackForPlaylist(playlist, listSize + 2) {

        @Override
        public void onCurrentMediaItemChanged(SessionPlayer player, MediaItem item) {
            super.onCurrentMediaItemChanged(player, item);
            currentMediaItemChanges.add(item);
            countDown();
        }

        @Override
        public void onPlaybackCompleted(SessionPlayer player) {
            assertWithMessage("Playback shouldn't be completed, Actual changes were %s", currentMediaItemChanges).fail();
        }
    };
    sessionPlayerConnector.registerPlayerCallback(executor, callback);
    assertThat(sessionPlayerConnector.setPlaylist(playlist, null)).isNotNull();
    assertThat(sessionPlayerConnector.prepare()).isNotNull();
    assertThat(sessionPlayerConnector.setRepeatMode(SessionPlayer.REPEAT_MODE_ALL)).isNotNull();
    assertThat(sessionPlayerConnector.play()).isNotNull();
    assertWithMessage("Current media item didn't change as expected. Actual changes were %s", currentMediaItemChanges).that(callback.await(PLAYBACK_COMPLETED_WAIT_TIME_MS, MILLISECONDS)).isTrue();
    int expectedMediaItemIndex = 0;
    for (MediaItem mediaItemInPlaybackOrder : currentMediaItemChanges) {
        assertWithMessage("Unexpected media item for %sth playback. Actual changes were %s", expectedMediaItemIndex, currentMediaItemChanges).that(mediaItemInPlaybackOrder).isEqualTo(playlist.get(expectedMediaItemIndex));
        expectedMediaItemIndex = (expectedMediaItemIndex + 1) % listSize;
    }
}
Also used : UriMediaItem(androidx.media2.common.UriMediaItem) MediaItem(androidx.media2.common.MediaItem) SessionPlayer(androidx.media2.common.SessionPlayer) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) MediumTest(androidx.test.filters.MediumTest) LargeTest(androidx.test.filters.LargeTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 17 with LargeTest

use of androidx.test.filters.LargeTest in project ExoPlayer by google.

the class SessionCallbackBuilderTest method setFastForwardIncrementMs_withPositiveFastForwardIncrement_fastsForward.

@LargeTest
@Test
public void setFastForwardIncrementMs_withPositiveFastForwardIncrement_fastsForward() throws Exception {
    int testResId = R.raw.video_big_buck_bunny;
    int testDuration = 10_000;
    int tolerance = 100;
    int testSeekPosition = 2_000;
    int testFastForwardIncrementMs = 300;
    TestUtils.loadResource(testResId, sessionPlayerConnector);
    // seekTo() sometimes takes couple of seconds. Disable default timeout behavior.
    try (MediaSession session = createMediaSession(sessionPlayerConnector, new SessionCallbackBuilder(context, sessionPlayerConnector).setFastForwardIncrementMs(testFastForwardIncrementMs).setSeekTimeoutMs(0).build())) {
        try (MediaController controller = createConnectedController(session)) {
            // Prepare first to ensure that seek() works.
            assertSessionResultSuccess(controller.prepare(), PLAYER_STATE_CHANGE_OVER_SESSION_WAIT_TIME_MS);
            assertThat((float) sessionPlayerConnector.getDuration()).isWithin(tolerance).of(testDuration);
            assertSessionResultSuccess(controller.seekTo(testSeekPosition), PLAYER_STATE_CHANGE_OVER_SESSION_WAIT_TIME_MS);
            assertThat((float) sessionPlayerConnector.getCurrentPosition()).isWithin(tolerance).of(testSeekPosition);
            // Test fast-forward
            assertSessionResultSuccess(controller.fastForward(), PLAYER_STATE_CHANGE_OVER_SESSION_WAIT_TIME_MS);
            assertThat((float) sessionPlayerConnector.getCurrentPosition()).isWithin(tolerance).of(testSeekPosition + testFastForwardIncrementMs);
        }
    }
}
Also used : MediaController(androidx.media2.session.MediaController) MediaSession(androidx.media2.session.MediaSession) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 18 with LargeTest

use of androidx.test.filters.LargeTest in project ExoPlayer by google.

the class SessionCallbackBuilderTest method setRewindIncrementMs_withPositiveRewindIncrement_rewinds.

@LargeTest
@Test
public void setRewindIncrementMs_withPositiveRewindIncrement_rewinds() throws Exception {
    int testResId = R.raw.video_big_buck_bunny;
    int testDuration = 10_000;
    int tolerance = 100;
    int testSeekPosition = 2_000;
    int testRewindIncrementMs = 500;
    TestUtils.loadResource(testResId, sessionPlayerConnector);
    // seekTo() sometimes takes couple of seconds. Disable default timeout behavior.
    try (MediaSession session = createMediaSession(sessionPlayerConnector, new SessionCallbackBuilder(context, sessionPlayerConnector).setRewindIncrementMs(testRewindIncrementMs).setSeekTimeoutMs(0).build())) {
        try (MediaController controller = createConnectedController(session)) {
            // Prepare first to ensure that seek() works.
            assertSessionResultSuccess(controller.prepare(), PLAYER_STATE_CHANGE_OVER_SESSION_WAIT_TIME_MS);
            assertThat((float) sessionPlayerConnector.getDuration()).isWithin(tolerance).of(testDuration);
            assertSessionResultSuccess(controller.seekTo(testSeekPosition), PLAYER_STATE_CHANGE_OVER_SESSION_WAIT_TIME_MS);
            assertThat((float) sessionPlayerConnector.getCurrentPosition()).isWithin(tolerance).of(testSeekPosition);
            // Test rewind
            assertSessionResultSuccess(controller.rewind(), PLAYER_STATE_CHANGE_OVER_SESSION_WAIT_TIME_MS);
            assertThat((float) sessionPlayerConnector.getCurrentPosition()).isWithin(tolerance).of(testSeekPosition - testRewindIncrementMs);
        }
    }
}
Also used : MediaController(androidx.media2.session.MediaController) MediaSession(androidx.media2.session.MediaSession) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 19 with LargeTest

use of androidx.test.filters.LargeTest in project fdroidclient by f-droid.

the class MainActivityEspressoTest method startSwap.

@LargeTest
@Test
public void startSwap() {
    if (!BuildConfig.FLAVOR.startsWith("full")) {
        return;
    }
    ViewInteraction nearbyBottonNavButton = onView(allOf(withText(R.string.main_menu__swap_nearby), isDisplayed()));
    nearbyBottonNavButton.perform(click());
    ViewInteraction findPeopleButton = onView(allOf(withId(R.id.find_people_button), withText(R.string.nearby_splash__find_people_button), isDisplayed()));
    findPeopleButton.perform(click());
    onView(withText(R.string.swap_send_fdroid)).check(matches(isDisplayed()));
}
Also used : ViewInteraction(androidx.test.espresso.ViewInteraction) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 20 with LargeTest

use of androidx.test.filters.LargeTest in project fdroidclient by f-droid.

the class MainActivityEspressoTest method showUpdates.

@LargeTest
@Test
public void showUpdates() {
    ViewInteraction updatesBottonNavButton = onView(allOf(withText(R.string.main_menu__updates), isDisplayed()));
    updatesBottonNavButton.perform(click());
    onView(withText(R.string.main_menu__updates)).check(matches(isDisplayed()));
}
Also used : ViewInteraction(androidx.test.espresso.ViewInteraction) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Aggregations

LargeTest (androidx.test.filters.LargeTest)36 Test (org.junit.Test)36 MediumTest (androidx.test.filters.MediumTest)29 SmallTest (androidx.test.filters.SmallTest)29 SessionPlayer (androidx.media2.common.SessionPlayer)24 CountDownLatch (java.util.concurrent.CountDownLatch)23 MediaItem (androidx.media2.common.MediaItem)13 UriMediaItem (androidx.media2.common.UriMediaItem)13 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)12 ArrayList (java.util.ArrayList)9 MediaMetadata (androidx.media2.common.MediaMetadata)7 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)7 AudioAttributesCompat (androidx.media.AudioAttributesCompat)3 PlayerResult (androidx.media2.common.SessionPlayer.PlayerResult)3 ViewInteraction (androidx.test.espresso.ViewInteraction)3 TestUtils.assertPlayerResult (com.google.android.exoplayer2.ext.media2.TestUtils.assertPlayerResult)3 Activity (android.app.Activity)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 CancellationSignal (android.os.CancellationSignal)2