in BoltsTest/src/bolts/TaskTest.java [163:178]
public void testBackgroundCallWaitOnCancellation() throws Exception {
Task<Integer> task = Task.callInBackground(new Callable<Integer>() {
public Integer call() throws Exception {
Thread.sleep(100);
return 5;
}
}).continueWithTask(new Continuation<Integer, Task<Integer>>() {
public Task<Integer> then(Task<Integer> task) {
return Task.cancelled();
}
});
task.waitForCompletion();
assertTrue(task.isCompleted());
assertTrue(task.isCancelled());
}