FileDocCategorySizeDatePackage
IntentSenderTest.javaAPI DocAndroid 5.1 API3428Thu Mar 12 22:22:12 GMT 2015android.app.activity

IntentSenderTest

public class IntentSenderTest extends BroadcastTest

Fields Summary
Constructors Summary
Methods Summary
public voidtestLocalReceivePermissionDenied()

        final Intent intent = makeBroadcastIntent(BROADCAST_LOCAL_DENIED);

        setExpectedReceivers(new String[]{RECEIVER_RESULTS});

        PendingIntent.OnFinished finish = new PendingIntent.OnFinished() {
            public void onSendFinished(PendingIntent pi, Intent intent,
                    int resultCode, String resultData, Bundle resultExtras) {
                gotReceive(RECEIVER_RESULTS, intent);
            }
        };

        PendingIntent is = PendingIntent.getBroadcast(getContext(), 0, intent, 0);
        is.send(Activity.RESULT_CANCELED, finish, null);
        waitForResultOrThrow(BROADCAST_TIMEOUT);
        is.cancel();
    
public voidtestLocalReceivePermissionGranted()

        setExpectedReceivers(new String[]{RECEIVER_LOCAL});
        PendingIntent is = PendingIntent.getBroadcast(getContext(), 0,
                makeBroadcastIntent(BROADCAST_LOCAL_GRANTED), 0);
        is.send();
        waitForResultOrThrow(BROADCAST_TIMEOUT);
        is.cancel();
    
public voidtestRegisteredReceivePermissionDenied()

        final Intent intent = makeBroadcastIntent(BROADCAST_REGISTERED);

        setExpectedReceivers(new String[]{RECEIVER_RESULTS});
        registerMyReceiver(new IntentFilter(BROADCAST_REGISTERED), PERMISSION_DENIED);
        addIntermediate("after-register");

        PendingIntent.OnFinished finish = new PendingIntent.OnFinished() {
            public void onSendFinished(PendingIntent pi, Intent intent,
                    int resultCode, String resultData, Bundle resultExtras) {
                gotReceive(RECEIVER_RESULTS, intent);
            }
        };

        PendingIntent is = PendingIntent.getBroadcast(getContext(), 0, intent, 0);
        is.send(Activity.RESULT_CANCELED, finish, null);
        waitForResultOrThrow(BROADCAST_TIMEOUT);
        is.cancel();
    
public voidtestRegisteredReceivePermissionGranted()

        setExpectedReceivers(new String[]{RECEIVER_REG});
        registerMyReceiver(new IntentFilter(BROADCAST_REGISTERED), PERMISSION_GRANTED);
        addIntermediate("after-register");
        PendingIntent is = PendingIntent.getBroadcast(getContext(), 0,
                makeBroadcastIntent(BROADCAST_REGISTERED), 0);
        is.send();
        waitForResultOrThrow(BROADCAST_TIMEOUT);
        is.cancel();