Search in sources :

Example 1 with EditorFixture

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

the class RefactoringFlowTest method testWarnOverridingExternal.

@Test()
public void testWarnOverridingExternal() throws Exception {
    // Try to override a resource that is only defined in an external
    // library; check that we get an error message. Then try to override
    // a resource that is both overridden locally and externally, and
    // check that we get a warning dialog. And finally try to override
    // a resource that is only defined locally and make sure there is
    // no dialog.
    guiTest.importProjectAndWaitForProjectSyncToFinish("LayoutTest");
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/main/res/values/override.xml");
    // <string name="abc_searchview_description_submit">@string/abc_searchview_description_voice</string>
    // only defined in appcompat
    editor.moveBetween("abc_searchview_", "description_voice");
    guiTest.ideFrame().invokeMenuPath("Refactor", "Rename...");
    RenameRefactoringDialogFixture refactoringDialog = RenameRefactoringDialogFixture.find(guiTest.robot());
    refactoringDialog.setNewName("a");
    refactoringDialog.clickRefactor();
    ConflictsDialogFixture conflictsDialog = ConflictsDialogFixture.find(guiTest.robot());
    String text = conflictsDialog.getText().replace("\n", "");
    assertThat(text).matches(Pattern.quote("Resource is also only defined in external libraries and" + "cannot be renamed.Unhandled references:") + VALUE_REGEX + Pattern.quote("...(Additional results truncated)"));
    conflictsDialog.clickCancel();
    refactoringDialog.clickCancel();
    // Now try to rename @string/abc_searchview_description_submit which is defined in *both* appcompat and locally
    // only defined in appcompat
    editor.moveBetween("abc_searchview_", "description_submit");
    guiTest.ideFrame().invokeMenuPath("Refactor", "Rename...");
    refactoringDialog = RenameRefactoringDialogFixture.find(guiTest.robot());
    refactoringDialog.setNewName("a");
    refactoringDialog.clickRefactor();
    conflictsDialog = ConflictsDialogFixture.find(guiTest.robot());
    text = conflictsDialog.getText().replace("\n", "");
    assertThat(text).matches(Pattern.quote("The resource @string/abc_searchview_description_submit is" + "defined outside of the project (in one of the libraries) and" + "cannot be updated. This can change the behavior of the" + "application.Are you sure you want to do this?Unhandled references:") + VALUE_REGEX + Pattern.quote("...(Additional results truncated)"));
    conflictsDialog.clickCancel();
    refactoringDialog.clickCancel();
}
Also used : RenameRefactoringDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) ConflictsDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture.ConflictsDialogFixture) Test(org.junit.Test)

Example 2 with EditorFixture

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

the class TestManifestTest method testManifest.

@Test
public void testManifest() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("ProjectWithUnitTests");
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/main/AndroidManifest.xml", EditorFixture.Tab.EDITOR);
    editor.waitForCodeAnalysisHighlightCount(HighlightSeverity.ERROR, 0);
    editor.select("(\\.MainActivity)");
    // TestActivity shouldn't be accessible from the main AndroidManifest.xml
    editor.enterText(".TestActivity");
    // Close the auto-completion window
    editor.invokeAction(EditorFixture.EditorAction.ESCAPE);
    editor.waitForCodeAnalysisHighlightCount(HighlightSeverity.ERROR, 1);
    // but it should be from the test manifest
    editor.open("app/src/test/AndroidManifest.xml");
    editor.waitForCodeAnalysisHighlightCount(HighlightSeverity.ERROR, 0);
    editor.select("(\\.TestActivity)");
    editor.enterText(".MainActivity2");
    // Make sure we trigger the highlighting error
    editor.waitForCodeAnalysisHighlightCount(HighlightSeverity.ERROR, 1);
    // Remove the number "2". That should bring the errors back to 0
    editor.invokeAction(EditorFixture.EditorAction.BACK_SPACE);
    editor.waitForCodeAnalysisHighlightCount(HighlightSeverity.ERROR, 0);
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) Test(org.junit.Test)

Example 3 with EditorFixture

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

the class CreateResourceTest method testLibraryPrefix.

@Test
public void testLibraryPrefix() throws IOException {
    // Tests creating a new resource in a library project with a predefined library prefix,
    // and makes sure the prefix is correct, including checking that we don't end up with
    // double prefixes as described in issue http://b.android.com/77421.
    guiTest.importProjectAndWaitForProjectSyncToFinish("LayoutTest");
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("lib/src/main/java/com/android/tools/test/mylibrary/LibraryActivity.java");
    editor.select("R.layout.(activity_library)");
    editor.invokeAction(EditorFixture.EditorAction.BACK_SPACE);
    // text now says setContentView(R.layout.x), a missing layout
    editor.enterText("x");
    // Wait for symbol to be marked as unrecognized
    editor.waitForCodeAnalysisHighlightCount(HighlightSeverity.ERROR, 1);
    editor.invokeQuickfixAction("Create layout resource file");
    CreateResourceFileDialogFixture dialog = CreateResourceFileDialogFixture.find(guiTest.robot());
    // Should automatically prepend library prefix lib1:
    dialog.requireName("lib1_x.xml");
    dialog.clickCancel();
    // Now make sure we don't enter it if we already use that prefix
    editor.invokeAction(EditorFixture.EditorAction.BACK_SPACE);
    editor.enterText("lib1_y");
    // Wait for symbol to be marked as unrecognized
    editor.waitForCodeAnalysisHighlightCount(HighlightSeverity.ERROR, 1);
    editor.invokeQuickfixAction("Create layout resource file");
    dialog = CreateResourceFileDialogFixture.find(guiTest.robot());
    // Should automatically prepend library prefix lib1:
    dialog.requireName("lib1_y.xml");
    dialog.clickCancel();
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) CreateResourceFileDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.CreateResourceFileDialogFixture) Test(org.junit.Test)

Example 4 with EditorFixture

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

the class BasicNativeDebuggerTest method openAndToggleBreakPoints.

/**
   * Toggles breakpoints at {@code lines} of the source file {@code fileName}.
   */
private void openAndToggleBreakPoints(String fileName, String[] lines) {
    EditorFixture editor = guiTest.ideFrame().getEditor().open(fileName);
    for (String line : lines) {
        editor.moveBetween("", line);
        editor.invokeAction(EditorFixture.EditorAction.TOGGLE_LINE_BREAKPOINT);
    }
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)

Example 5 with EditorFixture

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

the class GradleTestArtifactSyncTest method testTestFileBackground.

@Test
public void testTestFileBackground() throws Exception {
    guiTest.importSimpleApplication();
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/test/java/google/simpleapplication/UnitTest.java");
    TabLabel tabLabel = findTab(editor);
    Color green = new JBColor(new Color(231, 250, 219), new Color(0x425444));
    assertEquals(green, tabLabel.getInfo().getTabColor());
// TODO re-enable following code when we fix background color support
//editor.close();
//editor.open("app/src/androidTest/java/google/simpleapplication/ApplicationTest.java");
//tabLabel = findTab(editor);
//Color blue = new JBColor(new Color(0xdcf0ff), new Color(0x3C476B));
//assertEquals(blue, tabLabel.getInfo().getTabColor());
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) JBColor(com.intellij.ui.JBColor) TabLabel(com.intellij.ui.tabs.impl.TabLabel) JBColor(com.intellij.ui.JBColor)

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