Search in sources :

Example 1 with IntentSenderRequest

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

the class ShadowActivityTest method getLastIntentSenderRequest.

@Test
public void getLastIntentSenderRequest() throws IntentSender.SendIntentException {
    Activity activity = Robolectric.setupActivity(Activity.class);
    int requestCode = 108;
    Intent intent = new Intent("action");
    Intent fillInIntent = new Intent();
    PendingIntent pendingIntent = PendingIntent.getActivity(systemContext, requestCode, intent, 0);
    Bundle options = new Bundle();
    int flagsMask = 1;
    int flagsValues = 2;
    int extraFlags = 3;
    IntentSender intentSender = pendingIntent.getIntentSender();
    activity.startIntentSenderForResult(intentSender, requestCode, fillInIntent, flagsMask, flagsValues, extraFlags, options);
    IntentSenderRequest lastIntentSenderRequest = shadowOf(activity).getLastIntentSenderRequest();
    assertThat(lastIntentSenderRequest.intentSender).isEqualTo(intentSender);
    assertThat(lastIntentSenderRequest.fillInIntent).isEqualTo(fillInIntent);
    assertThat(lastIntentSenderRequest.requestCode).isEqualTo(requestCode);
    assertThat(lastIntentSenderRequest.flagsMask).isEqualTo(flagsMask);
    assertThat(lastIntentSenderRequest.flagsValues).isEqualTo(flagsValues);
    assertThat(lastIntentSenderRequest.extraFlags).isEqualTo(extraFlags);
    assertThat(lastIntentSenderRequest.options).isEqualTo(options);
}
Also used : Bundle(android.os.Bundle) Robolectric.setupActivity(org.robolectric.Robolectric.setupActivity) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) IntentSenderRequest(org.robolectric.shadows.ShadowActivity.IntentSenderRequest) PendingIntent(android.app.PendingIntent) IntentSender(android.content.IntentSender) Test(org.junit.Test)

Aggregations

Activity (android.app.Activity)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 IntentSender (android.content.IntentSender)1 Bundle (android.os.Bundle)1 Test (org.junit.Test)1 Robolectric.buildActivity (org.robolectric.Robolectric.buildActivity)1 Robolectric.setupActivity (org.robolectric.Robolectric.setupActivity)1 IntentSenderRequest (org.robolectric.shadows.ShadowActivity.IntentSenderRequest)1