mobile/android/tests/background/junit3/src/sync/helpers/DefaultDelegate.java

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:03725e5eba94
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 package org.mozilla.gecko.background.sync.helpers;
5
6 import java.util.concurrent.ExecutorService;
7
8 import junit.framework.AssertionFailedError;
9
10 import org.mozilla.gecko.background.testhelpers.WaitHelper;
11
12 public abstract class DefaultDelegate {
13 protected ExecutorService executor;
14
15 protected final WaitHelper waitHelper;
16
17 public DefaultDelegate() {
18 waitHelper = WaitHelper.getTestWaiter();
19 }
20
21 public DefaultDelegate(WaitHelper waitHelper) {
22 this.waitHelper = waitHelper;
23 }
24
25 protected WaitHelper getTestWaiter() {
26 return waitHelper;
27 }
28
29 public void performWait(Runnable runnable) throws AssertionFailedError {
30 getTestWaiter().performWait(runnable);
31 }
32
33 public void performNotify() {
34 getTestWaiter().performNotify();
35 }
36
37 public void performNotify(Throwable e) {
38 getTestWaiter().performNotify(e);
39 }
40
41 public void performNotify(String reason, Throwable e) {
42 String message = reason;
43 if (e != null) {
44 message += ": " + e.getMessage();
45 }
46 AssertionFailedError ex = new AssertionFailedError(message);
47 if (e != null) {
48 ex.initCause(e);
49 }
50 getTestWaiter().performNotify(ex);
51 }
52 }

mercurial