CancelableOperation implements Cancelable, Runnable { @Override public final void run() { synchronized (this) { if (isDone() || isRunning) { return; } isRunning = true; handler.post(internalRunnable); } } CancelableOperation();  CancelableOperation(@Nullable Looper looper); @Override final boolean cancel(); @Override final boolean cancel(boolean mayInterruptIfRunning); @Override final void run(); @Override final boolean isDone(); @Override final boolean isCancelled(); @NonNull CancelableOperation addOnRun(@NonNull Runnable runnable); @NonNull CancelableOperation addOnCancel(@NonNull Cancelable cancelable); @NonNull Handler getHandler();  }
@Test public void testRun() { looper.pause(); operation.run(); assertFalse(operation.isDone()); assertFalse(operation.onRunCalled); looper.runToEndOfTasks(); assertTrue(operation.onRunCalled); assertTrue(operation.isDone()); assertFalse(operation.isCancelled()); }