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);
}
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);
}
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());
}
Aggregations