diff --git a/screenshot3.png b/screenshot3.png new file mode 100644 index 000000000..7b7fb8b56 Binary files /dev/null and b/screenshot3.png differ diff --git a/src/main/fsm/trafficLightBlink.fsm b/src/main/fsm/trafficLightBlink.fsm new file mode 100644 index 000000000..794e25e41 --- /dev/null +++ b/src/main/fsm/trafficLightBlink.fsm @@ -0,0 +1,84 @@ + + + + + R=1 + + 0 + Red + 70 + + + R=1,Y=1 + + 1 + Red/Yellow + 70 + + + G=1 + + 2 + Green + 70 + + + Y=1 + + 3 + Yellow + 70 + + + + + 4 + Off + 70 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Blk + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/de/neemann/digital/fsm/gui/FSMFrame.java b/src/main/java/de/neemann/digital/fsm/gui/FSMFrame.java index 18f570409..08a6fd91e 100644 --- a/src/main/java/de/neemann/digital/fsm/gui/FSMFrame.java +++ b/src/main/java/de/neemann/digital/fsm/gui/FSMFrame.java @@ -254,7 +254,12 @@ public class FSMFrame extends JFrame implements ClosingWindowListener.ConfirmSav } } - private void loadFile(File file) { + /** + * Loads a file. + * + * @param file the file to load + */ + public void loadFile(File file) { try { moveControl.setSelectedIndex(0); setFSM(FSM.loadFSM(file)); diff --git a/src/main/java/de/neemann/digital/gui/components/table/TableDialog.java b/src/main/java/de/neemann/digital/gui/components/table/TableDialog.java index 89c420946..8f252e779 100644 --- a/src/main/java/de/neemann/digital/gui/components/table/TableDialog.java +++ b/src/main/java/de/neemann/digital/gui/components/table/TableDialog.java @@ -525,6 +525,13 @@ public class TableDialog extends JDialog { else return filename.getName(); } + /** + * @return the all solutions dialog + */ + public AllSolutionsDialog getAllSolutionsDialog() { + return allSolutionsDialog; + } + private void setLastUsedGenerator(HardwareDescriptionGenerator generator) { if (lastUsedGenratorMenuItem != null) hardwareMenu.remove(lastUsedGenratorMenuItem); diff --git a/src/test/java/de/neemann/digital/docu/ScreenShots.java b/src/test/java/de/neemann/digital/docu/ScreenShots.java index d6ebe7617..0e8ecb572 100644 --- a/src/test/java/de/neemann/digital/docu/ScreenShots.java +++ b/src/test/java/de/neemann/digital/docu/ScreenShots.java @@ -6,12 +6,14 @@ package de.neemann.digital.docu; import de.neemann.digital.core.element.Keys; +import de.neemann.digital.fsm.gui.FSMFrame; import de.neemann.digital.gui.Main; import de.neemann.digital.gui.Settings; import de.neemann.digital.gui.components.AttributeDialog; import de.neemann.digital.gui.components.expression.ExpressionDialog; import de.neemann.digital.gui.components.graphics.GraphicDialog; import de.neemann.digital.gui.components.karnaugh.KarnaughMapDialog; +import de.neemann.digital.gui.components.table.AllSolutionsDialog; import de.neemann.digital.gui.components.table.TableDialog; import de.neemann.digital.gui.components.testing.TestCaseDescriptionDialog; import de.neemann.digital.gui.components.testing.ValueTableDialog; @@ -41,6 +43,7 @@ public class ScreenShots { private static final int WIN_DX = 850; private static final int WIN_DY = 500; private static GraphicDialog graphic; + private static Main mainStatic; public static void main(String[] args) { Settings.getInstance().getAttributes().set(Keys.SETTINGS_DEFAULT_TREESELECT, false); @@ -130,6 +133,60 @@ public class ScreenShots { .add(new GuiTester.CloseTopMost()) .add(new GuiTester.CloseTopMost()) .execute(); + + File trafficLight = new File(Resources.getRoot(), "../../main/fsm/trafficLightBlink.fsm"); + new GuiTester() + .press("F10") + .press("RIGHT", 4) + .press("DOWN", 4) + .press("ENTER") + .delay(500) + .add(new GuiTester.WindowCheck<>(FSMFrame.class, (gt, fsmFrame) -> fsmFrame.loadFile(trafficLight))) + .press("F10") + .press("RIGHT", 2) + .press("DOWN", 1) + .press("ENTER") + .delay(500) + .add(new GuiTester.WindowCheck<>(Window.class, (guiTester, window) -> { + if (window instanceof AllSolutionsDialog) + window.dispose(); + else + if (window instanceof TableDialog) + ((TableDialog)window).getAllSolutionsDialog().dispose(); + })) + .add(new GuiTester.WindowCheck<>(TableDialog.class)) + .press("F10") + .press("RIGHT", 4) + .press("DOWN", 2) + .press("ENTER") + .delay(500) + .add(new GuiTester.WindowCheck<>(Main.class, + (gt, main) -> { + main.getCircuitComponent().translateCircuit(-300, 0); + mainStatic = main; + })) + .delay(500) + .press("F10") + .press("RIGHT", 4) + .press("DOWN", 4) + .press("ENTER") + .delay(500) + .add(new GuiTester.WindowCheck<>(FSMFrame.class, (gt, fsmFrame) -> { + fsmFrame.loadFile(trafficLight); + fsmFrame.getContentPane().setPreferredSize(new Dimension(550, 400)); + fsmFrame.pack(); + final Point location = fsmFrame.getLocation(); + fsmFrame.setLocation(location.x + 250, location.y + 100); + fsmFrame.setAlwaysOnTop(true); + fsmFrame.setTitle(trafficLight.getName()); + mainStatic.requestFocus(); + })) + .add(new MainScreenShot("screenshot3.png")) + .add(new GuiTester.CloseTopMost()) + .add(new GuiTester.CloseTopMost()) + .add(new GuiTester.CloseTopMost()) + .add(new GuiTester.CloseTopMost()) + .execute(); } // Set all settings as needed before start this method diff --git a/src/test/java/de/neemann/digital/fsm/IntegrationTest.java b/src/test/java/de/neemann/digital/fsm/IntegrationTest.java index cb6c98fdb..fb2266889 100644 --- a/src/test/java/de/neemann/digital/fsm/IntegrationTest.java +++ b/src/test/java/de/neemann/digital/fsm/IntegrationTest.java @@ -17,7 +17,7 @@ public class IntegrationTest extends TestCase { public void testExamples() throws Exception { File examples = new File(Resources.getRoot().getParentFile().getParentFile(), "/main/fsm"); - assertEquals(7, new FileScanner(this::check).setSuffix("fsm").scan(examples)); + assertEquals(8, new FileScanner(this::check).setSuffix("fsm").scan(examples)); }