Search in sources :

Example 21 with TableCell

use of org.fest.swing.data.TableCell in project android by JetBrains.

the class ThemeEditorTableTest method testShowDocumentation.

/**
   * @see com.android.tools.idea.editors.theme.attributes.ShowJavadocAction
   */
@Test
public void testShowDocumentation() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    TableCell cell = row(1).column(0);
    assertEquals("android:colorPrimary", themeEditorTable.attributeNameAt(cell));
    assertEquals("@android:color/holo_light_primary", themeEditorTable.valueAt(cell));
    JTableCellFixture colorCell = themeEditorTable.cell(cell);
    ResourceComponentFixture resourceComponent = new ResourceComponentFixture(guiTest.robot(), (ResourceComponent) colorCell.editor());
    colorCell.startEditing();
    JPopupMenuFixture popupMenu = resourceComponent.showPopupMenu();
    popupMenu.menuItemWithPath("Show documentation").click();
    JWindow docWindow = GuiTests.waitUntilShowing(guiTest.robot(), Matchers.byType(JWindow.class));
    JEditorPane docComp = guiTest.robot().finder().findByType(docWindow, JEditorPane.class);
    JTextComponentFixture quickDoc = new JTextComponentFixture(guiTest.robot(), docComp);
    String expected = "<html>\n" + "  <head>\n" + "    <font size=\"3\">\n" + "</font>  </head>\n" + "  <body>\n" + "    <b><font size=\"3\">android:colorPrimary</font></b><font size=\"3\"> (Added in \n" + "    API level 21)<br>The primary branding color for the app. By default, this \n" + "    is the color applied to the action bar background.<br><hr>\n" + "</font>\n" + "    <table border=\"0\" align=\"center\" style=\"background-color: rgb(230,230,230); width: 200px\">\n" + "      <tr height=\"100\">\n" + "        <td align=\"center\" valign=\"middle\" height=\"100\">\n" + "          <font size=\"3\">#e6e6e6\n" + "</font>        </td>\n" + "      </tr>\n" + "    </table>\n" + "    <font size=\"3\"><br>\n" + "    <br>\n" + "    ?android:attr/colorPrimary =&gt; @color/holo_light_primary =&gt; #ffe6e6e6<br><br></font>\n" + "  </body>\n" + "</html>\n";
    quickDoc.requireText(expected);
}
Also used : TableCell(org.fest.swing.data.TableCell) Test(org.junit.Test)

Example 22 with TableCell

use of org.fest.swing.data.TableCell in project android by JetBrains.

the class ThemeSelectorTest method testCreateNewTheme.

/**
   * Tests the theme creation functionality of the theme selector
   * and that IntelliJ's Undo can revert this action
   */
