Search in sources :

Example 6 with TableCell

use of org.fest.swing.data.TableCell in project ats-framework by Axway.

the class SwingTable method selectCells.

/**
     * Select table cells
     *
     * @param cells the cells coordinates (eg. new int[][]{ { 1, 1 }, { 1, 2 }, { 2, 2 } )
     * @throws VerificationException if the element doesn't exist
     */
@PublicAtsApi
public void selectCells(int[][] cells) {
    new SwingElementState(this).waitToBecomeExisting();
    JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
    try {
        TableCell[] cellsToSelect = new TableCell[cells.length];
        for (int i = 0; i < cells.length; i++) {
            int row = cells[i][0];
            int column = cells[i][1];
            cellsToSelect[i] = new TableCell(row, column) {
            };
        }
        tableFixture.selectCells(cellsToSelect);
    } catch (Exception e) {
        throw new UiElementException(e.getMessage(), this);
    }
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) TableCell(org.fest.swing.data.TableCell) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) VerifyNotEqualityException(com.axway.ats.uiengine.exceptions.VerifyNotEqualityException) VerifyEqualityException(com.axway.ats.uiengine.exceptions.VerifyEqualityException) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 7 with TableCell

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

the class TranslationsEditorTest method enteringTextInTranslationTextFieldUpdatesTableCell.

@Test
public void enteringTextInTranslationTextFieldUpdatesTableCell() {
    JTableFixture table = myTranslationsEditor.getTable();
    TableCell cell = TableCell.row(2).column(3);
    table.selectCell(cell);
    myTranslationsEditor.getTranslationTextField().enterText("cancel_en");
    // Make the Translation text field lose focus
    myTranslationsEditor.getKeyTextField().focus();
    assertEquals("cancel_en", table.valueAt(cell));
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) TableCell(org.fest.swing.data.TableCell) Test(org.junit.Test)

Example 8 with TableCell

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

the class ChooseResourceDialogTest method testColorPickerAlpha.

/**
   * Test that the alpha slider and the textfield are hidden when we are not in ARGB.
   */
@Test
public void testColorPickerAlpha() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    TableCell cell = row(1).column(0);
    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());
    ColorPickerFixture colorPicker = dialog.getColorPicker();
    Color color = new Color(200, 0, 0, 200);
    colorPicker.setFormat("ARGB");
    colorPicker.setColorWithIntegers(color);
    JTextComponentFixture alphaLabel = colorPicker.getLabel("A:");
    SlideFixture alphaSlide = colorPicker.getAlphaSlide();
    alphaLabel.requireVisible();
    alphaSlide.requireVisible();
    colorPicker.setFormat("RGB");
    alphaLabel.requireNotVisible();
    alphaSlide.requireNotVisible();
    colorPicker.setFormat("HSB");
    alphaLabel.requireNotVisible();
    alphaSlide.requireNotVisible();
    dialog.clickOK();
    colorCell.stopEditing();
}
Also used : SlideFixture(com.android.tools.idea.tests.gui.framework.fixture.SlideFixture) TableCell(org.fest.swing.data.TableCell) ChooseResourceDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ChooseResourceDialogFixture) ColorPickerFixture(com.android.tools.idea.tests.gui.framework.fixture.ColorPickerFixture) Test(org.junit.Test)

Example 9 with TableCell

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

the class ChooseResourceDialogTest method testColorStateList.

@Test
public void testColorStateList() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("StateListApplication");
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    TableCell cell = row(7).column(0);
    FontFixture cellFont = themeEditorTable.fontAt(cell);
    cellFont.requireBold();
    assertEquals("android:textColorPrimary", themeEditorTable.attributeNameAt(cell));
    assertEquals("@color/text_color", themeEditorTable.valueAt(cell));
    JTableCellFixture stateListCell = themeEditorTable.cell(cell);
    ResourceComponentFixture resourceComponent = new ResourceComponentFixture(guiTest.robot(), (ResourceComponent) stateListCell.editor());
    stateListCell.startEditing();
    resourceComponent.getSwatchButton().click();
    final ChooseResourceDialogFixture dialog = ChooseResourceDialogFixture.find(guiTest.robot());
    StateListPickerFixture stateListPicker = dialog.getStateListPicker();
    java.util.List<StateListComponentFixture> states = stateListPicker.getStateComponents();
    assertThat(states).hasSize(4);
    final StateListComponentFixture state0 = states.get(0);
    assertEquals("Not enabled", state0.getStateName());
    assertEquals("?android:attr/colorForeground", state0.getValue());
    assertFalse(state0.getValueComponent().hasWarningIcon());
    assertTrue(state0.isAlphaVisible());
    assertEquals("@dimen/text_alpha", state0.getAlphaValue());
    assertFalse(state0.getAlphaComponent().hasWarningIcon());
    final StateListComponentFixture state1 = states.get(1);
    assertEquals("Checked", state1.getStateName());
    assertEquals("#5034FAB2", state1.getValue());
    assertFalse(state1.getValueComponent().hasWarningIcon());
    assertFalse(state1.isAlphaVisible());
    final StateListComponentFixture state2 = states.get(2);
    assertEquals("Pressed", state2.getStateName());
    assertEquals("@color/invalidColor", state2.getValue());
    assertTrue(state2.getValueComponent().hasWarningIcon());
    assertFalse(state2.isAlphaVisible());
    final StateListComponentFixture state3 = states.get(3);
    assertEquals("Default", state3.getStateName());
    assertEquals("?attr/myColorAttribute", state3.getValue());
    assertFalse(state3.getValueComponent().hasWarningIcon());
    assertFalse(state3.isAlphaVisible());
    dialog.waitForErrorLabel();
    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 10 with TableCell

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

the class ThemeEditorTableTest method testResettingColorAttribute.

/**
   * @see com.android.tools.idea.editors.theme.ThemeEditorTable#getPopupMenuAtCell(int, int)
   */
@Test
public void testResettingColorAttribute() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    final ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    final 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();
    resourceComponent.getSwatchButton().click();
    ChooseResourceDialogFixture dialog = ChooseResourceDialogFixture.find(guiTest.robot());
    Color color = new Color(200, 0, 0, 200);
    dialog.getColorPicker().setColorWithIntegers(color);
    dialog.clickOK();
    themeEditorTable.requireValueAt(cell, "@color/holo_light_primary");
    colorCell.startEditing();
    JPopupMenuFixture popupMenu = resourceComponent.showPopupMenu();
    popupMenu.menuItemWithPath("Reset value").click();
    themeEditorTable.requireValueAt(cell, "@android:color/holo_light_primary");
}
Also used : TableCell(org.fest.swing.data.TableCell) Test(org.junit.Test)

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