use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class AndroidSdkUtilsTest method testGetTargetLabel.
public void testGetTargetLabel() throws Exception {
IAndroidTarget platformTarget = new MockPlatformTarget(18, 2);
assertEquals("API 18: Android 4.3 (Jelly Bean)", AndroidSdkUtils.getTargetLabel(platformTarget));
IAndroidTarget unknownTarget = new MockPlatformTarget(-1, 1);
assertEquals("API -1", AndroidSdkUtils.getTargetLabel(unknownTarget));
IAndroidTarget anotherUnknownTarget = new MockPlatformTarget(100, 1);
assertEquals("API 100", AndroidSdkUtils.getTargetLabel(anotherUnknownTarget));
IAndroidTarget platformPreviewTarget = new MockPlatformTarget(100, 1) {
@NonNull
@Override
public AndroidVersion getVersion() {
return new AndroidVersion(100, "Z");
}
};
assertEquals("API 100+: platform r100", AndroidSdkUtils.getTargetLabel(platformPreviewTarget));
}
use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class AndroidVersionsInfoTest method withPlatformAndroidTarget.
/**
* For platform Android target versions, the Build API should be the same as the platform target
*/
@Test
public void withPlatformAndroidTarget() {
final MockPlatformTarget baseTarget = new MockPlatformTarget(DEFAULT_VERSION, 0);
MockAddonTarget projectTarget = new MockAddonTarget("google", baseTarget, 1);
AndroidVersionsInfo.VersionItem versionItem = myMockAndroidVersionsInfo.new VersionItem(projectTarget);
assertEquals(DEFAULT_VERSION, versionItem.getApiLevel());
assertEquals(DEFAULT_VERSION, versionItem.getBuildApiLevel());
}
use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class LaunchCompatibilityTest method testMinSdk.
public void testMinSdk() {
final MockPlatformTarget projectTarget = new MockPlatformTarget(14, 0);
final EnumSet<IDevice.HardwareFeature> requiredFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class);
// cannot run if the API level of device is < API level required by minSdk
LaunchCompatibility compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, null), projectTarget, requiredFeatures, null, createMockDevice(7, null));
assertEquals(new LaunchCompatibility(ThreeState.NO, "minSdk(API 8) > deviceSdk(API 7)"), compatibility);
// can run if the API level of device is >= API level required by minSdk
compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, null), projectTarget, requiredFeatures, null, createMockDevice(8, null));
assertEquals(new LaunchCompatibility(ThreeState.YES, null), compatibility);
// cannot run if minSdk uses a code name that is not matched by the device
compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, "P"), projectTarget, requiredFeatures, null, createMockDevice(9, null));
assertEquals(new LaunchCompatibility(ThreeState.NO, "minSdk(API 8, P preview) != deviceSdk(API 9)"), compatibility);
}
use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class LaunchCompatibilityTest method testIncompatibleAbiFilter.
public void testIncompatibleAbiFilter() {
AndroidVersion minSdkVersion = new AndroidVersion(8, null);
MockPlatformTarget projectTarget = new MockPlatformTarget(14, 0);
EnumSet<IDevice.HardwareFeature> requiredFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class);
Set<String> supportedAbis = ImmutableSet.of(Abi.X86_64.toString());
List<Abi> deviceAbis = ImmutableList.of(Abi.ARMEABI, Abi.ARMEABI_V7A, Abi.ARM64_V8A);
LaunchCompatibility compatibility = LaunchCompatibility.canRunOnDevice(minSdkVersion, projectTarget, requiredFeatures, supportedAbis, createMockDevice(8, null, false, deviceAbis));
assertEquals(new LaunchCompatibility(ThreeState.NO, "Device supports armeabi, armeabi-v7a, arm64-v8a, but APK only supports x86_64"), compatibility);
}
use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class AndroidVersionsInfoTest method highestInstalledTarget.
/**
* For preview Android target versions, the Build API should be the same as the preview
*/
@Test
public void highestInstalledTarget() {
MockPlatformTarget androidTarget = new MockPlatformTarget(DEFAULT_VERSION, 0);
AndroidVersionsInfo.VersionItem versionItem = myMockAndroidVersionsInfo.new VersionItem(androidTarget);
assertEquals(DEFAULT_VERSION, versionItem.getApiLevel());
assertEquals(HIGHEST_VERSION, versionItem.getBuildApiLevel());
}
Aggregations