Search in sources :

Example 1 with MockAddonTarget

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

Example 2 with MockAddonTarget

use of com.android.sdklib.internal.androidTarget.MockAddonTarget 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)

Aggregations

MockAddonTarget (com.android.sdklib.internal.androidTarget.MockAddonTarget)2 MockPlatformTarget (com.android.sdklib.internal.androidTarget.MockPlatformTarget)2 IDevice (com.android.ddmlib.IDevice)1 AndroidVersion (com.android.sdklib.AndroidVersion)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 Test (org.junit.Test)1