Search in sources :

Example 1 with Mode

use of org.robolectric.annotation.LooperMode.Mode in project robolectric by robolectric.

the class RobolectricTestRunner method getSandbox.

@Override
@Nonnull
protected AndroidSandbox getSandbox(FrameworkMethod method) {
    RobolectricFrameworkMethod roboMethod = (RobolectricFrameworkMethod) method;
    Sdk sdk = roboMethod.getSdk();
    InstrumentationConfiguration classLoaderConfig = createClassLoaderConfig(method);
    ResourcesMode resourcesMode = roboMethod.getResourcesMode();
    if (resourcesMode == ResourcesMode.LEGACY && sdk.getApiLevel() > Build.VERSION_CODES.P) {
        throw new AssumptionViolatedException("Robolectric doesn't support legacy mode after P");
    }
    LooperMode.Mode looperMode = roboMethod.configuration == null ? Mode.LEGACY : roboMethod.configuration.get(LooperMode.Mode.class);
    sdk.verifySupportedSdk(method.getDeclaringClass().getName());
    return sandboxManager.getAndroidSandbox(classLoaderConfig, sdk, resourcesMode, looperMode);
}
Also used : ResourcesMode(org.robolectric.internal.ResourcesMode) InstrumentationConfiguration(org.robolectric.internal.bytecode.InstrumentationConfiguration) AssumptionViolatedException(org.junit.AssumptionViolatedException) Mode(org.robolectric.annotation.LooperMode.Mode) SQLiteMode(org.robolectric.annotation.SQLiteMode) ResourcesMode(org.robolectric.internal.ResourcesMode) LooperMode(org.robolectric.annotation.LooperMode) Sdk(org.robolectric.pluginapi.Sdk) LooperMode(org.robolectric.annotation.LooperMode) Mode(org.robolectric.annotation.LooperMode.Mode) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)1 AssumptionViolatedException (org.junit.AssumptionViolatedException)1 LooperMode (org.robolectric.annotation.LooperMode)1 Mode (org.robolectric.annotation.LooperMode.Mode)1 SQLiteMode (org.robolectric.annotation.SQLiteMode)1 ResourcesMode (org.robolectric.internal.ResourcesMode)1 InstrumentationConfiguration (org.robolectric.internal.bytecode.InstrumentationConfiguration)1 Sdk (org.robolectric.pluginapi.Sdk)1