| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.base.test; | 5 package org.chromium.base.test; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.net.ConnectivityManager; | 8 import android.net.ConnectivityManager; |
| 9 import android.net.NetworkInfo; | 9 import android.net.NetworkInfo; |
| 10 import android.os.Build; | 10 import android.os.Build; |
| 11 import android.os.Bundle; |
| 11 import android.test.AndroidTestRunner; | 12 import android.test.AndroidTestRunner; |
| 12 import android.test.InstrumentationTestRunner; | 13 import android.test.InstrumentationTestRunner; |
| 13 import android.text.TextUtils; | 14 import android.text.TextUtils; |
| 14 | 15 |
| 15 import junit.framework.TestCase; | 16 import junit.framework.TestCase; |
| 16 import junit.framework.TestResult; | 17 import junit.framework.TestResult; |
| 17 | 18 |
| 18 import org.chromium.base.Log; | 19 import org.chromium.base.Log; |
| 19 import org.chromium.base.SysUtils; | 20 import org.chromium.base.SysUtils; |
| 21 import org.chromium.base.multidex.ChromiumMultiDex; |
| 20 import org.chromium.base.test.BaseTestResult.SkipCheck; | 22 import org.chromium.base.test.BaseTestResult.SkipCheck; |
| 21 import org.chromium.base.test.util.MinAndroidSdkLevel; | 23 import org.chromium.base.test.util.MinAndroidSdkLevel; |
| 22 import org.chromium.base.test.util.Restriction; | 24 import org.chromium.base.test.util.Restriction; |
| 23 import org.chromium.test.reporter.TestStatusListener; | 25 import org.chromium.test.reporter.TestStatusListener; |
| 24 | 26 |
| 25 import java.lang.reflect.Method; | 27 import java.lang.reflect.Method; |
| 26 | 28 |
| 27 // TODO(jbudorick): Add support for on-device handling of timeouts. | 29 // TODO(jbudorick): Add support for on-device handling of timeouts. |
| 28 /** | 30 /** |
| 29 * An Instrumentation test runner that checks SDK level for tests with specific
requirements. | 31 * An Instrumentation test runner that checks SDK level for tests with specific
requirements. |
| 30 */ | 32 */ |
| 31 public class BaseInstrumentationTestRunner extends InstrumentationTestRunner { | 33 public class BaseInstrumentationTestRunner extends InstrumentationTestRunner { |
| 32 private static final String TAG = "cr.base.test"; | 34 private static final String TAG = "cr.base.test"; |
| 33 | 35 |
| 34 @Override | 36 @Override |
| 37 public void onCreate(Bundle arguments) { |
| 38 ChromiumMultiDex.install(getTargetContext()); |
| 39 super.onCreate(arguments); |
| 40 } |
| 41 |
| 42 @Override |
| 35 protected AndroidTestRunner getAndroidTestRunner() { | 43 protected AndroidTestRunner getAndroidTestRunner() { |
| 36 AndroidTestRunner runner = new AndroidTestRunner() { | 44 AndroidTestRunner runner = new AndroidTestRunner() { |
| 37 @Override | 45 @Override |
| 38 protected TestResult createTestResult() { | 46 protected TestResult createTestResult() { |
| 39 BaseTestResult r = new BaseTestResult(BaseInstrumentationTestRun
ner.this); | 47 BaseTestResult r = new BaseTestResult(BaseInstrumentationTestRun
ner.this); |
| 40 addSkipChecks(r); | 48 addSkipChecks(r); |
| 41 return r; | 49 return r; |
| 42 } | 50 } |
| 43 }; | 51 }; |
| 44 runner.addTestListener(new TestStatusListener(getContext())); | 52 runner.addTestListener(new TestStatusListener(getContext())); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 Log.i(TAG, "Test " + testClass.getName() + "#" + testCase.ge
tName() | 130 Log.i(TAG, "Test " + testClass.getName() + "#" + testCase.ge
tName() |
| 123 + " is not enabled at SDK level " + Build.VERSION.SD
K_INT | 131 + " is not enabled at SDK level " + Build.VERSION.SD
K_INT |
| 124 + "."); | 132 + "."); |
| 125 return true; | 133 return true; |
| 126 } | 134 } |
| 127 } | 135 } |
| 128 return false; | 136 return false; |
| 129 } | 137 } |
| 130 } | 138 } |
| 131 } | 139 } |
| OLD | NEW |