Search in sources :

Example 1 with CreateResourceFileDialogFixture

use of com.android.tools.idea.tests.gui.framework.fixture.CreateResourceFileDialogFixture 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();
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) CreateResourceFileDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.CreateResourceFileDialogFixture) Test(org.junit.Test)

Aggregations

CreateResourceFileDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.CreateResourceFileDialogFixture)1 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)1 Test (org.junit.Test)1