| Index: base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java
|
| diff --git a/base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java b/base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java
|
| index cd202ccd61ff0b445543e5b66d95b86e7c7d1799..5d3f71b36508f3b1bbb64fb24dbebc2a38ddc7ed 100644
|
| --- a/base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java
|
| +++ b/base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java
|
| @@ -8,8 +8,6 @@ import android.content.Context;
|
| import android.net.ConnectivityManager;
|
| import android.net.NetworkInfo;
|
| import android.os.Build;
|
| -import android.os.Bundle;
|
| -import android.os.SystemClock;
|
| import android.test.AndroidTestRunner;
|
| import android.test.InstrumentationTestRunner;
|
| import android.text.TextUtils;
|
| @@ -17,17 +15,14 @@ import android.text.TextUtils;
|
| import junit.framework.TestCase;
|
| import junit.framework.TestResult;
|
|
|
| -import org.chromium.base.CommandLine;
|
| import org.chromium.base.Log;
|
| import org.chromium.base.SysUtils;
|
| -import org.chromium.base.test.util.CommandLineFlags;
|
| +import org.chromium.base.test.BaseTestResult.SkipCheck;
|
| import org.chromium.base.test.util.MinAndroidSdkLevel;
|
| import org.chromium.base.test.util.Restriction;
|
| import org.chromium.test.reporter.TestStatusListener;
|
|
|
| import java.lang.reflect.Method;
|
| -import java.util.ArrayList;
|
| -import java.util.List;
|
|
|
| // TODO(jbudorick): Add support for on-device handling of timeouts.
|
| /**
|
| @@ -36,84 +31,12 @@ import java.util.List;
|
| public class BaseInstrumentationTestRunner extends InstrumentationTestRunner {
|
| private static final String TAG = "cr.base.test";
|
|
|
| - private static final int SLEEP_INTERVAL = 50; // milliseconds
|
| - private static final int WAIT_DURATION = 5000; // milliseconds
|
| -
|
| - /**
|
| - * An interface for classes that check whether a test case should be skipped.
|
| - */
|
| - public interface SkipCheck {
|
| - /**
|
| - * Checks whether the given test case should be skipped.
|
| - *
|
| - * @param testCase The test case to check.
|
| - * @return Whether the test case should be skipped.
|
| - */
|
| - public boolean shouldSkip(TestCase testCase);
|
| - }
|
| -
|
| - /**
|
| - * A test result that can skip tests.
|
| - */
|
| - public class BaseTestResult extends TestResult {
|
| -
|
| - private final List<SkipCheck> mSkipChecks;
|
| -
|
| - /**
|
| - * Creates an instance of BaseTestResult.
|
| - */
|
| - public BaseTestResult() {
|
| - mSkipChecks = new ArrayList<SkipCheck>();
|
| - }
|
| -
|
| - /**
|
| - * Adds a check for whether a test should run.
|
| - *
|
| - * @param skipCheck The check to add.
|
| - */
|
| - public void addSkipCheck(SkipCheck skipCheck) {
|
| - mSkipChecks.add(skipCheck);
|
| - }
|
| -
|
| - private boolean shouldSkip(final TestCase test) {
|
| - for (SkipCheck s : mSkipChecks) {
|
| - if (s.shouldSkip(test)) return true;
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - @Override
|
| - protected void run(final TestCase test) {
|
| - if (shouldSkip(test)) {
|
| - startTest(test);
|
| -
|
| - Bundle skipResult = new Bundle();
|
| - skipResult.putString("class", test.getClass().getName());
|
| - skipResult.putString("test", test.getName());
|
| - skipResult.putBoolean("test_skipped", true);
|
| - sendStatus(0, skipResult);
|
| -
|
| - endTest(test);
|
| - } else {
|
| - try {
|
| - CommandLine.reset();
|
| - CommandLineFlags.setUp(
|
| - BaseInstrumentationTestRunner.this.getTargetContext(),
|
| - test.getClass().getMethod(test.getName()));
|
| - } catch (NoSuchMethodException e) {
|
| - Log.e(TAG, "Unable to set up CommandLineFlags", e);
|
| - }
|
| - super.run(test);
|
| - }
|
| - }
|
| - }
|
| -
|
| @Override
|
| protected AndroidTestRunner getAndroidTestRunner() {
|
| AndroidTestRunner runner = new AndroidTestRunner() {
|
| @Override
|
| protected TestResult createTestResult() {
|
| - BaseTestResult r = new BaseTestResult();
|
| + BaseTestResult r = new BaseTestResult(BaseInstrumentationTestRunner.this);
|
| addSkipChecks(r);
|
| return r;
|
| }
|
| @@ -205,29 +128,4 @@ public class BaseInstrumentationTestRunner extends InstrumentationTestRunner {
|
| return false;
|
| }
|
| }
|
| -
|
| - /**
|
| - * Gets the target context.
|
| - *
|
| - * On older versions of Android, getTargetContext() may initially return null, so we have to
|
| - * wait for it to become available.
|
| - *
|
| - * @return The target {@link android.content.Context} if available; null otherwise.
|
| - */
|
| - @Override
|
| - public Context getTargetContext() {
|
| - Context targetContext = super.getTargetContext();
|
| - try {
|
| - long startTime = SystemClock.uptimeMillis();
|
| - // TODO(jbudorick): Convert this to CriteriaHelper once that moves to base/.
|
| - while (targetContext == null
|
| - && SystemClock.uptimeMillis() - startTime < WAIT_DURATION) {
|
| - Thread.sleep(SLEEP_INTERVAL);
|
| - targetContext = super.getTargetContext();
|
| - }
|
| - } catch (InterruptedException e) {
|
| - Log.e(TAG, "Interrupted while attempting to initialize the command line.");
|
| - }
|
| - return targetContext;
|
| - }
|
| }
|
|
|