Search in sources :

Example 1 with MessageFixture

use of com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture in project android by JetBrains.

the class GradleSyncTest method withPreReleasePlugin.

@Test
public void withPreReleasePlugin() throws IOException {
    guiTest.importMultiModule();
    guiTest.ideFrame().updateAndroidGradlePluginVersion("1.2.0-beta1").requestProjectSync().waitForGradleProjectSyncToFail();
    ContentFixture syncMessages = guiTest.ideFrame().getMessagesToolWindow().getGradleSyncContent();
    MessageFixture message = syncMessages.findMessage(ERROR, firstLineStartingWith("Plugin is too old, please update to a more recent version"));
    // Verify that the "quick fix" is added.
    message.findHyperlink("Fix plugin version and sync project");
}
Also used : MessageFixture(com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture) ContentFixture(com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.ContentFixture) Test(org.junit.Test)

Example 2 with MessageFixture

use of com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture in project android by JetBrains.

the class GradleSyncTest method javaToAndroidModuleDependencies.

// See https://code.google.com/p/android/issues/detail?id=169778
@Test
public void javaToAndroidModuleDependencies() throws IOException {
    guiTest.importMultiModule();
    IdeFrameFixture ideFrame = guiTest.ideFrame();
    Module library3 = ideFrame.getModule("library3");
    assertNull(AndroidFacet.getInstance(library3));
    File library3BuildFile = new File(ideFrame.getProjectPath(), join("library3", FN_BUILD_GRADLE));
    assertAbout(file()).that(library3BuildFile).isFile();
    appendToFile(library3BuildFile, "dependencies { compile project(':app') }");
    ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
    ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(library3);
    // Verify that the module "library3" doesn't depend on module "app"
    ModuleOrderEntry moduleDependency = null;
    for (OrderEntry orderEntry : moduleRootManager.getOrderEntries()) {
        if (orderEntry instanceof ModuleOrderEntry) {
            moduleDependency = (ModuleOrderEntry) orderEntry;
            break;
        }
    }
    assertNull(moduleDependency);
    ContentFixture syncMessages = ideFrame.getMessagesToolWindow().getGradleSyncContent();
    MessageFixture message = syncMessages.findMessage(WARNING, firstLineStartingWith("Ignoring dependency of module 'app' on module 'library3'."));
    // Verify if the error message's link goes to the build file.
    VirtualFile buildFile = getGradleBuildFile(library3);
    message.requireLocation(new File(buildFile.getPath()), 0);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MessageFixture(com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture) Module(com.intellij.openapi.module.Module) 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) ContentFixture(com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.ContentFixture) Test(org.junit.Test)

Example 3 with MessageFixture

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

MessageFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture)3 Test (org.junit.Test)3 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)2 GradleUtil.getGradleBuildFile (com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile)2 ContentFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.ContentFixture)2 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 HyperlinkFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.HyperlinkFixture)1 Module (com.intellij.openapi.module.Module)1 GradleSettings (org.jetbrains.plugins.gradle.settings.GradleSettings)1