Search in sources :

Example 51 with Config

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;
    }
}
Also used : Config(org.robolectric.annotation.Config) Nullable(org.jetbrains.annotations.Nullable)

Example 52 with 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;
}
Also used : Config(org.robolectric.annotation.Config)

Example 53 with 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);
}
Also used : StatFs(android.os.StatFs) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 54 with Config

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);
}
Also used : StatFs(android.os.StatFs) File(java.io.File) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 55 with Config

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);
}
Also used : SoundPool(android.media.SoundPool) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

Config (org.robolectric.annotation.Config)158 Test (org.junit.Test)153 Intent (android.content.Intent)21 ComponentName (android.content.ComponentName)16 Bundle (android.os.Bundle)10 Activity (android.app.Activity)7 Bitmap (android.graphics.Bitmap)7 Notification (android.app.Notification)6 Button (android.widget.Button)6 TextView (android.widget.TextView)6 BuildConfig (com.firebase.ui.auth.BuildConfig)6 BuildConfig (com.onesignal.BuildConfig)6 ShadowRecyclerView (io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView)6 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)6 Properties (java.util.Properties)6 Account (android.accounts.Account)5 Network (android.net.Network)5 NetworkInfo (android.net.NetworkInfo)5 RecyclerView (android.support.v7.widget.RecyclerView)5 BitmapDrawable (android.graphics.drawable.BitmapDrawable)4