use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class AndroidVersionsInfoTest method withPreviewAndroidTarget.
/**
* For preview Android target versions, the Build API should be the same as the preview
*/
@Test
public void withPreviewAndroidTarget() {
MockPlatformTarget androidTarget = new MockPlatformTarget(PREVIEW_VERSION, 0) {
@NonNull
@Override
public AndroidVersion getVersion() {
return new AndroidVersion(PREVIEW_VERSION - 1, "TEST_CODENAME");
}
};
AndroidVersionsInfo.VersionItem versionItem = myMockAndroidVersionsInfo.new VersionItem(androidTarget);
assertEquals(PREVIEW_VERSION, versionItem.getApiLevel());
assertEquals(PREVIEW_VERSION, versionItem.getBuildApiLevel());
}
use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class LaunchCompatibilityTest method testOpenAbiFilter.
public void testOpenAbiFilter() {
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();
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.YES, null), compatibility);
}
use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class LaunchCompatibilityTest method testRequiredDeviceCharacteristic.
public void testRequiredDeviceCharacteristic() {
final AndroidVersion minSdkVersion = new AndroidVersion(8, null);
final MockPlatformTarget projectTarget = new MockPlatformTarget(14, 0);
EnumSet<IDevice.HardwareFeature> requiredFeatures = EnumSet.of(IDevice.HardwareFeature.WATCH);
// cannot run if the device doesn't have a required feature
LaunchCompatibility compatibility = LaunchCompatibility.canRunOnDevice(minSdkVersion, projectTarget, requiredFeatures, null, createMockDevice(8, null, false));
assertEquals(new LaunchCompatibility(ThreeState.NO, "missing feature: WATCH"), compatibility);
// can run if the device has the required features
compatibility = LaunchCompatibility.canRunOnDevice(minSdkVersion, projectTarget, requiredFeatures, null, createMockDevice(8, null, true));
assertEquals(new LaunchCompatibility(ThreeState.YES, null), compatibility);
// cannot run apk's that don't specify uses-feature watch on a wear device
requiredFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class);
compatibility = LaunchCompatibility.canRunOnDevice(minSdkVersion, projectTarget, requiredFeatures, null, createMockDevice(8, null, true));
assertEquals(new LaunchCompatibility(ThreeState.NO, "missing uses-feature watch, non-watch apks cannot be launched on a watch"), compatibility);
}
use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class LaunchCompatibilityTest method testRequiredAddons.
public void testRequiredAddons() {
final AndroidVersion minSdkVersion = new AndroidVersion(8, null);
final EnumSet<IDevice.HardwareFeature> requiredFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class);
// add-on target shouldn't affect anything if it doesn't have optional libraries
final MockPlatformTarget baseTarget = new MockPlatformTarget(14, 0);
MockAddonTarget projectTarget = new MockAddonTarget("google", baseTarget, 1);
LaunchCompatibility compatibility = LaunchCompatibility.canRunOnDevice(minSdkVersion, projectTarget, requiredFeatures, null, createMockDevice(8, null, false));
assertEquals(new LaunchCompatibility(ThreeState.YES, null), compatibility);
IAndroidTarget.OptionalLibrary optionalLibrary = mock(IAndroidTarget.OptionalLibrary.class);
projectTarget.setOptionalLibraries(ImmutableList.of(optionalLibrary));
// add-on targets with optional libraries should still be allowed to run on real devices (no avdinfo)
compatibility = LaunchCompatibility.canRunOnDevice(minSdkVersion, projectTarget, requiredFeatures, null, createMockDevice(8, null, false));
assertEquals(new LaunchCompatibility(ThreeState.UNSURE, "unsure if device supports addon: google"), compatibility);
// Google APIs add on should be treated as a special case and should always be allowed to run on a real device
MockAddonTarget googleApiTarget = new MockAddonTarget("Google APIs", baseTarget, 1);
googleApiTarget.setOptionalLibraries(ImmutableList.of(optionalLibrary));
compatibility = LaunchCompatibility.canRunOnDevice(minSdkVersion, googleApiTarget, requiredFeatures, null, createMockDevice(8, null, false));
assertEquals(new LaunchCompatibility(ThreeState.YES, null), compatibility);
}
use of com.android.sdklib.internal.androidTarget.MockPlatformTarget in project android by JetBrains.
the class LaunchCompatibilityTest method testCompatibleAbiFilter.
public void testCompatibleAbiFilter() {
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.ARMEABI_V7A.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.YES, null), compatibility);
}
Aggregations