Search in sources :

Example 11 with ValidationResult

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

the class SdkPathsTest method testUnReadableNdkDirectory.

public void testUnReadableNdkDirectory() throws Exception {
    File mockFile = mock(File.class);
    when(mockFile.getPath()).thenReturn(DUMMY_PATH);
    when(mockFile.getAbsolutePath()).thenReturn(DUMMY_PATH);
    when(mockFile.isDirectory()).thenReturn(true);
    when(mockFile.canRead()).thenReturn(false);
    ValidationResult result = validateAndroidNdk(mockFile, false);
    assertFalse(result.success);
    assertEquals("The path is not readable.", result.message);
    result = validateAndroidNdk(mockFile, true);
    assertFalse(result.success);
    assertEquals(String.format("The path\n'%1$s'\nis not readable.", DUMMY_PATH), result.message);
}
Also used : ValidationResult(com.android.tools.idea.sdk.SdkPaths.ValidationResult) File(java.io.File)

Example 12 with ValidationResult

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

the class SdkPathsTest method testInvalidNdkDirectory.

public void testInvalidNdkDirectory() throws Exception {
    File mockFile = mock(File.class);
    when(mockFile.getPath()).thenReturn(DUMMY_PATH);
    when(mockFile.getAbsolutePath()).thenReturn(DUMMY_PATH);
    when(mockFile.isDirectory()).thenReturn(false);
    ValidationResult result = validateAndroidNdk(mockFile, false);
    assertFalse(result.success);
    assertEquals("The path does not belong to a directory.", result.message);
    result = validateAndroidNdk(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 13 with ValidationResult

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

the class SdkPathsTest method testValidSdkDirectory.

public void testValidSdkDirectory() throws Exception {
    tmpDir = createTempDirectory(SdkPathsTest.class.getName(), "testValidSdkDirectory");
    createDirectory(new File(tmpDir, "platforms"));
    ValidationResult result = validateAndroidSdk(tmpDir, false);
    assertTrue(result.success);
    result = validateAndroidSdk(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