Search in sources :

Example 6 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project scdl by passy.

the class PreferencesMenuTest method shouldStartPreferencesInActivity.

private void shouldStartPreferencesInActivity(Fragment fragment) {
    final ActivityController<FragmentActivity> controller = Robolectric.buildActivity(FragmentActivity.class);
    controller.create().start().resume();
    final FragmentActivity activity = controller.get();
    activity.getSupportFragmentManager().beginTransaction().add(fragment, null).commit();
    final MenuItem item = new TestMenuItem(R.id.preferences);
    fragment.onOptionsItemSelected(item);
    final ShadowActivity shadowActivity = Robolectric.shadowOf(activity);
    final Intent startedActivity = shadowActivity.getNextStartedActivity();
    // Intent was actually started
    assertThat(startedActivity, notNullValue());
    final ShadowIntent intent = Robolectric.shadowOf(startedActivity);
    assertThat(intent.getComponent().getClassName(), equalTo(ApplicationPreferencesActivity.class.getName()));
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) ShadowIntent(org.robolectric.shadows.ShadowIntent) TestMenuItem(org.robolectric.tester.android.view.TestMenuItem) ShadowActivity(org.robolectric.shadows.ShadowActivity) TestMenuItem(org.robolectric.tester.android.view.TestMenuItem) MenuItem(android.view.MenuItem) ShadowIntent(org.robolectric.shadows.ShadowIntent) Intent(android.content.Intent)

Example 7 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project scdl by passy.

the class ShareIntentResolverTest method testFailWithPlaylistUrl.

@Test(expected = ShareIntentResolver.UnsupportedPlaylistUrlException.class)
public void testFailWithPlaylistUrl() throws ShareIntentResolverException {
    ShadowIntent intent = Robolectric.shadowOf(mIntent);
    intent.setData(Uri.parse("https://soundcloud.com/revealed-recordings/sets/3lau-paris-simo-feat-bright"));
    final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
    resolver.resolvePendingDownload();
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) ShareIntentResolver(net.rdrei.android.scdl2.ShareIntentResolver) Test(org.junit.Test)

Example 8 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project scdl by passy.

the class ShareIntentResolverTest method testFailWithSuperInvalidUrl.

@Test(expected = ShareIntentResolverException.class)
public void testFailWithSuperInvalidUrl() throws ShareIntentResolverException {
    ShadowIntent intent = Robolectric.shadowOf(mIntent);
    intent.setData(Uri.parse("//nope"));
    final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
    resolver.resolve();
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) ShareIntentResolver(net.rdrei.android.scdl2.ShareIntentResolver) Test(org.junit.Test)

Example 9 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project scdl by passy.

the class ShareIntentResolverTest method testFailWithInvalidUrl.

@Test(expected = ShareIntentResolverException.class)
public void testFailWithInvalidUrl() throws ShareIntentResolverException {
    ShadowIntent intent = Robolectric.shadowOf(mIntent);
    intent.setData(Uri.parse("https://yoosello.de/"));
    final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
    resolver.resolve();
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) ShareIntentResolver(net.rdrei.android.scdl2.ShareIntentResolver) Test(org.junit.Test)

Aggregations

ShadowIntent (org.robolectric.shadows.ShadowIntent)9 ShareIntentResolver (net.rdrei.android.scdl2.ShareIntentResolver)8 Test (org.junit.Test)8 PendingDownload (net.rdrei.android.scdl2.api.PendingDownload)3 Intent (android.content.Intent)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 MenuItem (android.view.MenuItem)1 ShadowActivity (org.robolectric.shadows.ShadowActivity)1 TestMenuItem (org.robolectric.tester.android.view.TestMenuItem)1