Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd86cb7c authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

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
parent 07aef1c7
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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.
@@ -155,8 +157,8 @@ public class AndroidTestCase extends TestCase {
            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 {
            }
        }
    }


}