use of org.robolectric.internal.SdkConfig in project robolectric by robolectric.
the class SdkPickerTest method shouldClipSdkRangeFromAndroidManifest.
@Test
public void shouldClipSdkRangeFromAndroidManifest() throws Exception {
when(appManifest.getTargetSdkVersion()).thenReturn(1);
when(appManifest.getMinSdkVersion()).thenReturn(1);
when(appManifest.getMaxSdkVersion()).thenReturn(null);
assertThat(sdkPicker.selectSdks(new Config.Builder().build(), appManifest)).containsExactly(new SdkConfig(16));
}
use of org.robolectric.internal.SdkConfig in project robolectric by robolectric.
the class SdkPicker method configuredSdks.
protected Set<SdkConfig> configuredSdks(Config config, AndroidManifest appManifest) {
int appMinSdk = Math.max(appManifest.getMinSdkVersion(), minSupportedSdk.getApiLevel());
int appTargetSdk = Math.max(appManifest.getTargetSdkVersion(), minSupportedSdk.getApiLevel());
Integer appMaxSdk = appManifest.getMaxSdkVersion();
if (appMaxSdk == null) {
appMaxSdk = maxSupportedSdk.getApiLevel();
}
// For min/max SDK ranges...
int minSdk = config.minSdk();
int maxSdk = config.maxSdk();
if (minSdk != -1 || maxSdk != -1) {
int rangeMin = decodeSdk(minSdk, appMinSdk, appMinSdk, appTargetSdk, appMaxSdk);
int rangeMax = decodeSdk(maxSdk, appMaxSdk, appMinSdk, appTargetSdk, appMaxSdk);
if (rangeMin > rangeMax && (minSdk == -1 || maxSdk == -1)) {
return Collections.emptySet();
}
return sdkRange(rangeMin, rangeMax);
}
// For explicitly-enumerated SDKs...
if (config.sdk().length == 0) {
return Collections.singleton(new SdkConfig(appTargetSdk));
}
if (config.sdk().length == 1 && config.sdk()[0] == Config.ALL_SDKS) {
return sdkRange(appMinSdk, appMaxSdk);
}
Set<SdkConfig> sdkConfigs = new HashSet<>();
for (int sdk : config.sdk()) {
int decodedApiLevel = decodeSdk(sdk, appTargetSdk, appMinSdk, appTargetSdk, appMaxSdk);
sdkConfigs.add(new SdkConfig(decodedApiLevel));
}
return sdkConfigs;
}
use of org.robolectric.internal.SdkConfig in project robolectric by robolectric.
the class ParallelUniverseTest method setUp.
@Before
public void setUp() throws InitializationError {
pu = new ParallelUniverse();
pu.setSdkConfig(new SdkConfig(18));
}
use of org.robolectric.internal.SdkConfig in project robolectric by robolectric.
the class SdkPickerTest method withDefaultSdkConfig_shouldUseTargetSdkFromAndroidManifest.
@Test
public void withDefaultSdkConfig_shouldUseTargetSdkFromAndroidManifest() throws Exception {
when(appManifest.getTargetSdkVersion()).thenReturn(22);
assertThat(sdkPicker.selectSdks(new Config.Builder().build(), appManifest)).containsExactly(new SdkConfig(22));
}
use of org.robolectric.internal.SdkConfig in project robolectric by robolectric.
the class SdkPickerTest method withMinSdkConfig_shouldClipSdkRangeFromAndroidManifest.
@Test
public void withMinSdkConfig_shouldClipSdkRangeFromAndroidManifest() throws Exception {
when(appManifest.getTargetSdkVersion()).thenReturn(22);
when(appManifest.getMinSdkVersion()).thenReturn(19);
when(appManifest.getMaxSdkVersion()).thenReturn(23);
assertThat(sdkPicker.selectSdks(new Config.Builder().setMinSdk(21).build(), appManifest)).containsExactly(new SdkConfig(21), new SdkConfig(22), new SdkConfig(23));
}
Aggregations