@Test
  public void testSchedule_sendsAppropriateBroadcast() {
    ArgumentCaptor<Intent> pmQueryIntentCaptor = mockPackageManagerInfo();

    Job job =
        dispatcher
            .newJobBuilder()
            .setConstraints(Constraint.DEVICE_CHARGING)
            .setService(TestJobService.class)
            .setTrigger(Trigger.executionWindow(0, 60))
            .setRecurring(false)
            .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
            .setTag("foobar")
            .build();

    Intent pmQueryIntent = pmQueryIntentCaptor.getValue();
    assertEquals(JobService.ACTION_EXECUTE, pmQueryIntent.getAction());
    assertEquals(TestJobService.class.getName(), pmQueryIntent.getComponent().getClassName());

    assertEquals(
        "Expected schedule() request to succeed",
        FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS,
        dispatcher.schedule(job));

    final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
    verify(mMockContext).sendBroadcast(captor.capture());

    Intent broadcast = captor.getValue();

    assertNotNull(broadcast);
    assertEquals("com.google.android.gms.gcm.ACTION_SCHEDULE", broadcast.getAction());
    assertEquals("SCHEDULE_TASK", broadcast.getStringExtra("scheduler_action"));
    assertEquals("com.google.android.gms", broadcast.getPackage());
    assertEquals(8, broadcast.getIntExtra("source", -1));
    assertEquals(1, broadcast.getIntExtra("source_version", -1));

    final Parcelable parcelablePendingIntent = broadcast.getParcelableExtra("app");
    assertTrue(
        "Expected 'app' value to be a PendingIntent",
        parcelablePendingIntent instanceof PendingIntent);
  }
Tests for the {@link GooglePlayDriver} class.
jobdispatcher/src/test/java/com/firebase/jobdispatcher/GooglePlayDriverTest.java