use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class UnresolvedDependenciesReporterTest method testReportWithConstraintLayout.
public void testReportWithConstraintLayout() throws Exception {
myOriginalIdeInfo = IdeInfo.getInstance();
IdeInfo ideInfo = IdeComponents.replaceServiceWithMock(IdeInfo.class);
when(ideInfo.isAndroidStudio()).thenReturn(true);
loadSimpleApplication();
mySyncMessagesStub.clearReportedMessages();
Module appModule = myModules.getAppModule();
when(mySyncIssue.getData()).thenReturn("com.android.support.constraint:constraint-layout:+");
myReporter.report(mySyncIssue, appModule, null);
SyncMessage message = mySyncMessagesStub.getFirstReportedMessage();
assertNotNull(message);
// @formatter:off
assertAbout(syncMessage()).that(message).hasGroup("Unresolved Android dependencies").hasMessageLine("Failed to resolve: com.android.support.constraint:constraint-layout:+", 0);
// @formatter:on
List<NotificationHyperlink> quickFixes = message.getQuickFixes();
assertThat(quickFixes).hasSize(2);
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class ClassLoadingErrorHandlerTest method assertErrorAndHyperlinksDisplayed.
private void assertErrorAndHyperlinksDisplayed(@NotNull Throwable cause) throws Exception {
registerSyncErrorToSimulate(cause);
loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
String message = notificationUpdate.getText();
assertThat(message).contains("Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle");
assertThat(message).contains("Re-download dependencies and sync project");
assertThat(message).contains("In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.");
boolean restartCapable = ApplicationManager.getApplication().isRestartCapable();
String quickFixText = restartCapable ? "Stop Gradle build processes (requires restart)" : "Open Gradle Daemon documentation";
assertTrue(message.contains(quickFixText));
// Verify hyperlinks are correct.
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(2);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(SyncProjectWithExtraCommandLineOptionsHyperlink.class);
quickFix = quickFixes.get(1);
assertThat(quickFix).isInstanceOf(OpenUrlHyperlink.class);
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class ConnectionPermissionDeniedErrorHandlerTest method testHandleError.
public void testHandleError() throws Exception {
Throwable cause = new SocketException("Permission denied: connect");
registerSyncErrorToSimulate(cause);
loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
assertThat(notificationUpdate.getText()).contains("Connection to the Internet denied.");
// Verify hyperlinks are correct.
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(1);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(OpenUrlHyperlink.class);
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class ErrorOpeningZipFileErrorHandlerTest method testHandleError.
public void testHandleError() throws Exception {
registerSyncErrorToSimulate("error in opening zip file");
loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
assertThat(notificationUpdate.getText()).contains("Failed to open zip file.\n" + "Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)\n");
// Verify hyperlinks are correct.
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(1);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(SyncProjectWithExtraCommandLineOptionsHyperlink.class);
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class FailedToParseSdkErrorHandlerTest method testHandleErrorWithBrokenSdkAndWithWriteAccess.
public void testHandleErrorWithBrokenSdkAndWithWriteAccess() throws Exception {
File sdkPath = new File("/path/to/sdk/home") {
@Override
public boolean canWrite() {
return true;
}
};
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");
// Verify hyperlinks are correct.
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(0);
}
Aggregations