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