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