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;
}
}
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);
}
}
}
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);
}
}
}
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()));
}
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()));
}
Aggregations