Search in sources :

Example 1 with ConfigurationImpl

use of org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl in project robolectric by robolectric.

the class RobolectricTestRunner method getConfiguration.

/**
 * Calculate the configuration for a given test method.
 */
private Configuration getConfiguration(Method method) {
    Configuration configuration = configurationStrategy.getConfig(getTestClass().getJavaClass(), method);
    // in case #getConfig(Method) has been overridden...
    try {
        Config config = getConfig(method);
        ((ConfigurationImpl) configuration).put(Config.class, config);
    } catch (UnsupportedOperationException e) {
    // no problem
    }
    return configuration;
}
Also used : Configuration(org.robolectric.pluginapi.config.ConfigurationStrategy.Configuration) InstrumentationConfiguration(org.robolectric.internal.bytecode.InstrumentationConfiguration) Config(org.robolectric.annotation.Config) ConfigurationImpl(org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl)

Example 2 with ConfigurationImpl

use of org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl in project robolectric by robolectric.

the class DefaultSdkPickerTest method buildConfig.

private Configuration buildConfig(Config.Builder builder) {
    ConfigurationImpl testConfig = new ConfigurationImpl();
    testConfig.put(Config.class, builder.build());
    return testConfig;
}
Also used : ConfigurationImpl(org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl)

Example 3 with ConfigurationImpl

use of org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl in project robolectric by robolectric.

the class AndroidTestEnvironmentTest method setUpApplicationState_setsVersionQualifierFromSdkWithOtherQualifiers.

@Test
public void setUpApplicationState_setsVersionQualifierFromSdkWithOtherQualifiers() {
    String givenQualifiers = "large-land";
    ConfigurationImpl config = new ConfigurationImpl();
    config.put(Config.class, new Config.Builder().setQualifiers(givenQualifiers).build());
    config.put(LooperMode.Mode.class, LEGACY);
    bootstrapWrapper.changeConfig(config);
    bootstrapWrapper.callSetUpApplicationState();
    String optsForO = RuntimeEnvironment.getApiLevel() >= O ? "nowidecg-lowdr-" : "";
    assertThat(RuntimeEnvironment.getQualifiers()).contains("large-notlong-notround-" + optsForO + "land-notnight-mdpi-finger-keyssoft" + "-nokeys-navhidden-nonav-v" + Build.VERSION.RESOURCES_SDK_INT);
}
Also used : Config(org.robolectric.annotation.Config) DeviceConfig(org.robolectric.android.DeviceConfig) ConfigurationImpl(org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl) LooperMode(org.robolectric.annotation.LooperMode) Test(org.junit.Test)

Example 4 with ConfigurationImpl

use of org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl in project robolectric by robolectric.

the class AndroidTestEnvironmentTest method setUpApplicationState_setsVersionQualifierFromSdk.

@Test
public void setUpApplicationState_setsVersionQualifierFromSdk() {
    String givenQualifiers = "";
    ConfigurationImpl config = new ConfigurationImpl();
    config.put(Config.class, new Config.Builder().setQualifiers(givenQualifiers).build());
    config.put(LooperMode.Mode.class, LEGACY);
    bootstrapWrapper.changeConfig(config);
    bootstrapWrapper.callSetUpApplicationState();
    assertThat(RuntimeEnvironment.getQualifiers()).contains("v" + Build.VERSION.RESOURCES_SDK_INT);
}
Also used : Config(org.robolectric.annotation.Config) DeviceConfig(org.robolectric.android.DeviceConfig) ConfigurationImpl(org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl) LooperMode(org.robolectric.annotation.LooperMode) Test(org.junit.Test)

Aggregations

ConfigurationImpl (org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl)4 Config (org.robolectric.annotation.Config)3 Test (org.junit.Test)2 DeviceConfig (org.robolectric.android.DeviceConfig)2 LooperMode (org.robolectric.annotation.LooperMode)2 InstrumentationConfiguration (org.robolectric.internal.bytecode.InstrumentationConfiguration)1 Configuration (org.robolectric.pluginapi.config.ConfigurationStrategy.Configuration)1