Search in sources :

Example 1 with JTableFixture

use of org.assertj.swing.fixture.JTableFixture in project jabref by JabRef.

the class ParameterizedDialogNewEntryTest method cancelAddingEntryPlainTextOfGivenType.

@Test
public void cancelAddingEntryPlainTextOfGivenType() {
    mainFrame.menuItemWithPath("File", "New " + databaseMode + " database").click();
    JTableFixture entryTable = mainFrame.table();
    entryTable.requireRowCount(0);
    mainFrame.menuItemWithPath("BibTeX", "New entry from plain text...").click();
    selectEntryType();
    GenericTypeMatcher<JDialog> matcher2 = plainTextMatcher();
    findDialog(matcher2).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {

        @Override
        protected boolean isMatching(@Nonnull JButton jButton) {
            return "Cancel".equals(jButton.getText());
        }
    }).click();
    entryTable.requireRowCount(0);
}
Also used : JTableFixture(org.assertj.swing.fixture.JTableFixture) Nonnull(org.assertj.swing.dependency.jsr305.Nonnull) JButton(javax.swing.JButton) GenericTypeMatcher(org.assertj.swing.core.GenericTypeMatcher) JDialog(javax.swing.JDialog) Test(org.junit.Test)

Example 2 with JTableFixture

use of org.assertj.swing.fixture.JTableFixture in project jabref by JabRef.

the class ParameterizedMenuNewEntryTest method addEntryOfGivenType.

// Not working on Travis
@Test
public void addEntryOfGivenType() {
    mainFrame.menuItemWithPath("File", "New " + databaseMode + " database").click();
    JTableFixture entryTable = mainFrame.table();
    entryTable.requireRowCount(0);
    mainFrame.menuItemWithPath("BibTeX", "New entry by type...", StringUtil.capitalizeFirst(entryType)).click();
    entryTable.requireRowCount(1);
}
Also used : JTableFixture(org.assertj.swing.fixture.JTableFixture) Test(org.junit.Test)

Example 3 with JTableFixture

use of org.assertj.swing.fixture.JTableFixture in project jabref by JabRef.

the class UndoTest method undoCutOfMultipleEntries.

@Test
public void undoCutOfMultipleEntries() {
    importBibIntoNewDatabase(getAbsolutePath("testbib/testjabref.bib"));
    JTableFixture entryTable = mainFrame.table();
    assertTrue("The database must have at least 2 entries for the test to begin!", entryTable.rowCount() >= 2);
    entryTable.selectRows(0, 1);
    entryTable.requireSelectedRows(0, 1);
    int oldRowCount = entryTable.rowCount();
    mainFrame.menuItemWithPath("Edit", "Cut").click();
    mainFrame.menuItemWithPath("Edit", "Undo").click();
    entryTable.requireRowCount(oldRowCount);
    closeDatabase();
    exitJabRef();
}
Also used : JTableFixture(org.assertj.swing.fixture.JTableFixture) Test(org.junit.Test)

Example 4 with JTableFixture

use of org.assertj.swing.fixture.JTableFixture in project jabref by JabRef.

the class UndoTest method undoRedoUpdatedCorrectly.

@Test
public void undoRedoUpdatedCorrectly() {
    newDatabase();
    assertFalse(mainFrame.menuItemWithPath("Edit", "Undo").isEnabled());
    assertFalse(mainFrame.menuItemWithPath("Edit", "Redo").isEnabled());
    JTableFixture entryTable = mainFrame.table();
    mainFrame.menuItemWithPath("BibTeX", "New entry...").click();
    findDialog(EntryTypeDialog.class).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {

        @Override
        protected boolean isMatching(@Nonnull JButton jButton) {
            return "Book".equals(jButton.getText());
        }
    }).click();
    assertTrue(mainFrame.menuItemWithPath("Edit", "Undo").isEnabled());
    assertFalse(mainFrame.menuItemWithPath("Edit", "Redo").isEnabled());
    entryTable.requireRowCount(1);
    mainFrame.menuItemWithPath("Edit", "Undo").click();
    assertFalse(mainFrame.menuItemWithPath("Edit", "Undo").isEnabled());
    assertTrue(mainFrame.menuItemWithPath("Edit", "Redo").isEnabled());
    entryTable.requireRowCount(0);
    closeDatabase();
    exitJabRef();
}
Also used : JTableFixture(org.assertj.swing.fixture.JTableFixture) Nonnull(org.assertj.swing.dependency.jsr305.Nonnull) JButton(javax.swing.JButton) GenericTypeMatcher(org.assertj.swing.core.GenericTypeMatcher) Test(org.junit.Test)

Example 5 with JTableFixture

use of org.assertj.swing.fixture.JTableFixture in project jabref by JabRef.

the class IdFetcherDialogTest method insertEmptySearchID.

@Test
public void insertEmptySearchID() {
    mainFrame.menuItemWithPath("File", "New " + databaseMode + " database").click();
    JTableFixture entryTable = mainFrame.table();
    entryTable.requireRowCount(0);
    mainFrame.menuItemWithPath("BibTeX", "New entry...").click();
    GenericTypeMatcher<JDialog> matcher = new GenericTypeMatcher<JDialog>(JDialog.class) {

        @Override
        protected boolean isMatching(JDialog dialog) {
            return "Select entry type".equals(dialog.getTitle());
        }
    };
    findDialog(matcher).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {

        @Override
        protected boolean isMatching(@Nonnull JButton jButton) {
            return "Generate".equals(jButton.getText());
        }
    }).click();
    GenericTypeMatcher<JDialog> matcherEmptyDialog = new GenericTypeMatcher<JDialog>(JDialog.class) {

        @Override
        protected boolean isMatching(JDialog dialog) {
            return "Empty search ID".equals(dialog.getTitle());
        }
    };
    findDialog(matcherEmptyDialog).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {

        @Override
        protected boolean isMatching(@Nonnull JButton jButton) {
            return "OK".equals(jButton.getText());
        }
    }).click();
    entryTable.requireRowCount(0);
}
Also used : JTableFixture(org.assertj.swing.fixture.JTableFixture) Nonnull(org.assertj.swing.dependency.jsr305.Nonnull) JButton(javax.swing.JButton) GenericTypeMatcher(org.assertj.swing.core.GenericTypeMatcher) JDialog(javax.swing.JDialog) Test(org.junit.Test)

Aggregations

JTableFixture (org.assertj.swing.fixture.JTableFixture)10 Test (org.junit.Test)10 JButton (javax.swing.JButton)5 JDialog (javax.swing.JDialog)5 GenericTypeMatcher (org.assertj.swing.core.GenericTypeMatcher)5 Nonnull (org.assertj.swing.dependency.jsr305.Nonnull)5 Pattern (java.util.regex.Pattern)1 JComboBox (javax.swing.JComboBox)1 JTextComponent (javax.swing.text.JTextComponent)1 JTableCellFixture (org.assertj.swing.fixture.JTableCellFixture)1 Condition (org.assertj.swing.timing.Condition)1