use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture 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()));
}
use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture in project android by JetBrains.
the class ManifestEditorTest method testRemoveFromManifest.
@Test
public void testRemoveFromManifest() throws IOException {
guiTest.importMultiModule();
IdeFrameFixture projectFrame = guiTest.ideFrame();
EditorFixture editor = projectFrame.getEditor();
editor.open("app/src/main/AndroidManifest.xml");
String addedText = " <activity\n" + " android:name=\"com.android.mylibrary.MainActivity\"\n" + " tools:remove=\"android:label\" />\n";
assertThat(editor.getCurrentFileContents()).doesNotContain(addedText);
editor.selectEditorTab(EditorFixture.Tab.MERGED_MANIFEST);
MergedManifestFixture mergedManifestFixture = editor.getMergedManifestEditor();
JTreeFixture tree = mergedManifestFixture.getTree();
// row 28 = "manifest/application/activity/android:name = com.android.mylibrary.MainActivity"
JPopupMenuFixture popup = tree.showPopupMenuAt(22);
popup.menuItemWithPath("Remove").click();
editor.selectEditorTab(EditorFixture.Tab.EDITOR);
assertThat(editor.getCurrentFileContents()).contains(addedText);
}
use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture in project android by JetBrains.
the class ManifestEditorTest method testManifestGoToSource.
@Test
public void testManifestGoToSource() throws IOException {
guiTest.importSimpleApplication();
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();
tree.clickPath("manifest/application/android:allowBackup = true");
mergedManifestFixture.checkAllRowsColored();
Color defaultBackgroundColor = mergedManifestFixture.getDefaultBackgroundColor();
assertEquals(defaultBackgroundColor, mergedManifestFixture.getSelectedNodeColor());
mergedManifestFixture.clickLinkText("app main manifest (this file), line 5");
assertThat(editor.getCurrentLine().trim()).isEqualTo("android:allowBackup=\"true\"");
}
use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture in project android by JetBrains.
the class NlPreviewTest method testCopyAndPaste.
@Test
public void testCopyAndPaste() throws Exception {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
EditorFixture editor = ideFrame.getEditor().open("app/src/main/res/layout/activity_my.xml", EditorFixture.Tab.EDITOR);
NlPreviewFixture layout = editor.getLayoutPreview(true);
layout.dragComponentToSurface("Widgets", "Button").dragComponentToSurface("Widgets", "CheckBox").waitForRenderToFinish();
// Find and click the first text view
NlComponentFixture checkBox = layout.findView("CheckBox", 0);
checkBox.click();
// It should be selected now
layout.requireSelection(Collections.singletonList(checkBox));
// 4 = root layout + 3 widgets
assertEquals(4, layout.getAllComponents().size());
ideFrame.invokeMenuPath("Edit", "Cut");
assertEquals(3, layout.getAllComponents().size());
layout.findView("Button", 0).click();
ideFrame.invokeMenuPath("Edit", "Paste");
layout.findView("CheckBox", 0).click();
ideFrame.invokeMenuPath("Edit", "Copy");
ideFrame.invokeMenuPath("Edit", "Paste");
assertEquals(5, layout.getAllComponents().size());
}
Aggregations