Search in sources :

Example 41 with IntentForResult

use of org.robolectric.shadows.ShadowActivity.IntentForResult in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FingerprintEnrollFindSensorTest method layoutWithoutAnimation_shouldNotCrash.

// Use a non-default resource qualifier to load the test layout in
// robotests/res/layout-mcc999/fingerprint_enroll_find_sensor. This layout is a copy of the
// regular find sensor layout, with the animation removed.
@Config(qualifiers = "mcc999")
@Test
public void layoutWithoutAnimation_shouldNotCrash() {
    EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
    enrollmentCallback.onEnrollmentProgress(123);
    enrollmentCallback.onEnrollmentError(FingerprintManager.FINGERPRINT_ERROR_CANCELED, "test");
    ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
    assertThat(startedActivity).named("Next activity").isNotNull();
    assertThat(startedActivity.intent.getComponent()).isEqualTo(new ComponentName(application, FingerprintEnrollEnrolling.class));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) ComponentName(android.content.ComponentName) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) EnrollmentCallback(android.hardware.fingerprint.FingerprintManager.EnrollmentCallback) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 42 with IntentForResult

use of org.robolectric.shadows.ShadowActivity.IntentForResult in project robolectric by robolectric.

the class ShadowContextWrapperTest method startActivities_canGetNextStartedActivityForResult.

@Test
public void startActivities_canGetNextStartedActivityForResult() {
    final Intent view = new Intent(Intent.ACTION_VIEW).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    final Intent pick = new Intent(Intent.ACTION_PICK).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    contextWrapper.startActivities(new Intent[] { view, pick });
    IntentForResult second = shadowOf(RuntimeEnvironment.getApplication()).getNextStartedActivityForResult();
    IntentForResult first = shadowOf(RuntimeEnvironment.getApplication()).getNextStartedActivityForResult();
    assertThat(second.intent).isEqualTo(pick);
    assertThat(second.options).isNull();
    assertThat(first.intent).isEqualTo(view);
    assertThat(first.options).isNull();
}
Also used : Intent(android.content.Intent) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) Test(org.junit.Test)

Example 43 with IntentForResult

use of org.robolectric.shadows.ShadowActivity.IntentForResult in project robolectric by robolectric.

the class ShadowContextWrapperTest method startActivities_withBundle_canGetNextStartedActivityForResult.

@Test
public void startActivities_withBundle_canGetNextStartedActivityForResult() {
    final Intent view = new Intent(Intent.ACTION_VIEW).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    final Intent pick = new Intent(Intent.ACTION_PICK).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Bundle options = new Bundle();
    options.putString("foo", "bar");
    contextWrapper.startActivities(new Intent[] { view, pick }, options);
    IntentForResult second = shadowOf(RuntimeEnvironment.getApplication()).getNextStartedActivityForResult();
    IntentForResult first = shadowOf(RuntimeEnvironment.getApplication()).getNextStartedActivityForResult();
    assertThat(second.intent).isEqualTo(pick);
    assertThat(second.options).isEqualTo(options);
    assertThat(first.intent).isEqualTo(view);
    assertThat(first.options).isEqualTo(options);
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) Test(org.junit.Test)

Example 44 with IntentForResult

use of org.robolectric.shadows.ShadowActivity.IntentForResult in project robolectric by robolectric.

the class ShadowInstrumentation method logStartedActivity.

private void logStartedActivity(Intent intent, String target, int requestCode, Bundle options) {
    startedActivities.add(intent);
    intentRequestCodeMap.put(new FilterComparison(intent), new TargetAndRequestCode(target, requestCode));
    startedActivitiesForResults.add(new IntentForResult(intent, requestCode, options));
}
Also used : FilterComparison(android.content.Intent.FilterComparison) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult)

Aggregations

IntentForResult (org.robolectric.shadows.ShadowActivity.IntentForResult)44 Test (org.junit.Test)43 ShadowActivity (org.robolectric.shadows.ShadowActivity)41 ComponentName (android.content.ComponentName)21 EnrollmentCallback (android.hardware.fingerprint.FingerprintManager.EnrollmentCallback)21 Intent (android.content.Intent)15 Activity (android.app.Activity)7 Bundle (android.os.Bundle)7 Config (org.robolectric.annotation.Config)7 Button (android.widget.Button)6 TestConfig (com.android.settings.TestConfig)6 IntentBuilder (com.android.settings.password.ChooseLockPassword.IntentBuilder)6 SetupChooseLockPasswordFragment (com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment)6 FilterComparison (android.content.Intent.FilterComparison)1 PartnerCustomizationLayout (com.google.android.setupcompat.PartnerCustomizationLayout)1