summaryrefslogtreecommitdiffstats
path: root/test-runner/src
diff options
context:
space:
mode:
Diffstat (limited to 'test-runner/src')
-rw-r--r--test-runner/src/android/test/ActivityTestCase.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/test-runner/src/android/test/ActivityTestCase.java b/test-runner/src/android/test/ActivityTestCase.java
index 18bfccc..c7b1d70 100644
--- a/test-runner/src/android/test/ActivityTestCase.java
+++ b/test-runner/src/android/test/ActivityTestCase.java
@@ -19,10 +19,11 @@ package android.test;
import android.app.Activity;
import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
/**
* This is common code used to support Activity test cases. For more useful classes, please see
- * {@link android.test.ActivityUnitTestCase} and
+ * {@link android.test.ActivityUnitTestCase} and
* {@link android.test.ActivityInstrumentationTestCase}.
*/
public abstract class ActivityTestCase extends InstrumentationTestCase {
@@ -38,7 +39,7 @@ public abstract class ActivityTestCase extends InstrumentationTestCase {
protected Activity getActivity() {
return mActivity;
}
-
+
/**
* Set the activity under test.
* @param testActivity The activity under test
@@ -46,15 +47,15 @@ public abstract class ActivityTestCase extends InstrumentationTestCase {
protected void setActivity(Activity testActivity) {
mActivity = testActivity;
}
-
+
/**
* This function is called by various TestCase implementations, at tearDown() time, in order
* to scrub out any class variables. This protects against memory leaks in the case where a
* test case creates a non-static inner class (thus referencing the test case) and gives it to
* someone else to hold onto.
- *
+ *
* @param testCaseClass The class of the derived TestCase implementation.
- *
+ *
* @throws IllegalAccessException
*/
protected void scrubClass(final Class<?> testCaseClass)
@@ -62,7 +63,8 @@ public abstract class ActivityTestCase extends InstrumentationTestCase {
final Field[] fields = getClass().getDeclaredFields();
for (Field field : fields) {
final Class<?> fieldClass = field.getDeclaringClass();
- if (testCaseClass.isAssignableFrom(fieldClass) && !field.getType().isPrimitive()) {
+ if (testCaseClass.isAssignableFrom(fieldClass) && !field.getType().isPrimitive()
+ && (field.getModifiers() & Modifier.FINAL) == 0) {
try {
field.setAccessible(true);
field.set(this, null);
@@ -77,6 +79,6 @@ public abstract class ActivityTestCase extends InstrumentationTestCase {
}
}
-
+
}