@Test
public void testCreateNewTheme() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    JComboBoxFixture themesComboBox = themeEditor.getThemesComboBox();
    String selectedTheme = themesComboBox.selectedItem();
    themesComboBox.selectItem("Create New Theme");
    NewStyleDialogFixture newStyleDialog = NewStyleDialogFixture.find(guiTest.robot());
    newStyleDialog.clickCancel();
    themeEditor.waitForThemeSelection(selectedTheme);
    themesComboBox.selectItem("Create New Theme");
    newStyleDialog = NewStyleDialogFixture.find(guiTest.robot());
    JTextComponentFixture newNameTextField = newStyleDialog.getNewNameTextField();
    JComboBoxFixture parentComboBox = newStyleDialog.getParentComboBox();
    parentComboBox.requireSelection("AppTheme");
    String[] parentsArray = parentComboBox.contents();
    // The expected elements are:
    // 0. AppTheme
    // 1. -- Separator
    // 2. AppCompat Light
    // 3. AppCompat
    // 4. -- Separator
    // 5. Show all themes
    assertThat(parentsArray).hasLength(6);
    assertThat(parentsArray[0]).isEqualTo("AppTheme");
    assertThat(parentsArray[2]).isEqualTo("Theme.AppCompat.Light.NoActionBar");
    assertThat(parentsArray[3]).isEqualTo("Theme.AppCompat.NoActionBar");
    assertThat(parentsArray[5]).isEqualTo("Show all themes");
    assertThat(parentsArray[1]).startsWith("javax.swing.JSeparator");
    assertThat(parentsArray[4]).startsWith("javax.swing.JSeparator");
    parentComboBox.selectItem("Theme.AppCompat.NoActionBar");
    newNameTextField.requireText("Theme.AppTheme.NoActionBar");
    parentComboBox.selectItem("Show all themes");
    ThemeSelectionDialogFixture themeSelectionDialog = ThemeSelectionDialogFixture.find(guiTest.robot());
    JTreeFixture categoriesTree = themeSelectionDialog.getCategoriesTree();
    JListFixture themeList = themeSelectionDialog.getThemeList();
    categoriesTree.clickRow(5);
    themeList.clickItem(0);
    themeList.requireSelection("android:Theme.Holo");
    themeSelectionDialog.clickOk();
    parentComboBox.requireSelection("android:Theme.Holo");
    newNameTextField.requireText("Theme.AppTheme");
    newNameTextField.deleteText().enterText("NewTheme");
    newStyleDialog.clickOk();
    themeEditor.waitForThemeSelection("NewTheme");
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    TableCell parentCell = row(0).column(0);
    assertEquals("android:Theme.Holo", themeEditorTable.getComboBoxSelectionAt(parentCell));
    // required to ensure that the Select Previous Tab action is available
    themeEditor.focus();
    EditorFixture editor = guiTest.ideFrame().invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab").getEditor();
    assertThat(editor.getCurrentFileContents()).contains("name=\"AppTheme");
    editor.moveBetween("", "name=\"NewTheme");
    assertThat(editor.getCurrentLine().trim()).isEqualTo("<style name=\"NewTheme\" parent=\"android:Theme.Holo\" />");
    // Tests Undo
    guiTest.ideFrame().invokeMenuPath("Window", "Editor Tabs", "Select Next Tab").invokeMenuPath("Edit", "Undo Create new style NewTheme");
    themeEditor.waitForThemeSelection("AppTheme");
    guiTest.ideFrame().invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab");
    assertThat(editor.getCurrentFileContents()).doesNotContain("name=\"NewTheme");
}
Also used : ThemeSelectionDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) TableCell(org.fest.swing.data.TableCell) NewStyleDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.NewStyleDialogFixture) ThemeEditorTableFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorTableFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) Test(org.junit.Test)

Example 23 with TableCell

use of org.fest.swing.data.TableCell in project android by JetBrains.

the class ChooseResourceDialogTest method testEditColorReference.

@Test
public void testEditColorReference() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("StateListApplication");
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    TableCell cell = row(1).column(0);
    FontFixture cellFont = themeEditorTable.fontAt(cell);
    cellFont.requireBold();
    assertEquals("android:colorPrimary", themeEditorTable.attributeNameAt(cell));
    assertEquals("@color/ref_color", themeEditorTable.valueAt(cell));
    JTableCellFixture stateListCell = themeEditorTable.cell(cell);
    ResourceComponentFixture resourceComponent = new ResourceComponentFixture(guiTest.robot(), (ResourceComponent) stateListCell.editor());
    stateListCell.startEditing();
    resourceComponent.getSwatchButton().click();
    ChooseResourceDialogFixture dialog = ChooseResourceDialogFixture.find(guiTest.robot());
    SwatchComponentFixture state1 = dialog.getEditReferencePanel().getSwatchComponent();
    assertEquals("@color/myColor", state1.getText());
    assertFalse(state1.hasWarningIcon());
    dialog.clickCancel();
    stateListCell.stopEditing();
}
Also used : TableCell(org.fest.swing.data.TableCell) ChooseResourceDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ChooseResourceDialogFixture) Test(org.junit.Test)

Example 24 with TableCell

use of org.fest.swing.data.TableCell in project android by JetBrains.

the class ThemeEditorTableTest method testSettingColorAttribute.

