Search in sources :

Example 1 with ConflictsDialogFixture

use of com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture.ConflictsDialogFixture 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 ConflictsDialogFixture

use of com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture.ConflictsDialogFixture 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();
}
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)

Aggregations

EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)2 RenameRefactoringDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture)2 ConflictsDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture.ConflictsDialogFixture)2 Test (org.junit.Test)2