@Test public void testDoesntFinishIfStopped() throws InterruptedException { JobService.Binder binder = (JobService.Binder) Robolectric.buildService(NoopAsyncJobService.class).create().get().onBind(null); final CountDownLatch doneSignal = new CountDownLatch(1); final CountDownLatch continueSignal = new CountDownLatch(1); assertTrue(binder.startJob(params, new JobService.Binder.Callback() { @Override public void jobFinished(JobParameters params, boolean needsReschedule) { try { continueSignal.await(TIMEOUT_MS, TimeUnit.MILLISECONDS); doneSignal.countDown(); } catch (InterruptedException e) { } } })); binder.stopJob(params); continueSignal.countDown(); assertFalse(doneSignal.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); }
@NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; }
JobService extends Service { @NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; } }
JobService extends Service { @NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; }  }
JobService extends Service { @NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; }  @NonNull @Override final IBinder onBind(Intent intent); abstract boolean onStartJob(JobParameters params); abstract boolean onStopJob(JobParameters params); final void jobFinished(JobParameters params, boolean needsReschedule); }
JobService extends Service { @NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; }  @NonNull @Override final IBinder onBind(Intent intent); abstract boolean onStartJob(JobParameters params); abstract boolean onStopJob(JobParameters params); final void jobFinished(JobParameters params, boolean needsReschedule);  }