use of org.robolectric.shadows.ShadowMediaPlayer.MediaInfo in project robolectric by robolectric.
the class ShadowMediaPlayerTest method testSetDataSourceUsesCustomMediaInfoProvider.
@Test
public void testSetDataSourceUsesCustomMediaInfoProvider() throws Exception {
MediaInfo mediaInfo = new MediaInfo();
ShadowMediaPlayer.setMediaInfoProvider(unused -> mediaInfo);
String path = "data_source_path";
DataSource ds = toDataSource(path);
mediaPlayer.setDataSource(path);
assertWithMessage("dataSource").that(shadowMediaPlayer.getDataSource()).isEqualTo(ds);
assertWithMessage("mediaInfo").that(shadowMediaPlayer.getMediaInfo()).isSameInstanceAs(mediaInfo);
}
use of org.robolectric.shadows.ShadowMediaPlayer.MediaInfo in project robolectric by robolectric.
the class ShadowMediaPlayerTest method setUp.
@Before
public void setUp() {
mediaPlayer = Shadow.newInstanceOf(MediaPlayer.class);
shadowMediaPlayer = shadowOf(mediaPlayer);
completionListener = Mockito.mock(MediaPlayer.OnCompletionListener.class);
mediaPlayer.setOnCompletionListener(completionListener);
preparedListener = Mockito.mock(MediaPlayer.OnPreparedListener.class);
mediaPlayer.setOnPreparedListener(preparedListener);
errorListener = Mockito.mock(MediaPlayer.OnErrorListener.class);
mediaPlayer.setOnErrorListener(errorListener);
infoListener = Mockito.mock(MediaPlayer.OnInfoListener.class);
mediaPlayer.setOnInfoListener(infoListener);
seekListener = Mockito.mock(MediaPlayer.OnSeekCompleteListener.class);
mediaPlayer.setOnSeekCompleteListener(seekListener);
shadowMainLooper().pause();
defaultSource = toDataSource(DUMMY_SOURCE);
info = new MediaInfo();
ShadowMediaPlayer.addMediaInfo(defaultSource, info);
shadowMediaPlayer.doSetDataSource(defaultSource);
}
Aggregations