Search in sources :

Example 6 with ValidationResult

use of com.android.tools.idea.sdk.SdkPaths.ValidationResult in project android by JetBrains.

the class SdkPathsTest method testNoToolchainsNdkDirectory.

public void testNoToolchainsNdkDirectory() throws Exception {
    if (SystemInfo.isWindows) {
        // Do not run tests on Windows (see http://b.android.com/222904)
        return;
    }
    tmpDir = createTempDirectory(SdkPathsTest.class.getSimpleName(), "testNoToolchainsNdkDirectory");
    createDirectory(new File(tmpDir, "platforms"));
    ValidationResult result = validateAndroidNdk(tmpDir, false);
    assertFalse(result.success);
    assertEquals("NDK does not contain any toolchains.", result.message);
    result = validateAndroidNdk(tmpDir, true);
    assertFalse(result.success);
    assertEquals(String.format("The NDK at\n'%1$s'\ndoes not contain any toolchains.", tmpDir.getPath()), result.message);
}
Also used : ValidationResult(com.android.tools.idea.sdk.SdkPaths.ValidationResult) File(java.io.File)

Example 7 with ValidationResult

use of com.android.tools.idea.sdk.SdkPaths.ValidationResult in project android by JetBrains.

the class SdkPathsTest method testInvalidSdkDirectory.

public void testInvalidSdkDirectory() throws Exception {
    File mockFile = mock(File.class);
    when(mockFile.getPath()).thenReturn(DUMMY_PATH);
    when(mockFile.isDirectory()).thenReturn(false);
    ValidationResult result = validateAndroidSdk(mockFile, false);
    assertFalse(result.success);
    assertEquals("The path does not belong to a directory.", result.message);
    result = validateAndroidSdk(mockFile, true);
    assertFalse(result.success);
    assertEquals(String.format("The path\n'%1$s'\ndoes not belong to a directory.", DUMMY_PATH), result.message);
}
Also used : ValidationResult(com.android.tools.idea.sdk.SdkPaths.ValidationResult) File(java.io.File)

Example 8 with ValidationResult

use of com.android.tools.idea.sdk.SdkPaths.ValidationResult in project android by JetBrains.

the class IdeSdksConfigurable method validateAndroidSdkPath.

/**
   * @return the error message when the sdk path is not valid, {@code null} otherwise.
   */
@Nullable
private String validateAndroidSdkPath() {
    //noinspection deprecation
    WizardUtils.ValidationResult wizardValidationResult = validateLocation(getSdkLocation().getAbsolutePath(), "Android SDK location", false, WritableCheckMode.DO_NOT_CHECK);
    if (!wizardValidationResult.isOk()) {
        return wizardValidationResult.getFormattedMessage();
    }
    ValidationResult validationResult = validateAndroidSdk(getSdkLocation(), false);
    if (!validationResult.success) {
        String msg = validationResult.message;
        if (isEmpty(msg)) {
            msg = CHOOSE_VALID_SDK_DIRECTORY_ERR;
        }
        return msg;
    }
    return null;
}
Also used : WizardUtils(com.android.tools.idea.npw.WizardUtils) ValidationResult(com.android.tools.idea.sdk.SdkPaths.ValidationResult) Nullable(org.jetbrains.annotations.Nullable)

Example 9 with ValidationResult

use of com.android.tools.idea.sdk.SdkPaths.ValidationResult in project android by JetBrains.

the class IdeSdksConfigurable method validateAndroidNdkPath.

/**
   * @return the error message when the ndk path is not valid, {@code null} otherwise.
   */
@Nullable
private String validateAndroidNdkPath() {
    hideNdkQuickfixLink();
    // As NDK is required for the projects with NDK modules, considering the empty value as legal.
    if (!myNdkLocationTextField.getText().isEmpty()) {
        ValidationResult validationResult = validateAndroidNdk(getNdkLocation(), false);
        if (!validationResult.success) {
            adjustNdkQuickFixVisibility();
            String msg = validationResult.message;
            if (isEmpty(msg)) {
                msg = CHOOSE_VALID_NDK_DIRECTORY_ERR;
            }
            return msg;
        }
    } else if (myNdkLocationTextField.isVisible()) {
        adjustNdkQuickFixVisibility();
    }
    return null;
}
Also used : ValidationResult(com.android.tools.idea.sdk.SdkPaths.ValidationResult) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with ValidationResult

use of com.android.tools.idea.sdk.SdkPaths.ValidationResult in project android by JetBrains.

the class SdkPathsTest method testValidNdkDirectory.

public void testValidNdkDirectory() throws Exception {
    if (SystemInfo.isWindows) {
        // Do not run tests on Windows (see http://b.android.com/222904)
        return;
    }
    tmpDir = createTempDirectory(SdkPathsTest.class.getName(), "testValidNdkDirectory");
    createDirectory(new File(tmpDir, "platforms"));
    createDirectory(new File(tmpDir, "toolchains"));
    ValidationResult result = validateAndroidNdk(tmpDir, false);
    assertTrue(result.success);
    result = validateAndroidNdk(tmpDir, true);
    assertTrue(result.success);
}
Also used : ValidationResult(com.android.tools.idea.sdk.SdkPaths.ValidationResult) File(java.io.File)

Aggregations

ValidationResult (com.android.tools.idea.sdk.SdkPaths.ValidationResult)13 File (java.io.File)9 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Nullable (org.jetbrains.annotations.Nullable)2 WizardUtils (com.android.tools.idea.npw.WizardUtils)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ExternalSystemException (com.intellij.openapi.externalSystem.model.ExternalSystemException)1 FileChooser.chooseFile (com.intellij.openapi.fileChooser.FileChooser.chooseFile)1 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)1 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)1 NotNull (org.jetbrains.annotations.NotNull)1