Search in sources :

Example 6 with Wrapper

use of org.robolectric.shadows.ShadowApplication.Wrapper in project robolectric by robolectric.

the class ShadowInstrumentation method sendOrderedBroadcastAsUser.

void sendOrderedBroadcastAsUser(Intent intent, UserHandle userHandle, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras, Context context) {
    List<Wrapper> receivers = getAppropriateWrappers(context, userHandle, intent, receiverPermission, /* broadcastOptions= */
    null);
    sortByPriority(receivers);
    if (resultReceiver != null) {
        receivers.add(new Wrapper(resultReceiver, null, context, null, scheduler));
    }
    postOrderedToWrappers(receivers, intent, initialCode, initialData, initialExtras, context);
}
Also used : Wrapper(org.robolectric.shadows.ShadowApplication.Wrapper) ContextWrapper(android.content.ContextWrapper)

Example 7 with Wrapper

use of org.robolectric.shadows.ShadowApplication.Wrapper in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TetherServiceTest method scheduleAlarm_shouldRegisterReceiver.

@Test
public void scheduleAlarm_shouldRegisterReceiver() {
    mService.setHotspotOffReceiver(new HotspotOffReceiver(mAppContext));
    mService.scheduleAlarm();
    boolean found = false;
    for (Wrapper wrapper : ShadowApplication.getInstance().getRegisteredReceivers()) {
        if (wrapper.intentFilter.matchAction(WifiManager.WIFI_AP_STATE_CHANGED_ACTION)) {
            found = true;
            break;
        }
    }
    assertThat(found).isTrue();
}
Also used : Wrapper(org.robolectric.shadows.ShadowApplication.Wrapper) Test(org.junit.Test)

Aggregations

Wrapper (org.robolectric.shadows.ShadowApplication.Wrapper)7 ContextWrapper (android.content.ContextWrapper)6 Intent (android.content.Intent)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Test (org.junit.Test)1