use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ConfigMerger method cachedPackageConfig.
@Nullable
private Config cachedPackageConfig(String packageName) {
synchronized (packageConfigCache) {
Config config = packageConfigCache.get(packageName);
if (config == null && !packageConfigCache.containsKey(packageName)) {
config = buildPackageConfig(packageName);
packageConfigCache.put(packageName, config);
}
return config;
}
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ConfigMerger method getConfig.
/**
* Calculate the {@link Config} for the given test.
*
* @param testClass the class containing the test
* @param method the test method
* @param globalConfig global configuration values
* @return the effective configuration
* @since 3.2
*/
public Config getConfig(Class<?> testClass, Method method, Config globalConfig) {
Config config = Config.Builder.defaults().build();
config = override(config, globalConfig);
for (String packageName : reverse(packageHierarchyOf(testClass))) {
Config packageConfig = cachedPackageConfig(packageName);
config = override(config, packageConfig);
}
for (Class clazz : reverse(parentClassesFor(testClass))) {
Config classConfig = (Config) clazz.getAnnotation(Config.class);
config = override(config, classConfig);
}
Config methodConfig = method.getAnnotation(Config.class);
config = override(config, methodConfig);
return config;
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowStatFsTest method withApi18_shouldResetStateBetweenTests.
@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void withApi18_shouldResetStateBetweenTests() {
StatFs statsFs = new StatFs("/tmp");
assertThat(statsFs.getBlockCountLong()).isEqualTo(0);
assertThat(statsFs.getAvailableBlocksLong()).isEqualTo(0);
assertThat(statsFs.getBlockSizeLong()).isEqualTo(ShadowStatFs.BLOCK_SIZE);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowStatFsTest method withApi18_shouldRegisterStatsWithFile.
@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void withApi18_shouldRegisterStatsWithFile() {
ShadowStatFs.registerStats(new File("/tmp"), 100, 20, 10);
StatFs statsFs = new StatFs(new File("/tmp").getAbsolutePath());
assertThat(statsFs.getBlockCountLong()).isEqualTo(100);
assertThat(statsFs.getAvailableBlocksLong()).isEqualTo(10L);
assertThat(statsFs.getBlockSizeLong()).isEqualTo(ShadowStatFs.BLOCK_SIZE);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowSoundPoolTest method shouldCreateSoundPool_Lollipop.
@Test
@Config(minSdk = LOLLIPOP)
public void shouldCreateSoundPool_Lollipop() {
SoundPool soundPool = new SoundPool.Builder().build();
assertThat(soundPool).isNotNull();
SoundPool.OnLoadCompleteListener listener = mock(SoundPool.OnLoadCompleteListener.class);
soundPool.setOnLoadCompleteListener(listener);
}
Aggregations