Search in sources :

Example 1 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project collect by opendatakit.

the class MainActivityTest method sendDataButtonTest.

/**
 * {@link Test} to assert sendDataButton's functioning.
 */
@Test
public void sendDataButtonTest() throws Exception {
    Button sendDataButton = mainMenuActivity.findViewById(R.id.send_data);
    assertNotNull(sendDataButton);
    assertEquals(View.VISIBLE, sendDataButton.getVisibility());
    assertEquals(mainMenuActivity.getString(R.string.send_data_button), sendDataButton.getText());
    sendDataButton.performClick();
    ShadowActivity shadowActivity = shadowOf(mainMenuActivity);
    Intent startedIntent = shadowActivity.getNextStartedActivity();
    ShadowIntent shadowIntent = shadowOf(startedIntent);
    assertEquals(InstanceUploaderList.class.getName(), shadowIntent.getIntentClass().getName());
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) ShadowIntent(org.robolectric.shadows.ShadowIntent) Intent(android.content.Intent) Test(org.junit.Test)

Example 2 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project collect by opendatakit.

the class MainActivityTest method dataButtonTest.

/**
 * {@link Test} to assert dataButton's functioning.
 */
@Test
public void dataButtonTest() throws Exception {
    Button dataButton = mainMenuActivity.findViewById(R.id.enter_data);
    assertNotNull(dataButton);
    assertEquals(View.VISIBLE, dataButton.getVisibility());
    assertEquals(mainMenuActivity.getString(R.string.enter_data_button), dataButton.getText());
    dataButton.performClick();
    ShadowActivity shadowActivity = shadowOf(mainMenuActivity);
    Intent startedIntent = shadowActivity.getNextStartedActivity();
    ShadowIntent shadowIntent = shadowOf(startedIntent);
    assertEquals(FormChooserList.class.getName(), shadowIntent.getIntentClass().getName());
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) ShadowIntent(org.robolectric.shadows.ShadowIntent) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with ShadowIntent

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

the class ShareIntentResolverTest method testResolveSoundcloudDataUrlToId.

@Test
public void testResolveSoundcloudDataUrlToId() throws ShareIntentResolverException {
    ShadowIntent intent = Robolectric.shadowOf(mIntent);
    intent.setData(Uri.parse("soundcloud://tracks/76738498"));
    final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
    final PendingDownload result = resolver.resolvePendingDownload();
    assertThat(result.getId(), equalTo("76738498"));
    assertThat(result.getType(), equalTo(MediaDownloadType.TRACK));
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) PendingDownload(net.rdrei.android.scdl2.api.PendingDownload) ShareIntentResolver(net.rdrei.android.scdl2.ShareIntentResolver) Test(org.junit.Test)

Example 4 with ShadowIntent

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

the class ShareIntentResolverTest method testResolveToId.

@Test
public void testResolveToId() throws ShareIntentResolverException {
    ShadowIntent intent = Robolectric.shadowOf(mIntent);
    intent.setData(Uri.parse("https://soundcloud.com/dj-newklear/newklear-contaminated-2"));
    final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
    final PendingDownload result = resolver.resolvePendingDownload();
    assertThat(result.getId(), equalTo("44276907"));
    assertThat(result.getType(), equalTo(MediaDownloadType.TRACK));
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) PendingDownload(net.rdrei.android.scdl2.api.PendingDownload) ShareIntentResolver(net.rdrei.android.scdl2.ShareIntentResolver) Test(org.junit.Test)

Example 5 with ShadowIntent

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

the class ShareIntentResolverTest method testNoSslResolveToId.

@Test
public void testNoSslResolveToId() throws ShareIntentResolverException {
    ShadowIntent intent = Robolectric.shadowOf(mIntent);
    intent.setData(Uri.parse("http://soundcloud.com/dj-newklear/newklear-contaminated-2"));
    final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
    final PendingDownload result = resolver.resolvePendingDownload();
    assertThat(result.getId(), equalTo("44276907"));
    assertThat(result.getType(), equalTo(MediaDownloadType.TRACK));
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) PendingDownload(net.rdrei.android.scdl2.api.PendingDownload) ShareIntentResolver(net.rdrei.android.scdl2.ShareIntentResolver) Test(org.junit.Test)

Aggregations

ShadowIntent (org.robolectric.shadows.ShadowIntent)15 Test (org.junit.Test)14 ShareIntentResolver (net.rdrei.android.scdl2.ShareIntentResolver)8 Intent (android.content.Intent)7 ShadowActivity (org.robolectric.shadows.ShadowActivity)7 Button (android.widget.Button)5 PendingDownload (net.rdrei.android.scdl2.api.PendingDownload)3 FragmentActivity (android.support.v4.app.FragmentActivity)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 PreferencesActivity (org.odk.collect.android.preferences.PreferencesActivity)1 TestMenuItem (org.robolectric.tester.android.view.TestMenuItem)1