Search in sources :

Example 1 with ContentFixture

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

the class GradleSyncTest method withAndroidProjectWithoutVariants.

// Verifies that sync does not fail and user is warned when a project contains an Android module without variants.
// See https://code.google.com/p/android/issues/detail?id=170722
@Test
public void withAndroidProjectWithoutVariants() throws IOException {
    guiTest.importSimpleApplication();
    IdeFrameFixture ideFrame = guiTest.ideFrame();
    assertNotNull(AndroidFacet.getInstance(ideFrame.getModule("app")));
    File appBuildFile = new File(ideFrame.getProjectPath(), join("app", FN_BUILD_GRADLE));
    assertAbout(file()).that(appBuildFile).isFile();
    // Remove all variants.
    appendToFile(appBuildFile, "android.variantFilter { variant -> variant.ignore = true }");
    ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
    // Verify user was warned.
    ContentFixture syncMessages = ideFrame.getMessagesToolWindow().getGradleSyncContent();
    syncMessages.findMessage(ERROR, firstLineStartingWith("The module 'app' is an Android project without build variants"));
    // Verify AndroidFacet was removed.
    assertNull(AndroidFacet.getInstance(ideFrame.getModule("app")));
}
Also used : 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 2 with ContentFixture

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

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

Aggregations

ContentFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.ContentFixture)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 MessageFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture)2 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 Module (com.intellij.openapi.module.Module)1