Search in sources :

Example 81 with AndroidVersion

use of com.android.sdklib.AndroidVersion 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);
}
Also used : MockPlatformTarget(com.android.sdklib.internal.androidTarget.MockPlatformTarget) IDevice(com.android.ddmlib.IDevice) Abi(com.android.sdklib.devices.Abi) AndroidVersion(com.android.sdklib.AndroidVersion)

Example 82 with AndroidVersion

use of com.android.sdklib.AndroidVersion 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);
}
Also used : MockPlatformTarget(com.android.sdklib.internal.androidTarget.MockPlatformTarget) AndroidVersion(com.android.sdklib.AndroidVersion)

Example 83 with AndroidVersion

use of com.android.sdklib.AndroidVersion 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);
}
Also used : MockPlatformTarget(com.android.sdklib.internal.androidTarget.MockPlatformTarget) MockAddonTarget(com.android.sdklib.internal.androidTarget.MockAddonTarget) IDevice(com.android.ddmlib.IDevice) IAndroidTarget(com.android.sdklib.IAndroidTarget) AndroidVersion(com.android.sdklib.AndroidVersion)

Example 84 with AndroidVersion

use of com.android.sdklib.AndroidVersion 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);
}
Also used : MockPlatformTarget(com.android.sdklib.internal.androidTarget.MockPlatformTarget) IDevice(com.android.ddmlib.IDevice) Abi(com.android.sdklib.devices.Abi) AndroidVersion(com.android.sdklib.AndroidVersion)

Example 85 with AndroidVersion

use of com.android.sdklib.AndroidVersion in project android by JetBrains.

the class DevicePickerListModelTest method createMockDevice.

@NotNull
private static IDevice createMockDevice(boolean isEmulator, @Nullable String avdName, int apiLevel, @NotNull String buildVersion) {
    IDevice device = mock(IDevice.class);
    when(device.isEmulator()).thenReturn(isEmulator);
    when(device.getAvdName()).thenReturn(avdName);
    when(device.getVersion()).thenReturn(new AndroidVersion(apiLevel, buildVersion));
    return device;
}
Also used : IDevice(com.android.ddmlib.IDevice) AndroidVersion(com.android.sdklib.AndroidVersion) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AndroidVersion (com.android.sdklib.AndroidVersion)89 Test (org.junit.Test)21 NotNull (org.jetbrains.annotations.NotNull)14 IAndroidTarget (com.android.sdklib.IAndroidTarget)12 IDevice (com.android.ddmlib.IDevice)11 Nullable (org.jetbrains.annotations.Nullable)9 MockPlatformTarget (com.android.sdklib.internal.androidTarget.MockPlatformTarget)8 Module (com.intellij.openapi.module.Module)8 File (java.io.File)8 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)8 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)8 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)6 Project (com.intellij.openapi.project.Project)5 Abi (com.android.sdklib.devices.Abi)4 InstantRunGradleSupport (com.android.tools.idea.fd.gradle.InstantRunGradleSupport)4 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)4 OutputFile (com.android.build.OutputFile)3 TypeDetails (com.android.repository.impl.meta.TypeDetails)3 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)3 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)3