/** * Invoke this utility method in tests to reveal which Android api classes and methods are being invoked * for which there are no shadows or shadow methods. This helps expose which methods are being invoked * either by a third party library or application code which need new shadow methods to be written. Generates * output for the current test only. */ public static void logMissingInvokedShadowMethods() { ShadowWrangler.getInstance().logMissingInvokedShadowMethods(); }
private static RobolectricClassLoader getDefaultLoader() { if (defaultLoader == null) { defaultLoader = new RobolectricClassLoader(ShadowWrangler.getInstance()); } return defaultLoader; }
private static RobolectricClassLoader getDefaultLoader() { if (defaultLoader == null) { defaultLoader = new RobolectricClassLoader(ShadowWrangler.getInstance()); } return defaultLoader; }
@SuppressWarnings({"unchecked"}) public static <P, R> P shadowOf_(R instance) { return (P) ShadowWrangler.getInstance().shadowOf(instance); }
public static void bindShadowClass(Class<?> shadowClass) { Implements realClass = shadowClass.getAnnotation(Implements.class); if (realClass == null) { throw new IllegalArgumentException(shadowClass + " is not annotated with @Implements"); } try { ShadowWrangler.getInstance().bindShadowClass(realClass.value(), shadowClass); } catch (TypeNotPresentException typeLoadingException) { String unloadableClassName = shadowClass.getSimpleName(); if (isIgnorableClassLoadingException(typeLoadingException)) { //this allows users of the robolectric.jar file to use the non-Google APIs version of the api if (unloadableClassNames.add(unloadableClassName)) { System.out.println("Warning: an error occurred while binding shadow class: " + unloadableClassName); } } else { throw typeLoadingException; } } }
/** * Call this constructor in subclasses in order to specify non-default configuration (e.g. location of the * AndroidManifest.xml file, resource directory, and DatabaseMap). * * @param testClass the test class to be run * @param robolectricConfig the configuration data * @param databaseMap the database mapping * @throws InitializationError if junit says so */ protected RobolectricTestRunner(Class<?> testClass, RobolectricConfig robolectricConfig, DatabaseMap databaseMap) throws InitializationError { this(testClass, isInstrumented() ? null : ShadowWrangler.getInstance(), isInstrumented() ? null : getDefaultLoader(), robolectricConfig, databaseMap); }
/** * Call this constructor in subclasses in order to specify non-default configuration (e.g. location of the * AndroidManifest.xml file, resource directory, and DatabaseMap). * * @param testClass the test class to be run * @param robolectricConfig the configuration data * @param databaseMap the database mapping * @throws org.junit.runners.model.InitializationError * if junit says so */ protected RobolectricSimpleRunner(Class<?> testClass, RobolectricConfig robolectricConfig, DatabaseConfig.DatabaseMap databaseMap) throws InitializationError { this(testClass, isInstrumented() ? null : ShadowWrangler.getInstance(), isInstrumented() ? null : getDefaultLoader(), robolectricConfig, databaseMap); }
/** * Call this constructor in subclasses in order to specify non-default configuration (e.g. location of the * AndroidManifest.xml file and resource directory). * * @param testClass the test class to be run * @param robolectricConfig the configuration data * @throws InitializationError if junit says so */ protected RobolectricTestRunner(final Class<?> testClass, final RobolectricConfig robolectricConfig) throws InitializationError { this(testClass, isInstrumented() ? null : ShadowWrangler.getInstance(), isInstrumented() ? null : getDefaultLoader(), robolectricConfig, new SQLiteMap()); }
/** * Call this constructor in subclasses in order to specify non-default configuration (e.g. location of the * AndroidManifest.xml file and resource directory). * * @param testClass the test class to be run * @param robolectricConfig the configuration data * @throws org.junit.runners.model.InitializationError * if junit says so */ protected RobolectricSimpleRunner(final Class<?> testClass, final RobolectricConfig robolectricConfig) throws InitializationError { this(testClass, isInstrumented() ? null : ShadowWrangler.getInstance(), isInstrumented() ? null : getDefaultLoader(), robolectricConfig, new SQLiteMap()); }
public static void resetStaticState() { ShadowWrangler.getInstance().silence(); Robolectric.application = new Application(); ShadowBitmapFactory.reset(); ShadowDrawable.reset(); ShadowMediaStore.reset(); ShadowLog.reset(); ShadowContext.clearFilesAndCache(); ShadowLooper.resetThreadLoopers(); ShadowDialog.reset(); ShadowContentResolver.reset(); ShadowLocalBroadcastManager.reset(); ShadowMimeTypeMap.reset(); ShadowPowerManager.reset(); ShadowStatFs.reset(); }