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.

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

mercurial