Search in sources :

Example 16 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)

Example 17 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 18 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project android_packages_apps_Settings by omnirom.

the class UserSettingsTest method onPreferenceClick_addGuestClicked_createGuestAndOpenDetails.

@Test
public void onPreferenceClick_addGuestClicked_createGuestAndOpenDetails() {
    UserInfo createdGuest = getGuest(false);
    removeFlag(createdGuest, UserInfo.FLAG_INITIALIZED);
    doReturn(createdGuest).when(mUserManager).createGuest(mActivity, "Guest");
    doReturn(mActivity).when(mFragment).getContext();
    mFragment.onPreferenceClick(mAddGuestPreference);
    verify(mUserManager).createGuest(mActivity, "Guest");
    Intent startedIntent = shadowOf(mActivity).getNextStartedActivity();
    ShadowIntent shadowIntent = shadowOf(startedIntent);
    assertThat(shadowIntent.getIntentClass()).isEqualTo(SubSettings.class);
    assertThat(startedIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(UserDetailsSettings.class.getName());
    Bundle arguments = startedIntent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
    assertThat(arguments).isNotNull();
    assertThat(arguments.getInt(UserDetailsSettings.EXTRA_USER_ID, 0)).isEqualTo(createdGuest.id);
    assertThat(arguments.getBoolean(AppRestrictionsFragment.EXTRA_NEW_USER, false)).isEqualTo(true);
    verify(mMetricsFeatureProvider).action(any(), eq(SettingsEnums.ACTION_USER_GUEST_ADD));
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) Bundle(android.os.Bundle) UserInfo(android.content.pm.UserInfo) Intent(android.content.Intent) ShadowIntent(org.robolectric.shadows.ShadowIntent) Test(org.junit.Test)

Example 19 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project android_packages_apps_Settings by omnirom.

the class UserDetailsSettingsTest method onPreferenceClick_selectRestrictedUser_appAndContentAccessClicked_startActivity.

@Test
public void onPreferenceClick_selectRestrictedUser_appAndContentAccessClicked_startActivity() {
    setupSelectedRestrictedUser();
    mFragment.mUserInfo = mUserInfo;
    mUserManager.setIsAdminUser(true);
    mFragment.mSwitchUserPref = mSwitchUserPref;
    mFragment.mRemoveUserPref = mRemoveUserPref;
    mFragment.mAppAndContentAccessPref = mAppAndContentAccessPref;
    mFragment.onPreferenceClick(mAppAndContentAccessPref);
    Intent startedIntent = shadowOf(mActivity).getNextStartedActivity();
    ShadowIntent shadowIntent = shadowOf(startedIntent);
    assertThat(shadowIntent.getIntentClass()).isEqualTo(SubSettings.class);
    assertThat(startedIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(AppRestrictionsFragment.class.getName());
    Bundle arguments = startedIntent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
    assertThat(arguments.getInt(AppRestrictionsFragment.EXTRA_USER_ID, 0)).isEqualTo(mUserInfo.id);
    assertThat(arguments.getBoolean(AppRestrictionsFragment.EXTRA_NEW_USER, true)).isEqualTo(false);
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) Bundle(android.os.Bundle) Intent(android.content.Intent) ShadowIntent(org.robolectric.shadows.ShadowIntent) Test(org.junit.Test)

Example 20 with ShadowIntent

use of org.robolectric.shadows.ShadowIntent in project android_packages_apps_Settings by omnirom.

the class UserDetailsSettingsTest method initialize_adminSelectsNewRestrictedUser_shouldOpenAppContentScreen.

@Test
public void initialize_adminSelectsNewRestrictedUser_shouldOpenAppContentScreen() {
    setupSelectedRestrictedUser();
    mUserManager.setIsAdminUser(true);
    mArguments.putBoolean(AppRestrictionsFragment.EXTRA_NEW_USER, true);
    mFragment.initialize(mActivity, mArguments);
    Intent startedIntent = shadowOf(mActivity).getNextStartedActivity();
    ShadowIntent shadowIntent = shadowOf(startedIntent);
    assertThat(shadowIntent.getIntentClass()).isEqualTo(SubSettings.class);
    assertThat(startedIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(AppRestrictionsFragment.class.getName());
    Bundle arguments = startedIntent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
    assertThat(arguments).isNotNull();
    assertThat(arguments.getInt(AppRestrictionsFragment.EXTRA_USER_ID, 0)).isEqualTo(mUserInfo.id);
    assertThat(arguments.getBoolean(AppRestrictionsFragment.EXTRA_NEW_USER, false)).isEqualTo(true);
}
Also used : ShadowIntent(org.robolectric.shadows.ShadowIntent) Bundle(android.os.Bundle) Intent(android.content.Intent) ShadowIntent(org.robolectric.shadows.ShadowIntent) Test(org.junit.Test)

Aggregations

ShadowIntent (org.robolectric.shadows.ShadowIntent)20 Test (org.junit.Test)19 Intent (android.content.Intent)12 ShareIntentResolver (net.rdrei.android.scdl2.ShareIntentResolver)8 ShadowActivity (org.robolectric.shadows.ShadowActivity)7 Button (android.widget.Button)5 Bundle (android.os.Bundle)3 PendingDownload (net.rdrei.android.scdl2.api.PendingDownload)3 UserInfo (android.content.pm.UserInfo)1 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