Search in sources :

Example 1 with GradleBuildModelFixture

use of com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture in project android by JetBrains.

the class AddGradleDependencyTest method testAddTestModuleDependency.

@RunIn(TestGroup.UNRELIABLE)
@Test
public void testAddTestModuleDependency() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultiModule");
    EditorFixture editor = guiTest.ideFrame().getEditor().open("app/src/androidTest/java/com/android/multimodule/ApplicationTest.java");
    String classToImport = "com.example.MyLibrary";
    addImport(editor, classToImport);
    editor.waitForCodeAnalysisHighlightCount(ERROR, 1);
    moveCaretToClassName(editor, classToImport);
    editor.invokeQuickfixAction("Add dependency on module 'library3'");
    guiTest.ideFrame().waitForGradleProjectSyncToFinish();
    editor.waitForCodeAnalysisHighlightCount(ERROR, 0);
    ExpectedModuleDependency dependencyOnLibrary3 = new ExpectedModuleDependency();
    dependencyOnLibrary3.configurationName = ANDROID_TEST_COMPILE;
    dependencyOnLibrary3.path = ":library3";
    GradleBuildModelFixture buildModel = guiTest.ideFrame().parseBuildFileForModule("app");
    buildModel.requireDependency(dependencyOnLibrary3);
    verifyUndo(editor, 1);
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) ExpectedModuleDependency(com.android.tools.idea.gradle.dsl.model.dependencies.ExpectedModuleDependency) GradleBuildModelFixture(com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture) Test(org.junit.Test)

Example 2 with GradleBuildModelFixture

use of com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture in project android by JetBrains.

the class AddGradleDependencyTest method testAddLibDependencyDeclaredInJavaProject.

@RunIn(TestGroup.UNRELIABLE)
@Test
public void testAddLibDependencyDeclaredInJavaProject() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultiModule");
    GradleBuildModelFixture library3BuildModel = guiTest.ideFrame().parseBuildFileForModule("library3");
    ArtifactDependencySpec gson = new ArtifactDependencySpec("gson", "com.google.code.gson", "2.4");
    library3BuildModel.getTarget().dependencies().addArtifact(COMPILE, gson);
    library3BuildModel.applyChanges();
    guiTest.ideFrame().requestProjectSync().waitForGradleProjectSyncToFinish();
    EditorFixture editor = guiTest.ideFrame().getEditor().open("app/src/main/java/com/android/multimodule/MainActivity.java");
    String classToImport = "com.google.gson.Gson";
    addImport(editor, classToImport);
    editor.waitForCodeAnalysisHighlightCount(ERROR, 1);
    moveCaretToClassName(editor, classToImport);
    editor.invokeQuickfixAction("Add library 'gson-2.4' to classpath");
    guiTest.ideFrame().waitForGradleProjectSyncToFinish();
    editor.waitForCodeAnalysisHighlightCount(ERROR, 0);
    GradleBuildModelFixture appBuildModel = guiTest.ideFrame().parseBuildFileForModule("app");
    appBuildModel.requireDependency(COMPILE, gson);
    verifyUndo(editor, 1);
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) GradleBuildModelFixture(com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture) ArtifactDependencySpec(com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencySpec) Test(org.junit.Test)

Example 3 with GradleBuildModelFixture

use of com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture in project android by JetBrains.

the class AddGradleDependencyTest method testAddProdModuleDependency.

@RunIn(TestGroup.UNRELIABLE)
@Test
public void testAddProdModuleDependency() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultiModule");
    EditorFixture editor = guiTest.ideFrame().getEditor().open("app/src/main/java/com/android/multimodule/MainActivity.java");
    String classToImport = "com.example.MyLibrary";
    addImport(editor, classToImport);
    editor.waitForCodeAnalysisHighlightCount(ERROR, 1);
    moveCaretToClassName(editor, classToImport);
    editor.invokeQuickfixAction("Add dependency on module 'library3'");
    guiTest.ideFrame().waitForGradleProjectSyncToFinish();
    editor.waitForCodeAnalysisHighlightCount(ERROR, 0);
    ExpectedModuleDependency dependencyOnLibrary3 = new ExpectedModuleDependency();
    dependencyOnLibrary3.configurationName = COMPILE;
    dependencyOnLibrary3.path = ":library3";
    GradleBuildModelFixture buildModel = guiTest.ideFrame().parseBuildFileForModule("app");
    buildModel.requireDependency(dependencyOnLibrary3);
    verifyUndo(editor, 1);
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) ExpectedModuleDependency(com.android.tools.idea.gradle.dsl.model.dependencies.ExpectedModuleDependency) GradleBuildModelFixture(com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture) Test(org.junit.Test)

