Search in sources :

Example 66 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class AndroidGradlePluginVersionReaderTest method testGetQuickFixes.

public void testGetQuickFixes() throws Exception {
    loadSimpleApplication();
    Module appModule = myModules.getAppModule();
    List<NotificationHyperlink> quickFixes = myVersionReader.getQuickFixes(appModule, VersionRange.parse("[1.2.0, +)"), null);
    assertThat(quickFixes).hasSize(2);
    NotificationHyperlink quickFix = quickFixes.get(0);
    assertThat(quickFix).isInstanceOf(FixAndroidGradlePluginVersionHyperlink.class);
    FixAndroidGradlePluginVersionHyperlink fixAndroidGradlePluginQuickFix = (FixAndroidGradlePluginVersionHyperlink) quickFix;
    assertEquals(BuildEnvironment.getInstance().getGradlePluginVersion(), fixAndroidGradlePluginQuickFix.getPluginVersion().toString());
    quickFix = quickFixes.get(1);
    assertThat(quickFix).isInstanceOf(OpenUrlHyperlink.class);
    OpenUrlHyperlink openUrlQuickFix = (OpenUrlHyperlink) quickFix;
    assertEquals("https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle", openUrlQuickFix.getUrl());
}
Also used : FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) OpenUrlHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink) Module(com.intellij.openapi.module.Module) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 67 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class AndroidGradleExperimentalPluginVersionReaderTest method testGetQuickFixes.

public void testGetQuickFixes() throws Exception {
    loadSimpleApplication();
    Module appModule = myModules.getAppModule();
    List<NotificationHyperlink> quickFixes = myVersionReader.getQuickFixes(appModule, VersionRange.parse("[1.2.0, +)"), null);
    assertThat(quickFixes).isEmpty();
}
Also used : Module(com.intellij.openapi.module.Module) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 68 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class FailedToParseSdkErrorHandlerTest method testHandleErrorWithBrokenSdkAndNoWriteAccess.

public void testHandleErrorWithBrokenSdkAndNoWriteAccess() throws Exception {
    File sdkPath = new File("/path/to/sdk/home") {

        @Override
        public boolean canWrite() {
            return false;
        }
    };
    when(myAndroidSdks.findPathOfSdkWithoutAddonsFolder(getProject())).thenReturn(sdkPath);
    Throwable cause = new RuntimeException("failed to parse SDK");
    registerSyncErrorToSimulate(cause);
    loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
    SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
    assertNotNull(notificationUpdate);
    assertThat(notificationUpdate.getText()).isEqualTo("The directory 'add-ons', in the Android SDK at '/path/to/sdk/home', is either missing or empty\n\nCurrent user (" + getUserName() + ") does not have write access to the SDK directory.");
    // Verify hyperlinks are correct.
    List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
    assertThat(quickFixes).hasSize(0);
}
Also used : SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) File(java.io.File) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 69 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class SdkToolsVersionSetupStepTest method testSetUpProject.

public void testSetUpProject() {
    when(myIdeSdks.getAndroidSdkPath()).thenReturn(new File("fakePath"));
    mySetupStep.setUpProject(getProject(), null);
    List<NotificationMessage> messages = myNotification.getMessages();
    assertThat(messages).hasSize(1);
    NotificationMessage message = messages.get(0);
    assertEquals("Android SDK Tools", message.getTitle());
    assertEquals("Version " + MIN_TOOLS_REV + " or later is required.", message.getText());
    assertEquals(INFORMATION, message.getType());
    NotificationHyperlink[] hyperlinks = message.getHyperlinks();
    assertThat(hyperlinks).hasLength(1);
    NotificationHyperlink hyperlink = hyperlinks[0];
    assertThat(hyperlink).isInstanceOf(InstallSdkToolsHyperlink.class);
    assertEquals(MIN_TOOLS_REV, ((InstallSdkToolsHyperlink) hyperlink).getVersion());
    assertTrue(mySetupStep.isNewSdkVersionToolsInfoAlreadyShown());
}
Also used : NotificationMessage(com.android.tools.idea.gradle.project.AndroidGradleNotificationStub.NotificationMessage) File(java.io.File) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 70 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class ExpiredPreviewBuildSetupStepIdeaTest method testSetUpProjectWithExpiredPreview.

public void testSetUpProjectWithExpiredPreview() {
    when(myApplicationInfo.getFullVersion()).thenReturn("1.2 Preview");
    when(myApplicationInfo.getBuildDate()).thenReturn(simulateExpiredBuildDate());
    mySetupStep.setUpProject(getProject(), null);
    List<NotificationMessage> messages = myNotification.getMessages();
    assertThat(messages).hasSize(1);
    NotificationMessage message = messages.get(0);
    assertEquals("Old Preview Build", message.getTitle());
    assertEquals("This preview build (1.2 Preview) is old; please update to a newer preview or a stable version.", message.getText());
    assertEquals(INFORMATION, message.getType());
    NotificationHyperlink[] hyperlinks = message.getHyperlinks();
    assertThat(hyperlinks).hasLength(1);
    NotificationHyperlink hyperlink = hyperlinks[0];
    assertThat(hyperlink).isInstanceOf(OpenUrlHyperlink.class);
    assertTrue(mySetupStep.isExpirationChecked());
}
Also used : NotificationMessage(com.android.tools.idea.gradle.project.AndroidGradleNotificationStub.NotificationMessage) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Aggregations

NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)70 ArrayList (java.util.ArrayList)28 NotNull (org.jetbrains.annotations.NotNull)28 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)17 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)11 Module (com.intellij.openapi.module.Module)11 OpenUrlHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink)10 FixAndroidGradlePluginVersionHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink)8 OpenFileHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink)8 File (java.io.File)8 Project (com.intellij.openapi.project.Project)5 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)4 GradleVersion (com.android.ide.common.repository.GradleVersion)3 OpenAndroidSdkManagerHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ProgressIndicator (com.android.repository.api.ProgressIndicator)2 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)2 NotificationMessage (com.android.tools.idea.gradle.project.AndroidGradleNotificationStub.NotificationMessage)2 CreateGradleWrapperHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.CreateGradleWrapperHyperlink)2 InstallBuildToolsHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.InstallBuildToolsHyperlink)2