summaryrefslogtreecommitdiffstats
path: root/test-runner
diff options
context:
space:
mode:
authorDmitri Plotnikov <dplotnikov@google.com>2009-08-03 14:27:20 -0700
committerDmitri Plotnikov <dplotnikov@google.com>2009-08-03 14:27:20 -0700
commit44a29dd097350e3050e44a2f64aa4c75d26ec695 (patch)
treeede70810414746e53136a938e7c3395f571f089a /test-runner
parentf6d1a5528ee626487c78f17501d61e61bbe26b10 (diff)
downloadframeworks_base-44a29dd097350e3050e44a2f64aa4c75d26ec695.zip
frameworks_base-44a29dd097350e3050e44a2f64aa4c75d26ec695.tar.gz
frameworks_base-44a29dd097350e3050e44a2f64aa4c75d26ec695.tar.bz2
Adding "test context" to AndroidTestCase
Diffstat (limited to 'test-runner')
-rw-r--r--test-runner/android/test/AndroidTestRunner.java6
-rw-r--r--test-runner/android/test/TestRunner.java8
2 files changed, 9 insertions, 5 deletions
diff --git a/test-runner/android/test/AndroidTestRunner.java b/test-runner/android/test/AndroidTestRunner.java
index 79cedb0..00440b4 100644
--- a/test-runner/android/test/AndroidTestRunner.java
+++ b/test-runner/android/test/AndroidTestRunner.java
@@ -158,16 +158,18 @@ public class AndroidTestRunner extends BaseTestRunner {
mTestResult.addListener(testListener);
}
+ Context testContext = mInstrumentation.getContext();
for (TestCase testCase : mTestCases) {
- setContextIfAndroidTestCase(testCase, mContext);
+ setContextIfAndroidTestCase(testCase, mContext, testContext);
setInstrumentationIfInstrumentationTestCase(testCase, mInstrumentation);
testCase.run(mTestResult);
}
}
- private void setContextIfAndroidTestCase(Test test, Context context) {
+ private void setContextIfAndroidTestCase(Test test, Context context, Context testContext) {
if (AndroidTestCase.class.isAssignableFrom(test.getClass())) {
((AndroidTestCase) test).setContext(context);
+ ((AndroidTestCase) test).setTestContext(testContext);
}
}
diff --git a/test-runner/android/test/TestRunner.java b/test-runner/android/test/TestRunner.java
index efa2480..012df35 100644
--- a/test-runner/android/test/TestRunner.java
+++ b/test-runner/android/test/TestRunner.java
@@ -39,7 +39,7 @@ import com.google.android.collect.Lists;
* and you probably will not need to instantiate, extend, or call this
* class yourself. See the full {@link android.test} package description
* to learn more about testing Android applications.
- *
+ *
* {@hide} Not needed for 1.0 SDK.
*/
public class TestRunner implements PerformanceTestCase.Intermediates {
@@ -84,6 +84,7 @@ public class TestRunner implements PerformanceTestCase.Intermediates {
super();
}
+ @Override
public void run(TestResult result) {
result.addListener(this);
super.run(result);
@@ -301,7 +302,7 @@ public class TestRunner implements PerformanceTestCase.Intermediates {
if (mMode == PERFORMANCE) {
runInPerformanceMode(test, className, false, className);
} else if (mMode == PROFILING) {
- //Need a way to mark a test to be run in profiling mode or not.
+ //Need a way to mark a test to be run in profiling mode or not.
startProfiling();
test.run();
finishProfiling();
@@ -337,6 +338,7 @@ public class TestRunner implements PerformanceTestCase.Intermediates {
AndroidTestCase testcase = (AndroidTestCase) test;
try {
testcase.setContext(mContext);
+ testcase.setTestContext(mContext);
} catch (Exception ex) {
Log.i("TestHarness", ex.toString());
}
@@ -700,7 +702,7 @@ public class TestRunner implements PerformanceTestCase.Intermediates {
}
} catch (ClassNotFoundException e) {
return 1; // this gets the count right, because either this test
- // is missing, and it will fail when run or it is a single Junit test to be run.
+ // is missing, and it will fail when run or it is a single Junit test to be run.
}
return 0;
}