Search in sources :

Example 6 with EditorFixture

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

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

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

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

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

the class AndroidSdkSourceAttachTest method testRefreshSdkSource.

@Ignore("failed in http://go/aj/job/studio-ui-test/417 and from IDEA")
@Test
public void testRefreshSdkSource() throws IOException {
    assumeTrue("Android Sdk Source for '" + mySdk.getName() + "' must be installed before running 'testRefreshSdkSource'", mySdkSourcePath.isDirectory());
    SdkModificator sdkModificator = mySdk.getSdkModificator();
    sdkModificator.removeRoots(OrderRootType.SOURCES);
    sdkModificator.commitChanges();
    guiTest.importSimpleApplication();
    final EditorFixture editor = guiTest.ideFrame().getEditor();
    final VirtualFile classFile = findActivityClassFile();
    editor.open(classFile, EditorFixture.Tab.EDITOR);
    acceptLegalNoticeIfNeeded();
    // Refresh the source.
    editor.awaitNotification("Sources for '" + mySdk.getName() + "' not found.").performAction("Refresh (if already downloaded)");
    Wait.seconds(1).expecting("source file to be opened").until(() -> !classFile.equals(editor.getCurrentFile()));
    assertIsActivityJavaFile(editor.getCurrentFile());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)41 Test (org.junit.Test)37 IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)9 Ignore (org.junit.Ignore)7 GradleBuildModelFixture (com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture)6 NlComponentFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture)6 NlEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture)6 ArtifactDependencySpec (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencySpec)4 MergedManifestFixture (com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture)4 RunIn (com.android.tools.idea.tests.gui.framework.RunIn)3 RenameRefactoringDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 DialogFixture (org.fest.swing.fixture.DialogFixture)3 JButtonFixture (org.fest.swing.fixture.JButtonFixture)3 JTreeFixture (org.fest.swing.fixture.JTreeFixture)3 ExpectedModuleDependency (com.android.tools.idea.gradle.dsl.model.dependencies.ExpectedModuleDependency)2 ChooseResourceDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ChooseResourceDialogFixture)2 ConflictsDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture.ConflictsDialogFixture)2 ThemeEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture)2 Project (com.intellij.openapi.project.Project)2