use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by SudaMod.
the class DashboardFeatureProviderImplTest method bindPreference_withIntentActionMetatdata_shouldSetLaunchAction.
@Test
public void bindPreference_withIntentActionMetatdata_shouldSetLaunchAction() {
Activity activity = Robolectric.buildActivity(Activity.class).get();
final ShadowApplication application = ShadowApplication.getInstance();
final Preference preference = new Preference(application.getApplicationContext());
final Tile tile = new Tile();
tile.key = "key";
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
tile.metaData = new Bundle();
tile.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
ShadowActivity shadowActivity = shadowOf(activity);
final Intent launchIntent = shadowActivity.getNextStartedActivityForResult().intent;
assertThat(launchIntent.getAction()).isEqualTo("TestAction");
assertThat(launchIntent.getIntExtra(SettingsActivity.EXTRA_SOURCE_METRICS_CATEGORY, 0)).isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GESTURES);
}
use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by DirtyUnicorns.
the class FingerprintEnrollFindSensorTest method enrollFingerprintTwice_shouldStartOneEnrolling.
@Test
public void enrollFingerprintTwice_shouldStartOneEnrolling() {
EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
enrollmentCallback.onEnrollmentProgress(123);
// A second enroll should be a no-op
enrollmentCallback.onEnrollmentProgress(123);
ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
assertThat(startedActivity).named("Next activity 1").isNotNull();
assertThat(startedActivity.intent.getComponent()).isEqualTo(new ComponentName(application, FingerprintEnrollEnrolling.class));
// Should only start one next activity
assertThat(shadowActivity.getNextStartedActivityForResult()).named("Next activity 2").isNull();
}
use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by DirtyUnicorns.
the class FingerprintSuggestionActivityTest method testKeyguardSecure_shouldFinishWithFingerprintResultSkip.
@Test
public void testKeyguardSecure_shouldFinishWithFingerprintResultSkip() {
getShadowKeyguardManager().setIsKeyguardSecure(true);
mController.create().resume();
final Button cancelButton = mController.get().findViewById(R.id.fingerprint_cancel_button);
assertThat(cancelButton.getText().toString()).isEqualTo("Cancel");
assertThat(cancelButton.getVisibility()).named("Cancel visible").isEqualTo(View.VISIBLE);
cancelButton.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(mController.get());
assertThat(mController.get().isFinishing()).named("Is finishing").isTrue();
assertThat(shadowActivity.getResultCode()).named("Result code").isEqualTo(Activity.RESULT_CANCELED);
}
use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by DirtyUnicorns.
the class SetupFingerprintEnrollIntroductionTest method testCancelClicked_shouldSetIntentDataIfLockScreenAdded.
@Test
public void testCancelClicked_shouldSetIntentDataIfLockScreenAdded() {
getShadowKeyguardManager().setIsKeyguardSecure(false);
SetupFingerprintEnrollIntroduction activity = mController.create().resume().get();
final Button skipButton = activity.findViewById(R.id.fingerprint_cancel_button);
getShadowKeyguardManager().setIsKeyguardSecure(true);
skipButton.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
assertThat(shadowActivity.getResultIntent()).isNotNull();
assertThat(shadowActivity.getResultIntent().hasExtra(SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isTrue();
}
use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by DirtyUnicorns.
the class SetupFingerprintEnrollIntroductionTest method testKeyguardSecure_shouldFinishWithFingerprintResultSkip.
@Test
public void testKeyguardSecure_shouldFinishWithFingerprintResultSkip() {
getShadowKeyguardManager().setIsKeyguardSecure(true);
mController.create().resume();
final Button skipButton = mController.get().findViewById(R.id.fingerprint_cancel_button);
assertThat(skipButton.getVisibility()).named("Skip visible").isEqualTo(View.VISIBLE);
skipButton.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(mController.get());
assertThat(mController.get().isFinishing()).named("Is finishing").isTrue();
assertThat(shadowActivity.getResultCode()).named("Result code").isEqualTo(FingerprintEnrollBase.RESULT_SKIP);
}
Aggregations