Search in sources :

Example 31 with EditorFixture

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

the class TranslationsEditorTest method setUp.

@Before
public void setUp() throws IOException {
    myGuiTest.importSimpleApplication();
    EditorFixture editor = myGuiTest.ideFrame().getEditor();
    editor.open("app/src/main/res/values/strings.xml", EDITOR).awaitNotification("Edit translations for all locales in the translations editor.").performAction("Open editor");
    GuiTests.waitUntilShowing(myGuiTest.robot(), new GenericTypeMatcher<JTable>(JTable.class) {

        @Override
        protected boolean isMatching(@NotNull JTable table) {
            return table.getModel().getRowCount() != 0;
        }
    });
    myTranslationsEditor = editor.getTranslationsEditor();
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) TranslationsEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.TranslationsEditorFixture) Before(org.junit.Before)

Example 32 with EditorFixture

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

the class AddGradleDependencyTest method testNoModuleDependencyQuickfixFromJavaToAndroid.

@Test
public void testNoModuleDependencyQuickfixFromJavaToAndroid() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultiModule");
    EditorFixture editor = guiTest.ideFrame().getEditor().open("library3/src/main/java/com/example/MyLibrary.java");
    String classToImport = "com.android.multimodule.MainActivity";
    addImport(editor, classToImport);
    editor.waitForCodeAnalysisHighlightCount(ERROR, 1);
    moveCaretToClassName(editor, classToImport);
    editor.waitForQuickfix();
    assertIntentionNotIncluded(editor, "Add dependency on module");
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) Test(org.junit.Test)

Example 33 with EditorFixture

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

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

the class GradleTestArtifactSyncTest method testLoadAllTestArtifacts.

@Test
public void testLoadAllTestArtifacts() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("LoadMultiTestArtifacts");
    EditorFixture editor = guiTest.ideFrame().getEditor();
    Module appModule = guiTest.ideFrame().getModule("app");
    List<String> sourceRootNames = Lists.newArrayList();
    VirtualFile[] sourceRoots = ModuleRootManager.getInstance(appModule).getSourceRoots();
    for (VirtualFile sourceRoot : sourceRoots) {
        // Get the last 2 segments of the path for each source folder (e.g. 'testFree/java')
        String path = sourceRoot.getPath();
        if (path.contains("/app/build/generated/")) {
            // Ignore generated directories
            continue;
        }
        List<String> pathSegments = Splitter.on(VIRTUAL_FILE_PATH_SEPARATOR).omitEmptyStrings().splitToList(path);
        int segmentCount = pathSegments.size();
        assertThat(segmentCount).named("number of segments in path '" + path + "'").isGreaterThan(2);
        String name = Joiner.on(VIRTUAL_FILE_PATH_SEPARATOR).join(pathSegments.get(segmentCount - 2), pathSegments.get(segmentCount - 1));
        sourceRootNames.add(name);
    }
    assertThat(sourceRootNames).containsExactly("testFree/java", "androidTestFree/java", "testDebug/java", "main/res", "main/java", "test/java", "androidTest/java");
    // Refer to the test source file for the reason of unresolved references
    editor.open("app/src/androidTest/java/com/example/ApplicationTest.java");
    assertThat(editor.getHighlights(HighlightSeverity.ERROR)).containsExactly("Cannot resolve symbol 'Assert'", "Cannot resolve symbol 'ExampleUnitTest'", "Cannot resolve symbol 'Lib'");
    editor.moveBetween("Test", "Util util").invokeAction(GOTO_DECLARATION);
    requirePath(editor.getCurrentFile(), "androidTest/java/com/example/TestUtil.java");
    editor.open("app/src/test/java/com/example/UnitTest.java");
    assertThat(editor.getHighlights(HighlightSeverity.ERROR)).containsExactly("Cannot resolve symbol 'Collections2'", "Cannot resolve symbol 'ApplicationTest'");
    editor.moveBetween("Test", "Util util").invokeAction(GOTO_DECLARATION);
    requirePath(editor.getCurrentFile(), "test/java/com/example/TestUtil.java");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) Module(com.intellij.openapi.module.Module)

Example 35 with EditorFixture

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

the class ManifestEditorTest method testEditManifest.

@Test
public void testEditManifest() throws IOException {
    guiTest.importMultiModule();
    IdeFrameFixture projectFrame = guiTest.ideFrame();
    EditorFixture editor = projectFrame.getEditor();
    editor.open("app/src/main/AndroidManifest.xml");
    editor.selectEditorTab(EditorFixture.Tab.MERGED_MANIFEST);
    MergedManifestFixture mergedManifestFixture = editor.getMergedManifestEditor();
    JTreeFixture tree = mergedManifestFixture.getTree();
    mergedManifestFixture.checkAllRowsColored();
    mergedManifestFixture.requireText("Manifest Sources \n" + "\n" + "app main manifest (this file)\n" + "\n" + "library manifest\n" + "\n" + "build.gradle injection", false);
    editor.selectEditorTab(EditorFixture.Tab.EDITOR);
    editor.moveBetween("<application", "");
    editor.enterText(" android:isGame=\"true\"");
    editor.selectEditorTab(EditorFixture.Tab.MERGED_MANIFEST);
    tree.clickPath("manifest/application/android:isGame = true");
    assertEquals("android:isGame = true", tree.valueAt(tree.target().getLeadSelectionRow()));
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) MergedManifestFixture(com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) 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