-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration tests are now separated from the normal unit tests and have to be called manually.
- Loading branch information
1 parent
7d66412
commit 2cef1fe
Showing
7 changed files
with
196 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/integration-test/java/net/sf/jabref/gui/AWTExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.sf.jabref.gui; | ||
|
||
import junit.framework.AssertionFailedError; | ||
import org.junit.Assert; | ||
|
||
import javax.swing.*; | ||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
/** | ||
* Can catch any exceptions occuring on the EDT thread for assertion. | ||
*/ | ||
public class AWTExceptionHandler { | ||
|
||
private final List<Throwable> list = new CopyOnWriteArrayList<>(); | ||
|
||
public void installExceptionDetectionInEDT() { | ||
SwingUtilities.invokeLater(() -> Thread.currentThread().setUncaughtExceptionHandler((t, e) -> list.add(e))); | ||
} | ||
|
||
public void assertNoExceptions() { | ||
if(!list.isEmpty()) { | ||
throw new AssertionError("Uncaught exception in EDT", list.get(0)); | ||
} | ||
} | ||
|
||
} |
104 changes: 104 additions & 0 deletions
104
src/integration-test/java/net/sf/jabref/gui/GUITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package net.sf.jabref.gui; | ||
|
||
import net.sf.jabref.JabRefMain; | ||
import net.sf.jabref.gui.preftabs.PreferencesDialog; | ||
import org.assertj.swing.core.GenericTypeMatcher; | ||
import org.assertj.swing.dependency.jsr305.Nonnull; | ||
import org.assertj.swing.fixture.FrameFixture; | ||
import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase; | ||
import org.junit.Test; | ||
|
||
import javax.swing.*; | ||
|
||
import static org.assertj.swing.finder.WindowFinder.findDialog; | ||
import static org.assertj.swing.finder.WindowFinder.findFrame; | ||
import static org.assertj.swing.launcher.ApplicationLauncher.application; | ||
|
||
public class GUITest extends AssertJSwingJUnitTestCase { | ||
|
||
private AWTExceptionHandler awtExceptionHandler; | ||
|
||
@Override | ||
protected void onSetUp() { | ||
awtExceptionHandler = new AWTExceptionHandler(); | ||
awtExceptionHandler.installExceptionDetectionInEDT(); | ||
application(JabRefMain.class).start(); | ||
} | ||
|
||
@Test | ||
public void testExit() { | ||
FrameFixture mainFrame = findFrame(JabRefFrame.class).using(robot()); | ||
exitJabRef(mainFrame); | ||
} | ||
|
||
private void exitJabRef(FrameFixture mainFrame) { | ||
mainFrame.menuItemWithPath("File", "Quit").click(); | ||
awtExceptionHandler.assertNoExceptions(); | ||
} | ||
|
||
@Test | ||
public void testNewFile() { | ||
FrameFixture mainFrame = findFrame(JabRefFrame.class).using(robot()); | ||
newDatabase(mainFrame); | ||
|
||
mainFrame.menuItemWithPath("File", "Close database").click(); | ||
exitJabRef(mainFrame); | ||
} | ||
|
||
private void newDatabase(FrameFixture mainFrame) { | ||
mainFrame.menuItemWithPath("File", "New BibTeX database").click(); | ||
} | ||
|
||
@Test | ||
public void testCreateBibtexEntry() { | ||
FrameFixture mainFrame = findFrame(JabRefFrame.class).using(robot()); | ||
|
||
newDatabase(mainFrame); | ||
|
||
mainFrame.menuItemWithPath("BibTeX", "New entry").click(); | ||
findDialog(EntryTypeDialog.class).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) { | ||
|
||
@Override protected boolean isMatching(@Nonnull JButton jButton) { | ||
return "Book".equals(jButton.getText()); | ||
} | ||
}).click(); | ||
|
||
exitJabRef(mainFrame); | ||
} | ||
|
||
@Test | ||
public void testOpenAndSavePreferences() { | ||
FrameFixture mainFrame = findFrame(JabRefFrame.class).using(robot()); | ||
|
||
mainFrame.menuItemWithPath("Options", "Preferences").click(); | ||
findDialog(PreferencesDialog.class).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) { | ||
|
||
@Override protected boolean isMatching(@Nonnull JButton jButton) { | ||
return "OK".equals(jButton.getText()); | ||
} | ||
}).click(); | ||
|
||
exitJabRef(mainFrame); | ||
} | ||
|
||
@Test | ||
public void testViewChanges() { | ||
FrameFixture mainFrame = findFrame(JabRefFrame.class).using(robot()); | ||
|
||
newDatabase(mainFrame); | ||
|
||
mainFrame.menuItemWithPath("View", "Increase table font size").click(); | ||
mainFrame.menuItemWithPath("View", "Decrease table font size").click(); | ||
mainFrame.menuItemWithPath("View", "Web search").click(); | ||
mainFrame.menuItemWithPath("View", "Toggle groups interface").click(); | ||
mainFrame.menuItemWithPath("View", "Toggle entry preview").click(); | ||
mainFrame.menuItemWithPath("View", "Switch preview layout").click(); | ||
mainFrame.menuItemWithPath("View", "Hide/show toolbar").click(); | ||
mainFrame.menuItemWithPath("View", "Focus entry table").click(); | ||
|
||
newDatabase(mainFrame); | ||
mainFrame.menuItemWithPath("File", "Close database").click(); | ||
exitJabRef(mainFrame); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package net.sf.jabref; | ||
|
||
import javax.swing.*; | ||
|
||
/** | ||
* JabRef MainClass | ||
*/ | ||
public class JabRefMain { | ||
public static void main(String[] args) { | ||
new JabRef().start(args); | ||
SwingUtilities.invokeLater(() -> new JabRef().start(args)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters