Use binary resource support in robolectric

The resources available to tests are now exactly the merged resources
located in the APK under test.

Bug: 74359828
Test: make -j56 RunSettingsRoboTests
Change-Id: I050db81a92decefea23314b5ec7a62f77ff4bb2b
This commit is contained in:
James Lemieux
2018-12-07 12:56:49 -08:00
committed by Fan Zhang
parent 1f5fab1480
commit f1dade40d2
1005 changed files with 3187 additions and 5478 deletions

View File

@@ -22,7 +22,7 @@ import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
import com.android.settings.slices.SlicesDatabaseHelper;
import java.lang.reflect.Field;
import org.robolectric.util.ReflectionHelpers;
public class DatabaseTestUtils {
@@ -36,41 +36,17 @@ public class DatabaseTestUtils {
SlicesDatabaseHelper helper = SlicesDatabaseHelper.getInstance(context);
helper.close();
Field instance;
Class clazz = SlicesDatabaseHelper.class;
try {
instance = clazz.getDeclaredField("sSingleton");
instance.setAccessible(true);
instance.set(null, null);
} catch (Exception e) {
throw new RuntimeException();
}
ReflectionHelpers.setStaticField(SlicesDatabaseHelper.class, "sSingleton", null);
}
private static void clearAnomalyDb(Context context) {
AnomalyDatabaseHelper helper = AnomalyDatabaseHelper.getInstance(context);
helper.close();
Field instance;
Class clazz = AnomalyDatabaseHelper.class;
try {
instance = clazz.getDeclaredField("sSingleton");
instance.setAccessible(true);
instance.set(null, null);
} catch (Exception e) {
throw new RuntimeException();
}
ReflectionHelpers.setStaticField(AnomalyDatabaseHelper.class, "sSingleton", null);
}
private static void clearAnomalyDbManager() {
Field instance;
Class clazz = BatteryDatabaseManager.class;
try {
instance = clazz.getDeclaredField("sSingleton");
instance.setAccessible(true);
instance.set(null, null);
} catch (Exception e) {
throw new RuntimeException();
}
ReflectionHelpers.setStaticField(BatteryDatabaseManager.class, "sSingleton", null);
}
}