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);
}
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);
}
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;
}
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;
}
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);
}
Aggregations