mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-18 01:14:42 -04:00
closes #164
This commit is contained in:
parent
9c078062a6
commit
addc9c26e3
@ -43,7 +43,7 @@ public class ClosingWindowListener extends WindowAdapter {
|
|||||||
* @param confirmSave the ConfirmSave interface
|
* @param confirmSave the ConfirmSave interface
|
||||||
* @param doExit if true the parent JFrame is disposed by this listener
|
* @param doExit if true the parent JFrame is disposed by this listener
|
||||||
*/
|
*/
|
||||||
public ClosingWindowListener(final JFrame parent, final ConfirmSave confirmSave, final boolean doExit) {
|
private ClosingWindowListener(final JFrame parent, final ConfirmSave confirmSave, final boolean doExit) {
|
||||||
this((Component) parent, new GUICloser() {
|
this((Component) parent, new GUICloser() {
|
||||||
@Override
|
@Override
|
||||||
public void closeGUI() {
|
public void closeGUI() {
|
||||||
@ -80,14 +80,14 @@ public class ClosingWindowListener extends WindowAdapter {
|
|||||||
.setCancleOption(CANCEL_MESSAGE)
|
.setCancleOption(CANCEL_MESSAGE)
|
||||||
.show(parent);
|
.show(parent);
|
||||||
|
|
||||||
if (r != JOptionPane.CANCEL_OPTION) {
|
if (r == JOptionPane.YES_OPTION || r == JOptionPane.NO_OPTION) {
|
||||||
if (r == JOptionPane.YES_OPTION) {
|
if (r == JOptionPane.YES_OPTION) {
|
||||||
confirmSave.saveChanges();
|
confirmSave.saveChanges();
|
||||||
}
|
return !confirmSave.isStateChanged();
|
||||||
return true;
|
} else
|
||||||
} else {
|
return true;
|
||||||
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ public class ClosingWindowListener extends WindowAdapter {
|
|||||||
* @param parent the parent component of the confirm dialog
|
* @param parent the parent component of the confirm dialog
|
||||||
* @param guiCloser the guiCloser
|
* @param guiCloser the guiCloser
|
||||||
*/
|
*/
|
||||||
public ClosingWindowListener(Component parent, GUICloser guiCloser) {
|
private ClosingWindowListener(Component parent, GUICloser guiCloser) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.guiCloser = guiCloser;
|
this.guiCloser = guiCloser;
|
||||||
}
|
}
|
||||||
|
@ -543,6 +543,84 @@ public class TestInGUI extends TestCase {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSaveDialog() {
|
||||||
|
new GuiTester()
|
||||||
|
.press("F10")
|
||||||
|
.press("RIGHT", 5)
|
||||||
|
.press("DOWN", "RIGHT", "ENTER")
|
||||||
|
.mouseMove(100, 150)
|
||||||
|
.mouseClick(InputEvent.BUTTON1_MASK)
|
||||||
|
.delay(100)
|
||||||
|
|
||||||
|
// aboard with escape
|
||||||
|
.press("control typed n")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.WindowCheck<>(JDialog.class,
|
||||||
|
(guiTester, window) -> assertEquals(Lang.get("win_stateChanged"), window.getTitle())))
|
||||||
|
.press("ESCAPE")
|
||||||
|
.add(new GuiTester.WindowCheck<>(Main.class,
|
||||||
|
(gt, main) -> assertEquals(1, main.getCircuitComponent().getCircuit().getElements().size())))
|
||||||
|
|
||||||
|
// press edit further
|
||||||
|
.press("control typed n")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.SetFocusTo<>(JDialog.class,
|
||||||
|
c -> c instanceof JButton && ((JButton)c).getText().equals(Lang.get("btn_editFurther"))))
|
||||||
|
.press("SPACE")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.WindowCheck<>(Main.class,
|
||||||
|
(gt, main) -> assertEquals(1, main.getCircuitComponent().getCircuit().getElements().size())))
|
||||||
|
|
||||||
|
// press save and the escape the save dialog (JFileChooser)
|
||||||
|
.press("control typed n")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.SetFocusTo<>(JDialog.class,
|
||||||
|
c -> c instanceof JButton && ((JButton)c).getText().equals(Lang.get("btn_save"))))
|
||||||
|
.press("SPACE")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.WindowCheck<>(JDialog.class))
|
||||||
|
.press("ESCAPE")
|
||||||
|
.add(new GuiTester.WindowCheck<>(Main.class,
|
||||||
|
(gt, main) -> assertEquals(1, main.getCircuitComponent().getCircuit().getElements().size())))
|
||||||
|
|
||||||
|
// press save and save the file
|
||||||
|
.press("control typed n")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.SetFocusTo<>(JDialog.class,
|
||||||
|
c -> c instanceof JButton && ((JButton)c).getText().equals(Lang.get("btn_save"))))
|
||||||
|
.press("SPACE")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.WindowCheck<>(JDialog.class))
|
||||||
|
.typeTempFile("save.dig")
|
||||||
|
.press("ENTER")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.WindowCheck<>(Main.class,
|
||||||
|
(gt, main) -> assertEquals(0, main.getCircuitComponent().getCircuit().getElements().size())))
|
||||||
|
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSaveDialog2() {
|
||||||
|
new GuiTester()
|
||||||
|
.press("F10")
|
||||||
|
.press("RIGHT", 5)
|
||||||
|
.press("DOWN", "RIGHT", "ENTER")
|
||||||
|
.mouseMove(100, 150)
|
||||||
|
.mouseClick(InputEvent.BUTTON1_MASK)
|
||||||
|
.delay(100)
|
||||||
|
|
||||||
|
// discard changes
|
||||||
|
.press("control typed n")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.SetFocusTo<>(JDialog.class,
|
||||||
|
c -> c instanceof JButton && ((JButton)c).getText().equals(Lang.get("btn_discard"))))
|
||||||
|
.press("SPACE")
|
||||||
|
.delay(100)
|
||||||
|
.add(new GuiTester.WindowCheck<>(Main.class,
|
||||||
|
(gt, main) -> assertEquals(0, main.getCircuitComponent().getCircuit().getElements().size())))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void test74xxFunctions() {
|
public void test74xxFunctions() {
|
||||||
new GuiTester("dig/manualError/10_74xx.dig")
|
new GuiTester("dig/manualError/10_74xx.dig")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user