Search in sources :

Example 6 with ChooseResourceDialogFixture

use of com.android.tools.idea.tests.gui.framework.fixture.ChooseResourceDialogFixture in project android by JetBrains.

the class ChooseResourceDialogTest method testResourcePickerNameError.

@Test
public void testResourcePickerNameError() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    // Cell (1,0) should be some color
    JTableCellFixture colorCell = themeEditorTable.cell(row(1).column(0));
    // click on a color
    ResourceComponentFixture resourceComponent = new ResourceComponentFixture(guiTest.robot(), (ResourceComponent) colorCell.editor());
    colorCell.startEditing();
    resourceComponent.getSwatchButton().click();
    final ChooseResourceDialogFixture dialog = ChooseResourceDialogFixture.find(guiTest.robot());
    JTextComponentFixture name = dialog.getNameTextField();
    // add mistake into name field
    String badText = "(";
    name.deleteText();
    name.enterText("color" + badText);
    String text = name.text();
    assertThat(text).endsWith(badText);
    final String expectedError = "<html><font color='#ff0000'><left>'" + badText + "' is not a valid resource name character</left></b></font></html>";
    Wait.seconds(1).expecting("error to update").until(() -> dialog.getError().equals(expectedError));
    dialog.clickCancel();
    colorCell.cancelEditing();
}
Also used : ChooseResourceDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ChooseResourceDialogFixture) GuiTests.listToString(com.android.tools.idea.tests.gui.framework.GuiTests.listToString) GuiTests.tableToString(com.android.tools.idea.tests.gui.framework.GuiTests.tableToString) Test(org.junit.Test)

Aggregations

ChooseResourceDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ChooseResourceDialogFixture)6 Test (org.junit.Test)6 TableCell (org.fest.swing.data.TableCell)3 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)2 NlComponentFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture)2 NlEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture)2 GuiTests.listToString (com.android.tools.idea.tests.gui.framework.GuiTests.listToString)1 GuiTests.tableToString (com.android.tools.idea.tests.gui.framework.GuiTests.tableToString)1 ColorPickerFixture (com.android.tools.idea.tests.gui.framework.fixture.ColorPickerFixture)1 SlideFixture (com.android.tools.idea.tests.gui.framework.fixture.SlideFixture)1 NlPropertyFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlPropertyFixture)1 NlPropertyInspectorFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlPropertyInspectorFixture)1 BufferedImage (java.awt.image.BufferedImage)1