Example 4 with GradleBuildModelFixture

use of com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture in project android by JetBrains.

the class AddGradleDependencyTest method testAddLibDependencyDeclaredInAndroidProject.

@RunIn(TestGroup.UNRELIABLE)
@Test
public void testAddLibDependencyDeclaredInAndroidProject() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultiModule");
    GradleBuildModelFixture appBuildModel = guiTest.ideFrame().parseBuildFileForModule("app");
    ArtifactDependencySpec gson = new ArtifactDependencySpec("gson", "com.google.code.gson", "2.4");
    appBuildModel.getTarget().dependencies().addArtifact(COMPILE, gson);
    appBuildModel.applyChanges();
    guiTest.ideFrame().requestProjectSync().waitForGradleProjectSyncToFinish();
    EditorFixture editor = guiTest.ideFrame().getEditor().open("library3/src/main/java/com/example/MyLibrary.java");
    String classToImport = "com.google.gson.Gson";
    addImport(editor, classToImport);
    editor.waitForCodeAnalysisHighlightCount(ERROR, 1);
    moveCaretToClassName(editor, classToImport);
    editor.invokeQuickfixAction("Add library 'gson-2.4' to classpath");
    guiTest.ideFrame().waitForGradleProjectSyncToFinish();
    editor.waitForCodeAnalysisHighlightCount(ERROR, 0);
    verifyUndo(editor, 1);
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) GradleBuildModelFixture(com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture) ArtifactDependencySpec(com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencySpec) Test(org.junit.Test)

Example 5 with GradleBuildModelFixture

use of com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture in project android by JetBrains.

the class GradleRenameModuleTest method testRenameModuleAlsoChangeReferencesInBuildFile.

@Test
public void testRenameModuleAlsoChangeReferencesInBuildFile() throws IOException {
    guiTest.importMultiModule();
    ProjectViewFixture.PaneFixture paneFixture = guiTest.ideFrame().getProjectView().selectProjectPane();
    paneFixture.selectByPath("MultiModule", "library");
    invokeRefactor();
    SelectRefactoringDialogFixture selectRefactoringDialog = SelectRefactoringDialogFixture.findByTitle(guiTest.robot());
    selectRefactoringDialog.selectRenameModule();
    selectRefactoringDialog.clickOk();
    InputDialogFixture renameModuleDialog = InputDialogFixture.findByTitle(guiTest.robot(), "Rename Module");
    renameModuleDialog.enterTextAndClickOk("newLibrary");
    guiTest.waitForBackgroundTasks();
    assertThat(guiTest.ideFrame().hasModule("newLibrary")).named("newLibrary module exists").isTrue();
    // app module has two references to library module
    GradleBuildModelFixture buildModel = guiTest.ideFrame().parseBuildFileForModule("app");
    ExpectedModuleDependency expected = new ExpectedModuleDependency();
    expected.configurationName = "debugCompile";
    expected.path = ":newLibrary";
    buildModel.requireDependency(expected);
    expected.configurationName = "releaseCompile";
    buildModel.requireDependency(expected);
}
Also used : ExpectedModuleDependency(com.android.tools.idea.gradle.dsl.model.dependencies.ExpectedModuleDependency) InputDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.InputDialogFixture) SelectRefactoringDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.SelectRefactoringDialogFixture) ProjectViewFixture(com.android.tools.idea.tests.gui.framework.fixture.ProjectViewFixture) GradleBuildModelFixture(com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture) Test(org.junit.Test)

Aggregations

GradleBuildModelFixture (com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture)8 Test (org.junit.Test)7 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)6 ArtifactDependencySpec (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencySpec)4 ExpectedModuleDependency (com.android.tools.idea.gradle.dsl.model.dependencies.ExpectedModuleDependency)3 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 GradleInvocationResult (com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult)1 InputDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.InputDialogFixture)1 ProjectViewFixture (com.android.tools.idea.tests.gui.framework.fixture.ProjectViewFixture)1 SelectRefactoringDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.SelectRefactoringDialogFixture)1 ReadAction (com.intellij.openapi.application.ReadAction)1 Result (com.intellij.openapi.application.Result)1 Module (com.intellij.openapi.module.Module)1 Ref (com.intellij.openapi.util.Ref)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Assert.assertNotNull (junit.framework.Assert.assertNotNull)1 NotNull (org.jetbrains.annotations.NotNull)1