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();
}
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();
}
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));
}
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);
}
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);
}
Aggregations