Search in sources :

Example 6 with GradleBuildModelFixture

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

the class AddGradleDependencyTest method testAddJetbrainsAnnotationDependency.

@Test
public void testAddJetbrainsAnnotationDependency() throws IOException {
    guiTest.importSimpleApplication();
    EditorFixture editor = guiTest.ideFrame().getEditor().open("app/src/main/java/google/simpleapplication/MyActivity.java");
    editor.moveBetween("onCreate(", "Bundle savedInstanceState) {");
    editor.enterText("\n@NotNull ");
    editor.waitForCodeAnalysisHighlightCount(ERROR, 1);
    editor.moveBetween("@Not", "Null ");
    editor.invokeQuickfixAction("Add 'annotations-java5' to classpath");
    guiTest.ideFrame().waitForGradleProjectSyncToFinish();
    editor.waitForCodeAnalysisHighlightCount(ERROR, 0);
    GradleBuildModelFixture appBuildModel = guiTest.ideFrame().parseBuildFileForModule("app");
    ArtifactDependencySpec expected = new ArtifactDependencySpec("annotations-java5", "org.jetbrains", "15.0");
    appBuildModel.requireDependency(COMPILE, expected);
    // Undo the import statement first
    editor.invokeAction(UNDO);
    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 7 with GradleBuildModelFixture

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

the class AddGradleDependencyTest method testAddJUnitDependency.

@RunIn(TestGroup.UNRELIABLE)
@Test
public void testAddJUnitDependency() throws IOException {
    EditorFixture editor = guiTest.importSimpleApplication().getEditor().open("app/build.gradle").moveBetween("testCompile", "").invokeAction(DELETE_LINE).getIdeFrame().requestProjectSync().getEditor().open("app/src/test/java/google/simpleapplication/UnitTest.java").waitForCodeAnalysisHighlightCount(ERROR, 6).moveBetween("@", "Test").invokeQuickfixAction("Add 'JUnit4' to classpath").getIdeFrame().waitForGradleProjectSyncToFinish().getEditor().waitForCodeAnalysisHighlightCount(ERROR, 0);
    GradleBuildModelFixture appBuildModel = guiTest.ideFrame().parseBuildFileForModule("app");
    ArtifactDependencySpec expected = new ArtifactDependencySpec("junit", "junit", "4.12");
    appBuildModel.requireDependency(TEST_COMPILE, expected);
    verifyUndo(editor, 6);
}
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 8 with GradleBuildModelFixture

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

the class IdeFrameFixture method parseBuildFileForModule.

@NotNull
public GradleBuildModelFixture parseBuildFileForModule(@NotNull String moduleName) {
    Module module = getModule(moduleName);
    VirtualFile buildFile = getGradleBuildFile(module);
    Ref<GradleBuildModel> buildModelRef = new Ref<>();
    new ReadAction() {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            buildModelRef.set(GradleBuildModel.parseBuildFile(buildFile, getProject()));
        }
    }.execute();
    return new GradleBuildModelFixture(buildModelRef.get());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Ref(com.intellij.openapi.util.Ref) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ReadAction(com.intellij.openapi.application.ReadAction) Module(com.intellij.openapi.module.Module) Result(com.intellij.openapi.application.Result) GradleInvocationResult(com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult) GradleBuildModelFixture(com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

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