MCPcopy Index your code
hub / github.com/BoltsFramework/Bolts-Java / testAsyncChaining

Method testAsyncChaining

BoltsTest/src/bolts/TaskTest.java:355–385  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

353 }
354
355 public void testAsyncChaining() {
356 runTaskTest(new Callable<Task<?>>() {
357 public Task<?> call() throws Exception {
358 final ArrayList<Integer> sequence = new ArrayList<Integer>();
359 Task<Void> result = Task.forResult(null);
360 for (int i = 0; i < 20; i++) {
361 final int taskNumber = i;
362 result = result.continueWithTask(new Continuation<Void, Task<Void>>() {
363 public Task<Void> then(Task<Void> task) {
364 return Task.callInBackground(new Callable<Void>() {
365 public Void call() throws Exception {
366 sequence.add(taskNumber);
367 return null;
368 }
369 });
370 }
371 });
372 }
373 result = result.continueWith(new Continuation<Void, Void>() {
374 public Void then(Task<Void> task) {
375 assertEquals(20, sequence.size());
376 for (int i = 0; i < 20; i++) {
377 assertEquals(i, sequence.get(i).intValue());
378 }
379 return null;
380 }
381 });
382 return result;
383 }
384 });
385 }
386
387 public void testOnSuccess() {
388 Continuation<Integer, Integer> continuation = new Continuation<Integer, Integer>() {

Callers

nothing calls this directly

Calls 1

runTaskTestMethod · 0.95

Tested by

no test coverage detected