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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 package org.mozilla.gecko.background.sync.helpers;
     6 import java.util.concurrent.ExecutorService;
     8 import junit.framework.AssertionFailedError;
    10 import org.mozilla.gecko.background.testhelpers.WaitHelper;
    12 public abstract class DefaultDelegate {
    13   protected ExecutorService executor;
    15   protected final WaitHelper waitHelper;
    17   public DefaultDelegate() {
    18     waitHelper = WaitHelper.getTestWaiter();
    19   }
    21   public DefaultDelegate(WaitHelper waitHelper) {
    22     this.waitHelper = waitHelper;
    23   }
    25   protected WaitHelper getTestWaiter() {
    26     return waitHelper;
    27   }
    29   public void performWait(Runnable runnable) throws AssertionFailedError {
    30     getTestWaiter().performWait(runnable);
    31   }
    33   public void performNotify() {
    34     getTestWaiter().performNotify();
    35   }
    37   public void performNotify(Throwable e) {
    38     getTestWaiter().performNotify(e);
    39   }
    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