Skip to content

Commit

Permalink
Merge pull request #1380 from bartsch-dev/fix-796
Browse files Browse the repository at this point in the history
[WIP] Fix for undoing deletion/cutting multiple entries (again)
  • Loading branch information
simonharrer committed May 11, 2016
2 parents 3f4bc92 + 7d0d4ce commit 225077e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/integrationTest/java/net/sf/jabref/gui/UndoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import net.sf.jabref.JabRefMain;

import org.assertj.swing.finder.JFileChooserFinder;
import org.assertj.swing.fixture.FrameFixture;
import org.assertj.swing.fixture.JFileChooserFixture;
import org.assertj.swing.fixture.JTableFixture;
Expand All @@ -13,7 +12,6 @@

import static org.assertj.swing.finder.WindowFinder.findFrame;
import static org.assertj.swing.launcher.ApplicationLauncher.application;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class UndoTest extends AssertJSwingJUnitTestCase {
Expand Down Expand Up @@ -42,13 +40,16 @@ private String getTestFilePath(String fileName) {
}

private void importBibIntoNewDatabase(FrameFixture mainFrame, String path) {
mainFrame.menuItemWithPath("File", "Import into new database").click();
// have to replace backslashes with normal slashes b/c assertJ can't type the former one on windows
path = path.replace("\\", "/");

JFileChooserFixture openFileDialog = JFileChooserFinder.findFileChooser().withTimeout(10_000).using(robot());
mainFrame.menuItemWithPath("File", "Import into new database").click();
JFileChooserFixture openFileDialog = mainFrame.fileChooser();
robot().settings().delayBetweenEvents(1);
openFileDialog.fileNameTextBox().enterText(path);
robot().settings().delayBetweenEvents(50);
robot().settings().delayBetweenEvents(1_000);
openFileDialog.approve();
robot().settings().delayBetweenEvents(50);
}

@Test
Expand All @@ -57,14 +58,17 @@ public void undoCutOfMultipleEntries() {
importBibIntoNewDatabase(mainFrame, getTestFilePath("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 rowCount = entryTable.rowCount();
int oldRowCount = entryTable.rowCount();
mainFrame.menuItemWithPath("Edit", "Cut").click();
mainFrame.menuItemWithPath("Edit", "Undo").click();
assertEquals(rowCount, entryTable.rowCount());
entryTable.requireRowCount(oldRowCount);

mainFrame.menuItemWithPath("File", "Close database").click();
mainFrame.menuItemWithPath("File", "Close database").click();
exitJabRef(mainFrame);
}
Expand Down

0 comments on commit 225077e

Please # to comment.