use of com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture 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.RenameRefactoringDialogFixture in project android by JetBrains.
the class ThemeSelectorTest method testRenameTheme.
/**
* Tests the theme renaming functionality of the theme selector
* and that IntelliJ's Undo works can revert this action
*/
@Ignore("go/studio-builder/builders/ubuntu-studio-master-dev-uitests/builds/257")
@Test
public void testRenameTheme() throws IOException {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(ideFrame);
final JComboBoxFixture themesComboBox = themeEditor.getThemesComboBox();
themesComboBox.selectItem("Rename AppTheme");
RenameRefactoringDialogFixture renameRefactoringDialog = RenameRefactoringDialogFixture.find(guiTest.robot());
renameRefactoringDialog.setNewName("NewAppTheme").clickRefactor();
themeEditor.waitForThemeSelection("NewAppTheme");
themesComboBox.requireSelection("NewAppTheme");
List<String> themeList = themeEditor.getThemesList();
assertThat(themeList).hasSize(9);
assertThat(themeList.get(0)).isEqualTo("NewAppTheme");
assertThat(themeList.get(8)).isEqualTo("Rename NewAppTheme");
guiTest.robot().waitForIdle();
// AppCompat is read-only, being a library theme
themesComboBox.selectItem("Theme.AppCompat.NoActionBar");
themeList = themeEditor.getThemesList();
assertThat(themeList).hasSize(8);
assertThat(themeList.get(0)).isEqualTo("NewAppTheme");
assertThat(themeList.get(3)).isEqualTo("Theme.AppCompat.Light.NoActionBar");
assertThat(themeList.get(4)).isEqualTo("Theme.AppCompat.NoActionBar");
assertThat(themeList.get(5)).isEqualTo("Show all themes");
assertThat(themeList.get(7)).isEqualTo("Create New Theme");
EditorFixture editor = ideFrame.invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab").getEditor();
assertThat(editor.getCurrentFileContents()).doesNotContain("name=\"AppTheme");
editor.moveBetween("", "name=\"NewAppTheme");
assertThat(editor.getCurrentLine().trim()).isEqualTo("<style name=\"NewAppTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\">");
// Testing Undo
ideFrame.invokeMenuPath("Window", "Editor Tabs", "Select Next Tab");
themesComboBox.selectItem("NewAppTheme");
ideFrame.invokeMenuPath("Edit", "Undo Renaming attribute value AppTh...").findMessageDialog("Undo").clickOk();
themeEditor.waitForThemeSelection("AppTheme");
// required to ensure that the Select Previous Tab action is available
themeEditor.focus();
ideFrame.invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab");
assertThat(editor.getCurrentFileContents()).doesNotContain("name=\"NewAppTheme");
editor.moveBetween("", "name=\"AppTheme");
assertThat(editor.getCurrentLine().trim()).isEqualTo("<style name=\"AppTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\">");
}
use of com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture in project android by JetBrains.
the class RefactoringFlowTest method testResourceConflict.
@Test
public void testResourceConflict() throws IOException {
// Try to rename a resource to an existing resource; check that
// you get a warning in the conflicts dialog first
guiTest.importSimpleApplication();
EditorFixture editor = guiTest.ideFrame().getEditor();
editor.open("app/src/main/res/values/strings.xml");
editor.moveBetween("hello", "_world");
guiTest.ideFrame().invokeMenuPath("Refactor", "Rename...");
// Rename as action_settings, which is already defined
RenameRefactoringDialogFixture refactoringDialog = RenameRefactoringDialogFixture.find(guiTest.robot());
refactoringDialog.setNewName("action_settings");
refactoringDialog.clickRefactor();
ConflictsDialogFixture conflictsDialog = ConflictsDialogFixture.find(guiTest.robot());
assertThat(conflictsDialog.getText()).contains("Resource @string/action_settings already exists");
conflictsDialog.clickCancel();
refactoringDialog.clickCancel();
}
Aggregations