AppSettingsDialog implements Parcelable { public void show() { startForResult(AppSettingsDialogHolderActivity.createShowDialogIntent(mContext, this)); } private  AppSettingsDialog(Parcel in); private  AppSettingsDialog(@NonNull final Object activityOrFragment,
                              @StyleRes int themeResId,
                              @Nullable String rationale,
                              @Nullable String title,
                              @Nullable String positiveButtonText,
                              @Nullable String negativeButtonText,
                              int requestCode,
                              int intentFlags); void show(); @Override int describeContents(); @Override void writeToParcel(@NonNull Parcel dest, int flags); static final int DEFAULT_SETTINGS_REQ_CODE; @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
    static final Parcelable.Creator<AppSettingsDialog> CREATOR; }
@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); }
@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); }