Search in sources :

Example 11 with GradleSettings

use of org.jetbrains.plugins.gradle.settings.GradleSettings in project android by JetBrains.

the class GradleSyncTest method syncDuringOfflineMode.

@Test
public void syncDuringOfflineMode() throws IOException {
    String hyperlinkText = "Disable offline mode and sync project";
    guiTest.importSimpleApplication();
    IdeFrameFixture ideFrame = guiTest.ideFrame();
    File buildFile = new File(ideFrame.getProjectPath(), join("app", FN_BUILD_GRADLE));
    assertAbout(file()).that(buildFile).isFile();
    appendToFile(buildFile, "dependencies { compile 'something:not:exists' }");
    GradleSettings gradleSettings = GradleSettings.getInstance(ideFrame.getProject());
    gradleSettings.setOfflineWork(true);
    ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
    MessagesToolWindowFixture messagesToolWindow = ideFrame.getMessagesToolWindow();
    MessageFixture message = messagesToolWindow.getGradleSyncContent().findMessage(ERROR, firstLineStartingWith("Failed to resolve:"));
    HyperlinkFixture hyperlink = message.findHyperlink(hyperlinkText);
    hyperlink.click();
    assertFalse(gradleSettings.isOfflineWork());
    ideFrame.waitForGradleProjectSyncToFinish();
    messagesToolWindow = ideFrame.getMessagesToolWindow();
    message = messagesToolWindow.getGradleSyncContent().findMessage(ERROR, firstLineStartingWith("Failed to resolve:"));
    try {
        message.findHyperlink(hyperlinkText);
        fail(hyperlinkText + " link still present");
    } catch (AssertionError e) {
        // After offline mode is disable, the previous hyperlink will disappear after next sync
        assertThat(e.getMessage()).contains("Failed to find URL");
        assertThat(e.getMessage()).contains(hyperlinkText);
    }
}
Also used : HyperlinkFixture(com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.HyperlinkFixture) GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) MessageFixture(com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) GradleBuildFile(com.android.tools.idea.gradle.parser.GradleBuildFile) File(java.io.File) GradleUtil.getGradleBuildFile(com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile) Test(org.junit.Test)

Example 12 with GradleSettings

use of org.jetbrains.plugins.gradle.settings.GradleSettings in project android by JetBrains.

the class IdeFrameFixture method setGradleJvmArgs.

@NotNull
public IdeFrameFixture setGradleJvmArgs(@NotNull String jvmArgs) {
    Project project = getProject();
    GradleSettings settings = GradleSettings.getInstance(project);
    settings.setGradleVmOptions(jvmArgs);
    Wait.seconds(1).expecting("Gradle settings to be set").until(() -> jvmArgs.equals(settings.getGradleVmOptions()));
    return this;
}
Also used : Project(com.intellij.openapi.project.Project) GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GradleSettings (org.jetbrains.plugins.gradle.settings.GradleSettings)12 Project (com.intellij.openapi.project.Project)3 File (java.io.File)3 GradleProjectSettings (org.jetbrains.plugins.gradle.settings.GradleProjectSettings)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NotNull (org.jetbrains.annotations.NotNull)2 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)1 SdkSync (com.android.tools.idea.gradle.project.sync.SdkSync)1 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)1 ToggleOfflineModeHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink)1 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)1 GradleUtil.getGradleBuildFile (com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile)1 HyperlinkFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.HyperlinkFixture)1 MessageFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture)1 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)1 SelectExternalProjectStep (com.intellij.openapi.externalSystem.service.project.wizard.SelectExternalProjectStep)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)1 IOException (java.io.IOException)1