From dce75d966735c83872adf043719753f1f427e204 Mon Sep 17 00:00:00 2001 From: hneemann Date: Wed, 28 Aug 2019 09:48:08 +0200 Subject: [PATCH] added gui test for net renaming --- .../digital/integration/TestInGUI.java | 44 +++++-- src/test/resources/dig/net/netRename.dig | 113 ++++++++++++++++++ 2 files changed, 148 insertions(+), 9 deletions(-) create mode 100644 src/test/resources/dig/net/netRename.dig diff --git a/src/test/java/de/neemann/digital/integration/TestInGUI.java b/src/test/java/de/neemann/digital/integration/TestInGUI.java index ee4da2bcf..a493e1048 100644 --- a/src/test/java/de/neemann/digital/integration/TestInGUI.java +++ b/src/test/java/de/neemann/digital/integration/TestInGUI.java @@ -16,6 +16,7 @@ import de.neemann.digital.core.io.Out; import de.neemann.digital.core.memory.ROM; import de.neemann.digital.core.wiring.Driver; import de.neemann.digital.draw.elements.Circuit; +import de.neemann.digital.draw.elements.Tunnel; import de.neemann.digital.draw.elements.VisualElement; import de.neemann.digital.draw.elements.Wire; import de.neemann.digital.draw.graphics.GraphicMinMax; @@ -62,7 +63,7 @@ import static de.neemann.digital.testing.TestCaseElement.TESTDATA; * These tests are excluded from the maven build because gui tests are sometimes fragile. * They may not behave as expected on all systems. * Run this tests directly from your IDE. - * + *

* maven: mvn -Dtest=TestInGUI test */ public class TestInGUI extends TestCase { @@ -240,14 +241,14 @@ public class TestInGUI extends TestCase { .add(new EnterTruthTable(0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1)) .press("F1") .delay(500) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 146, 110, new Color(215,175,175))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 109, new Color(187,187,221))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 86, 169, new Color(255,187,187))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 169, new Color(127,255,127))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 145, 228, new Color(127,127,255))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 230, new Color(255,175,255))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 86, 288, new Color(242,242,191))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 289, new Color(127,255,255))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 146, 110, new Color(215, 175, 175))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 109, new Color(187, 187, 221))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 86, 169, new Color(255, 187, 187))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 169, new Color(127, 255, 127))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 145, 228, new Color(127, 127, 255))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 230, new Color(255, 175, 255))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 86, 288, new Color(242, 242, 191))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 289, new Color(127, 255, 255))) // .add(new GuiTester.ColorPickerCreator(KarnaughMapComponent.class)) // .ask("Shows the k-map a checkerboard pattern?") .add(new GuiTester.CloseTopMost()) @@ -954,6 +955,31 @@ public class TestInGUI extends TestCase { .execute(); } + public void testNetRename() { + new GuiTester("dig/net/netRename.dig") + .add(new SetMouseToElement(v -> v.equalsDescription(Tunnel.DESCRIPTION) && v.getPos().x < 400)) + .mouseClick(InputEvent.BUTTON3_MASK) + .delay(200) + .type("et") + .press("ENTER") + .delay(200) + .add(new GuiTester.CheckTextInWindow<>(JDialog.class, "'net'")) + .delay(200) + .press("ENTER") + .delay(200) + .add(new GuiTester.WindowCheck

(Main.class){ + @Override + public void checkWindow(GuiTester guiTester, Main main) { + List e = main.getCircuitComponent().getCircuit() + .findElements(v -> v.equalsDescription(Tunnel.DESCRIPTION)); + assertEquals(3, e.size()); + for (VisualElement v : e) + assertEquals("net", v.getElementAttributes().get(Keys.NETNAME)); + } + }) + .execute(); + } + public void testFSM() { new GuiTester() .press("F10") diff --git a/src/test/resources/dig/net/netRename.dig b/src/test/resources/dig/net/netRename.dig new file mode 100644 index 000000000..5c1e3ec9a --- /dev/null +++ b/src/test/resources/dig/net/netRename.dig @@ -0,0 +1,113 @@ + + + 1 + + + + In + + + Label + A + + + + + + Tunnel + + + NetName + n + + + + + + Tunnel + + + rotation + + + + NetName + n + + + + + + Tunnel + + + rotation + + + + NetName + n + + + + + + Out + + + Label + Y + + + + + + Out + + + Label + X + + + + + + Not + + + + + Testcase + + + Testdata + + A Y X +0 0 1 +1 1 0 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file