Search in sources :

Example 1 with HyperlinkFixture

use of com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.HyperlinkFixture 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)

Aggregations

GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)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 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 GradleSettings (org.jetbrains.plugins.gradle.settings.GradleSettings)1 Test (org.junit.Test)1