Search in sources :

Example 11 with TableCell

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

the class ThemeEditorTableTest method testResourceCompletion.

/**
   * Test the text completion for attribute values
   */
@Ignore("http://wpie20.hot.corp.google.com:8200/builders/ubuntu-studio-master-dev-uitests/builds/28/")
@Test
public void testResourceCompletion() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    final ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    final TableCell cell = row(3).column(0);
    FontFixture cellFont = themeEditorTable.fontAt(cell);
    cellFont.requireNotBold();
    assertEquals("android:colorBackground", themeEditorTable.attributeNameAt(cell));
    assertEquals("@android:color/background_holo_light", themeEditorTable.valueAt(cell));
    JTableCellFixture tableCell = themeEditorTable.cell(cell);
    ResourceComponentFixture resourceComponent = new ResourceComponentFixture(guiTest.robot(), (ResourceComponent) tableCell.editor());
    tableCell.startEditing();
    EditorTextFieldFixture textComponent = resourceComponent.getTextField();
    textComponent.requireText("@android:color/background_holo_light");
    textComponent.enterText("invalid");
    tableCell.stopEditing();
    Wait.seconds(1).expecting("warning icon to be loaded").until(() -> themeEditorTable.hasWarningIconAt(cell));
    tableCell.startEditing();
    textComponent = resourceComponent.getTextField();
    String prefix = "@android:color/back";
    textComponent.replaceText(prefix);
    JListFixture completionPopup = ThemeEditorGuiTestUtils.getCompletionPopup(guiTest.robot());
    String[] suggestions = completionPopup.contents();
    assertThat(suggestions).isNotEmpty();
    for (String suggestion : suggestions) {
        assertThat(suggestion).startsWith(prefix);
    }
    prefix = "@color/back";
    textComponent.replaceText(prefix);
    completionPopup = ThemeEditorGuiTestUtils.getCompletionPopup(guiTest.robot());
    suggestions = completionPopup.contents();
    assertThat(suggestions).isNotEmpty();
    for (String suggestion : suggestions) {
        assertThat(suggestion).startsWith(prefix);
    }
    completionPopup.item(0).doubleClick();
    tableCell.stopEditing();
    assertEquals(suggestions[0], themeEditorTable.valueAt(cell));
}
Also used : TableCell(org.fest.swing.data.TableCell) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with TableCell

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

the class ThemeEditorTableTest method testTabSwitchingWhileEditing.

@Test
public void testTabSwitchingWhileEditing() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    final ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    final TableCell cell = row(3).column(0);
    JTableCellFixture tableCell = themeEditorTable.cell(cell);
    ResourceComponentFixture resourceComponent = new ResourceComponentFixture(guiTest.robot(), (ResourceComponent) tableCell.editor());
    tableCell.startEditing();
    EditorTextFieldFixture textComponent = resourceComponent.getTextField();
    textComponent.enterText("text");
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.switchToTab("styles.xml");
    editor.switchToTab("Theme Editor");
}
Also used : TableCell(org.fest.swing.data.TableCell) Test(org.junit.Test)

Example 13 with TableCell

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

the class ThemeEditorTableTest method testParentValueCell.

@Test
public void testParentValueCell() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    // Cell (0,0) should be the parent editor
    TableCell parentCell = row(0).column(0);
    List<String> parentsList = themeEditorTable.getComboBoxContentsAt(parentCell);
    // The expected elements are:
    // 0. Holo Light
    // 1. -- Separator
    // 2. AppCompat Light
    // 3. AppCompat
    // 4. -- Separator
    // 5. Show all themes
    assertThat(parentsList).hasSize(6);
    assertThat(parentsList.get(0)).isEqualTo("android:Theme.Holo.Light.DarkActionBar");
    assertThat(parentsList.get(2)).isEqualTo("Theme.AppCompat.Light.NoActionBar");
    assertThat(parentsList.get(3)).isEqualTo("Theme.AppCompat.NoActionBar");
    assertThat(parentsList.get(5)).isEqualTo("Show all themes");
    assertThat(parentsList.get(1)).startsWith("javax.swing.JSeparator");
    assertThat(parentsList.get(4)).startsWith("javax.swing.JSeparator");
    JTableCellFixture parentCellFixture = themeEditorTable.cell(parentCell);
    parentCellFixture.requireEditable();
    // Checks that selecting a separator does nothing
    Component parentEditor = parentCellFixture.editor();
    parentCellFixture.startEditing();
    JComboBoxFixture parentComboBox = new JComboBoxFixture(guiTest.robot(), guiTest.robot().finder().findByType((JComponent) parentEditor, JComboBox.class));
    parentComboBox.selectItem(4);
    parentCellFixture.stopEditing();
    assertEquals("android:Theme.Holo.Light.DarkActionBar", themeEditorTable.getComboBoxSelectionAt(parentCell));
    // Selects a new parent
    final String newParent = "Theme.AppCompat.NoActionBar";
    parentCellFixture.startEditing();
    parentComboBox.selectItem(newParent);
    parentCellFixture.stopEditing();
    assertEquals(newParent, themeEditorTable.getComboBoxSelectionAt(parentCell));
    guiTest.ideFrame().invokeMenuPath("Edit", "Undo Updating Parent to Theme.AppCo...");
    assertEquals("android:Theme.Holo.Light.DarkActionBar", themeEditorTable.getComboBoxSelectionAt(parentCell));
    guiTest.ideFrame().invokeMenuPath("Edit", "Redo Updating Parent to Theme.AppCo...");
    assertEquals(newParent, themeEditorTable.getComboBoxSelectionAt(parentCell));
    Wait.seconds(1).expecting("potential tooltips to disappear").until(() -> guiTest.robot().findActivePopupMenu() == null);
    testParentPopup(themeEditorTable.cell(parentCell), newParent, themeEditor);
    guiTest.ideFrame().invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab");
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.moveBetween("", "AppTheme");
    assertThat(editor.getCurrentLine().trim()).isEqualTo("<style name=\"AppTheme\" parent=\"Theme.AppCompat.NoActionBar\">");
}
Also used : TableCell(org.fest.swing.data.TableCell) ResourceComponent(com.android.tools.idea.editors.theme.ui.ResourceComponent) Test(org.junit.Test)

Example 14 with TableCell

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

the class SwingTable method rightClickCell.

/**
     * Right click on table cell
     *
     * @param row the row number
     * @param column the column number
     * @throws VerificationException if the table element doesn't exist
     */
@PublicAtsApi
public void rightClickCell(int row, int column) {
    new SwingElementState(this).waitToBecomeExisting();
    JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
    try {
        tableFixture.cell(new TableCell(row, column) {
        }).rightClick();
    } 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 15 with TableCell

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

the class SwingTable method getCellForegroundColor.

/**
     * Returns the table cell foreground {@link Color}
     *
     * @param row the row number
     * @param column the column number
     */
@PublicAtsApi
public Color getCellForegroundColor(int row, int column) {
    new SwingElementState(this).waitToBecomeExisting();
    JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
    return tableFixture.foregroundAt(new TableCell(row, column) {
    }).target();
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) TableCell(org.fest.swing.data.TableCell) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

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