@Test
public void testSettingColorAttribute() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    TableCell cell = row(1).column(0);
    FontFixture cellFont = themeEditorTable.fontAt(cell);
    cellFont.requireNotBold();
    assertEquals("android:colorPrimary", themeEditorTable.attributeNameAt(cell));
    assertEquals("@android:color/holo_light_primary", themeEditorTable.valueAt(cell));
    JTableCellFixture colorCell = themeEditorTable.cell(cell);
    ResourceComponentFixture resourceComponent = new ResourceComponentFixture(guiTest.robot(), (ResourceComponent) colorCell.editor());
    colorCell.startEditing();
    resourceComponent.getSwatchButton().click();
    ChooseResourceDialogFixture dialog = ChooseResourceDialogFixture.find(guiTest.robot());
    Color color = new Color(200, 0, 0, 200);
    dialog.getColorPicker().setColorWithIntegers(color);
    dialog.clickOK();
    colorCell.stopEditing();
    themeEditorTable.requireValueAt(cell, "@color/holo_light_primary");
    cellFont = themeEditorTable.fontAt(cell);
    cellFont.requireBold();
    assertEquals("android:colorPrimary", themeEditorTable.attributeNameAt(cell));
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/main/res/values/colors.xml");
    editor.moveBetween("", "holo");
    assertThat(editor.getCurrentLine().trim()).isEqualTo("<color name=\"holo_light_primary\">" + ResourceHelper.colorToString(color) + "</color>");
}
Also used : TableCell(org.fest.swing.data.TableCell) Test(org.junit.Test)

Example 25 with TableCell

use of org.fest.swing.data.TableCell in project android by JetBrains.

the class BuildVariantsToolWindowFixture method selectVariantForModule.

@NotNull
public BuildVariantsToolWindowFixture selectVariantForModule(@NotNull final String module, @NotNull String variant) {
    activate();
    Content[] contents = myToolWindow.getContentManager().getContents();
    assertThat(contents.length).isAtLeast(1);
    Content content = contents[0];
    JTable variantsTable = myRobot.finder().findByType(content.getComponent(), JTable.class, true);
    final String moduleColumnText = "Module: '" + module + "'";
    JTableFixture table = new JTableFixture(myRobot, variantsTable);
    JTableCellFixture moduleCell = table.cell((jTable, cellReader) -> {
        int rowCount = jTable.getRowCount();
        for (int i = 0; i < rowCount; i++) {
            int moduleColumnIndex = 0;
            String currentModule = cellReader.valueAt(jTable, i, moduleColumnIndex);
            if (moduleColumnText.equals(currentModule)) {
                return row(i).column(moduleColumnIndex);
            }
        }
        throw new AssertionError("Failed to find module '" + module + "' in 'Build Variants' view");
    });
    TableCell variantCellCoordinates = row(moduleCell.row()).column(1);
    String selectedVariant = table.valueAt(variantCellCoordinates);
    if (!variant.equals(selectedVariant)) {
        // Attempt to select variant if it is not already selected.
        JTableCellFixture variantCell = table.cell(variantCellCoordinates);
        variantCell.enterValue(variant);
        myProjectFrame.waitForBuildToFinish(BuildMode.SOURCE_GEN);
    }
    return this;
}
Also used : JTableCellFixture(org.fest.swing.fixture.JTableCellFixture) JTableFixture(org.fest.swing.fixture.JTableFixture) TableCell(org.fest.swing.data.TableCell) Content(com.intellij.ui.content.Content) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TableCell (org.fest.swing.data.TableCell)26 JTableFixture (org.fest.swing.fixture.JTableFixture)15 PublicAtsApi (com.axway.ats.common.PublicAtsApi)12 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)12 Test (org.junit.Test)12 NotSupportedOperationException (com.axway.ats.uiengine.exceptions.NotSupportedOperationException)7 UiElementException (com.axway.ats.uiengine.exceptions.UiElementException)7 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)6 VerifyEqualityException (com.axway.ats.uiengine.exceptions.VerifyEqualityException)6 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)6 ChooseResourceDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ChooseResourceDialogFixture)3 ResourceComponent (com.android.tools.idea.editors.theme.ui.ResourceComponent)2 JTableCellFixture (org.fest.swing.fixture.JTableCellFixture)2 NotNull (org.jetbrains.annotations.NotNull)2 ColorPickerFixture (com.android.tools.idea.tests.gui.framework.fixture.ColorPickerFixture)1 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)1 SlideFixture (com.android.tools.idea.tests.gui.framework.fixture.SlideFixture)1 ThemeSelectionDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture)1 NewStyleDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.NewStyleDialogFixture)1 ThemeEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture)1