diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-02-14 16:02:05 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-02-14 16:04:37 -0800 |
commit | dd86cb7caf224de0df9c5fff7439677972424fec (patch) | |
tree | e1bec5dbf6f11296456d56414d658d4247a2e67e /core | |
parent | 07aef1c78a92e70552f269b37615c19aea042410 (diff) | |
download | frameworks_base-dd86cb7caf224de0df9c5fff7439677972424fec.zip frameworks_base-dd86cb7caf224de0df9c5fff7439677972424fec.tar.gz frameworks_base-dd86cb7caf224de0df9c5fff7439677972424fec.tar.bz2 |
Update scrubClass() to match CoreTestRunner.
AndroidTestCase.scrubClass() is quite aggressive, and would end up
clearing out final fields like these:
private static final byte[] TEST_DATA = new byte[1];
This change updates the logic to match InstrumentationCoreTestRunner
in the cleanup() method.
Change-Id: Iba455ea35b2628473ce0ccc1431ab47c1caad45c
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/test/AndroidTestCase.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/java/android/test/AndroidTestCase.java b/core/java/android/test/AndroidTestCase.java index 0c8cbe6..0635559 100644 --- a/core/java/android/test/AndroidTestCase.java +++ b/core/java/android/test/AndroidTestCase.java @@ -20,9 +20,11 @@ import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.net.Uri; + import junit.framework.TestCase; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; /** * Extend this if you need to access Resources or other things that depend on Activity Context. @@ -152,11 +154,11 @@ public class AndroidTestCase extends TestCase { * @throws IllegalAccessException */ protected void scrubClass(final Class<?> testCaseClass) - throws IllegalAccessException { + throws IllegalAccessException { final Field[] fields = getClass().getDeclaredFields(); for (Field field : fields) { - final Class<?> fieldClass = field.getDeclaringClass(); - if (testCaseClass.isAssignableFrom(fieldClass) && !field.getType().isPrimitive()) { + if (!field.getType().isPrimitive() && + !Modifier.isStatic(field.getModifiers())) { try { field.setAccessible(true); field.set(this, null); @@ -170,6 +172,4 @@ public class AndroidTestCase extends TestCase { } } } - - } |