mobile/android/tests/background/junit3/src/helpers/AndroidSyncTestCase.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 package org.mozilla.gecko.background.helpers;
     6 import junit.framework.AssertionFailedError;
     8 import org.mozilla.gecko.background.testhelpers.WaitHelper;
    10 import android.app.Activity;
    11 import android.content.Context;
    12 import android.test.ActivityInstrumentationTestCase2;
    14 /**
    15  * AndroidSyncTestCase provides helper methods for testing.
    16  */
    17 public class AndroidSyncTestCase extends ActivityInstrumentationTestCase2<Activity> {
    18   protected static String LOG_TAG = "AndroidSyncTestCase";
    20   public AndroidSyncTestCase() {
    21     super(Activity.class);
    22     WaitHelper.resetTestWaiter();
    23   }
    25   public Context getApplicationContext() {
    26     return this.getInstrumentation().getTargetContext().getApplicationContext();
    27   }
    29   public static void performWait(Runnable runnable) {
    30     try {
    31       WaitHelper.getTestWaiter().performWait(runnable);
    32     } catch (WaitHelper.InnerError e) {
    33       AssertionFailedError inner = new AssertionFailedError("Caught error in performWait");
    34       inner.initCause(e.innerError);
    35       throw inner;
    36     }
    37   }
    39   public static void performNotify() {
    40     WaitHelper.getTestWaiter().performNotify();
    41   }
    43   public static void performNotify(Throwable e) {
    44     WaitHelper.getTestWaiter().performNotify(e);
    45   }
    47   public static void performNotify(String reason, Throwable e) {
    48     AssertionFailedError er = new AssertionFailedError(reason + ": " + e.getMessage());
    49     er.initCause(e);
    50     WaitHelper.getTestWaiter().performNotify(er);
    51   }
    52 }

mercurial