org.robolectric.shadows.ShadowIntent Java Examples
The following examples show how to use
org.robolectric.shadows.ShadowIntent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppSettingsDialogTest.java From easypermissions with Apache License 2.0 | 6 votes |
@Test public void shouldShowExpectedSettingsDialog_whenBuildingFromActivity() { new AppSettingsDialog.Builder(spyActivity) .setTitle(android.R.string.dialog_alert_title) .setRationale(android.R.string.unknownName) .setPositiveButton(android.R.string.ok) .setNegativeButton(android.R.string.cancel) .setThemeResId(R.style.Theme_AppCompat) .build() .show(); verify(spyActivity, times(1)) .startActivityForResult(intentCaptor.capture(), integerCaptor.capture()); assertThat(integerCaptor.getValue()).isEqualTo(DEFAULT_SETTINGS_REQ_CODE); assertThat(Objects.requireNonNull(intentCaptor.getValue().getComponent()).getClassName()) .isEqualTo(AppSettingsDialogHolderActivity.class.getName()); Intent startedIntent = shadowApp.getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertThat(shadowIntent.getIntentClass()).isEqualTo(AppSettingsDialogHolderActivity.class); }
Example #2
Source File: AppSettingsDialogTest.java From easypermissions with Apache License 2.0 | 6 votes |
@Test public void shouldShowExpectedSettingsDialog_whenBuildingFromSupportFragment() { new AppSettingsDialog.Builder(spyFragment) .setTitle(android.R.string.dialog_alert_title) .setRationale(android.R.string.unknownName) .setPositiveButton(android.R.string.ok) .setNegativeButton(android.R.string.cancel) .setThemeResId(R.style.Theme_AppCompat) .build() .show(); verify(spyFragment, times(1)) .startActivityForResult(intentCaptor.capture(), integerCaptor.capture()); assertThat(integerCaptor.getValue()).isEqualTo(DEFAULT_SETTINGS_REQ_CODE); assertThat(Objects.requireNonNull(intentCaptor.getValue().getComponent()).getClassName()) .isEqualTo(AppSettingsDialogHolderActivity.class.getName()); Intent startedIntent = shadowApp.getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertThat(shadowIntent.getIntentClass()).isEqualTo(AppSettingsDialogHolderActivity.class); }
Example #3
Source File: SmsRadarServiceTest.java From SmsRadar with Apache License 2.0 | 5 votes |
@Test public void shouldRestartServiceUsingAlarmManagerWhenTaskRemoved() { when(mockedTimeProvider.getDate()).thenReturn(new Date(ANY_TIME)); startSmsInterceptorService(); smsRadarService.onTaskRemoved(ANY_INTENT); ArgumentCaptor<PendingIntent> pendingIntentArgumentCaptor = ArgumentCaptor.forClass(PendingIntent.class); verify(mockedAlarmManager).set(eq(AlarmManager.RTC_WAKEUP), eq(ANY_TIME + ONE_SECOND), pendingIntentArgumentCaptor.capture()); PendingIntent capturedPendingIntent = pendingIntentArgumentCaptor.getValue(); ShadowPendingIntent pendingIntent = Robolectric.shadowOf(capturedPendingIntent); ShadowIntent intent = Robolectric.shadowOf(pendingIntent.getSavedIntent()); assertEquals(SmsRadarService.class, intent.getIntentClass()); }
Example #4
Source File: BaseActivityTest.java From open with GNU General Public License v3.0 | 5 votes |
@Test public void onOptionsItemSelected_shouldOpenAboutPage() throws Exception { MenuItem menuItem = menu.findItem(R.id.about); activity.onOptionsItemSelected(menuItem); ShadowActivity shadowActivity = shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertThat(shadowIntent.getAction()).isEqualTo(Intent.ACTION_VIEW); assertThat(shadowIntent.getData()).isEqualTo(Uri.parse("https://mapzen.com/open/about")); }
Example #5
Source File: HomeActivityTest.java From Inside_Android_Testing with Apache License 2.0 | 5 votes |
@Test public void pressingTheButtonShouldStartTheListActivity() throws Exception { pressMeButton.performClick(); ShadowActivity shadowActivity = shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertThat(shadowIntent.getComponent().getClassName(), equalTo(NamesActivity.class.getName())); }
Example #6
Source File: HomeActivityTest.java From Inside_Android_Testing with Apache License 2.0 | 5 votes |
@Test public void pressingTheButtonShouldStartTheSignInActivity() throws Exception { trackerRecentActivityButton.performClick(); ShadowActivity shadowActivity = shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertThat(shadowIntent.getComponent().getClassName(), equalTo(RecentActivityActivity.class.getName())); }
Example #7
Source File: HomeActivityTest.java From Inside_Android_Testing with Apache License 2.0 | 5 votes |
@Test public void shouldLaunchInjectedActivity() throws Exception { clickOn(injectedActivityButton); ShadowActivity shadowActivity = shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); assertNotNull(startedIntent); ShadowIntent shadowIntent = shadowOf(startedIntent); assertThat(shadowIntent.getComponent().getClassName(), equalTo(InjectedActivity.class.getName())); }