Search in sources :

Example 1 with ShadowMediaPlayer.addException

use of org.robolectric.shadows.ShadowMediaPlayer.addException in project robolectric by robolectric.

the class ShadowMediaPlayerTest method testSetDataSourceCustomExceptionOverridesIllegalState.

@Test
public void testSetDataSourceCustomExceptionOverridesIllegalState() {
    shadowMediaPlayer.setState(PREPARED);
    ShadowMediaPlayer.addException(toDataSource("dummy"), new IOException());
    try {
        mediaPlayer.setDataSource("dummy");
        fail("Expecting IOException to be thrown");
    } catch (IOException eThrown) {
    } catch (Exception eThrown) {
        fail(eThrown + " was thrown, expecting IOException");
    }
}
Also used : IOException(java.io.IOException) ShadowMediaPlayer.addException(org.robolectric.shadows.ShadowMediaPlayer.addException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1 ShadowMediaPlayer.addException (org.robolectric.shadows.ShadowMediaPlayer.addException)1