use of com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink in project android by JetBrains.
the class CachedDependencyNotFoundErrorHandlerTest method testHandleError.
public void testHandleError() throws Exception {
GradleSettings settings = GradleSettings.getInstance(getProject());
// Set "offline mode" on to force the IDE to show quick-fix.
settings.setOfflineWork(true);
String expectedNotificationMessage = "No cached version of dependency, available for offline mode.";
String error = expectedNotificationMessage + "\nExtra error message.";
registerSyncErrorToSimulate(error);
loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
assertThat(notificationUpdate.getText()).contains(expectedNotificationMessage);
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(1);
// Verify hyperlinks are correct.
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(ToggleOfflineModeHyperlink.class);
ToggleOfflineModeHyperlink toggleOfflineModeQuickFix = (ToggleOfflineModeHyperlink) quickFix;
assertFalse(toggleOfflineModeQuickFix.isEnableOfflineMode());
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink in project android by JetBrains.
the class MissingDependencyErrorHandler method handleMissingDependency.
private static void handleMissingDependency(@NotNull NotificationData notification, @NotNull Project project, @NotNull String msg, @NotNull String dependency, @NotNull List<NotificationHyperlink> additionalHyperlinks) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>(additionalHyperlinks);
ToggleOfflineModeHyperlink disableOfflineMode = ToggleOfflineModeHyperlink.disableOfflineMode(project);
if (disableOfflineMode != null) {
hyperlinks.add(0, disableOfflineMode);
}
hyperlinks.add(new SearchInBuildFilesHyperlink(dependency));
SyncMessages.getInstance(project).updateNotification(notification, msg, hyperlinks);
}
Aggregations