Search in sources :

Example 1 with GenericTypeMatcher

use of org.assertj.swing.core.GenericTypeMatcher 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 GenericTypeMatcher

use of org.assertj.swing.core.GenericTypeMatcher 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 3 with GenericTypeMatcher

use of org.assertj.swing.core.GenericTypeMatcher 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)

Example 4 with GenericTypeMatcher

use of org.assertj.swing.core.GenericTypeMatcher in project jabref by JabRef.

the class GUITest method testDatabasePropertiesDialog.

@Test
public void testDatabasePropertiesDialog() throws IOException {
    newDatabase();
    mainFrame.menuItemWithPath("File", "Library properties").click();
    robot().waitForIdle();
    DialogFixture databasePropertiesDialog = findDialog(DatabasePropertiesDialog.class).withTimeout(10_000).using(robot());
    takeScreenshot(databasePropertiesDialog, "DatabasePropertiesDialog");
    databasePropertiesDialog.button(new GenericTypeMatcher<JButton>(JButton.class) {

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

Example 5 with GenericTypeMatcher

use of org.assertj.swing.core.GenericTypeMatcher in project jabref by JabRef.

the class GUITest method testOpenAndSavePreferences.

@Test
public void testOpenAndSavePreferences() throws IOException {
    mainFrame.menuItemWithPath("Options", "Preferences").click();
    robot().waitForIdle();
    DialogFixture preferencesDialog = findDialog(PreferencesDialog.class).withTimeout(10_000).using(robot());
    takeScreenshot(preferencesDialog, "PreferencesDialog");
    preferencesDialog.button(new GenericTypeMatcher<JButton>(JButton.class) {

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

Aggregations

JButton (javax.swing.JButton)7 GenericTypeMatcher (org.assertj.swing.core.GenericTypeMatcher)7 Nonnull (org.assertj.swing.dependency.jsr305.Nonnull)7 Test (org.junit.Test)7 JTableFixture (org.assertj.swing.fixture.JTableFixture)5 JDialog (javax.swing.JDialog)4 DialogFixture (org.assertj.swing.fixture.DialogFixture)2 JComboBox (javax.swing.JComboBox)1 JTextComponent (javax.swing.text.JTextComponent)1 Condition (org.assertj.swing.timing.Condition)1