Search in sources :

Example 41 with IAndroidTarget

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

the class AndroidSdksTest method testFindSuitableAndroidSdk.

public void testFindSuitableAndroidSdk() {
    IAndroidTarget target = findAndroidTarget();
    Sdk sdk = myAndroidSdks.create(target, mySdkPath, myJdk, false);
    assertNotNull(sdk);
    String hash = getTargetHashString(target);
    Sdk foundSdk = myAndroidSdks.findSuitableAndroidSdk(hash);
    assertNotNull(foundSdk);
    assertEquals(sdk.getHomePath(), foundSdk.getHomePath());
    AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(foundSdk);
    assertEquals(hash, data.getBuildTargetHashString());
}
Also used : AndroidSdkAdditionalData(org.jetbrains.android.sdk.AndroidSdkAdditionalData) IAndroidTarget(com.android.sdklib.IAndroidTarget) Sdk(com.intellij.openapi.projectRoots.Sdk) AndroidTargetHash.getTargetHashString(com.android.sdklib.AndroidTargetHash.getTargetHashString)

Example 42 with IAndroidTarget

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

the class AndroidSdksTest method testCreateSdk.

public void testCreateSdk() {
    IAndroidTarget target = findAndroidTarget();
    String name = "testSdk";
    Sdk sdk = myAndroidSdks.create(target, mySdkPath, name, myJdk, true);
    assertNotNull(sdk);
    assertEquals(name, sdk.getName());
    verifyCorrectPath(sdk);
    AndroidSdkAdditionalData androidData = getAndroidSdkAdditionalData(sdk);
    assertSame(myJdk, androidData.getJavaSdk());
    AndroidPlatform androidPlatform = androidData.getAndroidPlatform();
    assertNotNull(androidPlatform);
    assertSame(target, androidPlatform.getTarget());
    File platformPath = new File(mySdkPath, join("platforms", androidData.getBuildTargetHashString()));
    // Check roots added to SDK
    Map<String, VirtualFile> classRootsByName = getSdkRootsByName(sdk, CLASSES);
    // android.jar and res folder
    assertThat(classRootsByName).hasSize(2);
    VirtualFile androidJar = classRootsByName.get("android.jar");
    File expectedAndroidJarPath = new File(platformPath, androidJar.getName());
    assertAbout(file()).that(virtualToIoFile(androidJar)).isEquivalentAccordingToCompareTo(expectedAndroidJarPath);
    VirtualFile resFolder = classRootsByName.get("res");
    File expectedResFolderPath = new File(platformPath, join("data", resFolder.getName()));
    assertAbout(file()).that(virtualToIoFile(resFolder)).isEquivalentAccordingToCompareTo(expectedResFolderPath);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AndroidSdkAdditionalData(org.jetbrains.android.sdk.AndroidSdkAdditionalData) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) IAndroidTarget(com.android.sdklib.IAndroidTarget) AndroidTargetHash.getTargetHashString(com.android.sdklib.AndroidTargetHash.getTargetHashString) Sdk(com.intellij.openapi.projectRoots.Sdk) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 43 with IAndroidTarget

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

the class AndroidSdksTest method createTargetWithApiLevel.

@NotNull
private static IAndroidTarget createTargetWithApiLevel(int apiLevel) {
    AndroidVersion version = new AndroidVersion(apiLevel, null);
    IAndroidTarget target = mock(IAndroidTarget.class);
    when(target.getVersion()).thenReturn(version);
    return target;
}
Also used : IAndroidTarget(com.android.sdklib.IAndroidTarget) AndroidVersion(com.android.sdklib.AndroidVersion) NotNull(org.jetbrains.annotations.NotNull)

Example 44 with IAndroidTarget

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

the class AndroidSdksTest method testNeedsAnnotationsJarInClasspathWithApiLevel15.

public void testNeedsAnnotationsJarInClasspathWithApiLevel15() {
    IAndroidTarget target = createTargetWithApiLevel(15);
    assertTrue(myAndroidSdks.needsAnnotationsJarInClasspath(target));
}
Also used : IAndroidTarget(com.android.sdklib.IAndroidTarget)

Example 45 with IAndroidTarget

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

the class AndroidSdksTest method testChooseNameForNewLibrary.

public void testChooseNameForNewLibrary() {
    IAndroidTarget target = findAndroidTarget();
    String name = myAndroidSdks.chooseNameForNewLibrary(target);
    assertEquals("Android " + target.getVersion().toString() + " Platform", name);
}
Also used : IAndroidTarget(com.android.sdklib.IAndroidTarget) AndroidTargetHash.getTargetHashString(com.android.sdklib.AndroidTargetHash.getTargetHashString)

Aggregations

IAndroidTarget (com.android.sdklib.IAndroidTarget)105 Nullable (org.jetbrains.annotations.Nullable)24 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 Module (com.intellij.openapi.module.Module)17 NotNull (org.jetbrains.annotations.NotNull)16 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)15 Sdk (com.intellij.openapi.projectRoots.Sdk)14 File (java.io.File)13 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)13 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)13 AndroidVersion (com.android.sdklib.AndroidVersion)11 Device (com.android.sdklib.devices.Device)11 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)9 State (com.android.sdklib.devices.State)8 AndroidSdkAdditionalData (org.jetbrains.android.sdk.AndroidSdkAdditionalData)8 AndroidTargetData (org.jetbrains.android.sdk.AndroidTargetData)8 Configuration (com.android.tools.idea.configurations.Configuration)7 CompatibilityRenderTarget (com.android.tools.idea.rendering.multi.CompatibilityRenderTarget)7 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)7 ConfigurationManager (com.android.tools.idea.configurations.ConfigurationManager)6