Search in sources :

Example 1 with ShareIntentResolver

use of net.rdrei.android.scdl2.ShareIntentResolver in project scdl by passy.

the class ShareIntentResolverTest method testShouldAcceptDataUri.

@Test
public void testShouldAcceptDataUri() 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 String result = resolver.resolve();
    assertThat(result, equalTo("https://api.soundcloud.com/tracks/44276907.json?client_id=429caab2811564cb27f52a7a4964269b"));
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) ShareIntentResolver(net.rdrei.android.scdl2.ShareIntentResolver) Test(org.junit.Test)

Example 2 with ShareIntentResolver

use of net.rdrei.android.scdl2.ShareIntentResolver in project scdl by passy.

the class ShareIntentResolverTest method testShouldAcceptExtraIntent.

@Test
public void testShouldAcceptExtraIntent() throws ShareIntentResolverException {
    ShadowIntent intent = Robolectric.shadowOf(mIntent);
    intent.putExtra(Intent.EXTRA_TEXT, "http://soundcloud.com/dj-newklear/newklear-contaminated-2");
    final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
    final String result = resolver.resolve();
    assertThat(result, equalTo("http://api.soundcloud.com/tracks/44276907.json?client_id=429caab2811564cb27f52a7a4964269b"));
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) ShareIntentResolver(net.rdrei.android.scdl2.ShareIntentResolver) Test(org.junit.Test)

Example 3 with ShareIntentResolver

use of net.rdrei.android.scdl2.ShareIntentResolver 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 ShareIntentResolver

use of net.rdrei.android.scdl2.ShareIntentResolver 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 ShareIntentResolver

use of net.rdrei.android.scdl2.ShareIntentResolver 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

ShareIntentResolver (net.rdrei.android.scdl2.ShareIntentResolver)9 Test (org.junit.Test)9 ShadowIntent (org.robolectric.shadows.ShadowIntent)8 PendingDownload (net.rdrei.android.scdl2.api.PendingDownload)3