From 988ccbb1063bf24457a31eabf98a076696c440f4 Mon Sep 17 00:00:00 2001 From: hneemann Date: Fri, 19 Feb 2021 11:12:38 +0100 Subject: [PATCH] adds a workaround for a failing gui test --- .../digital/integration/TestInGUI.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/test/java/de/neemann/digital/integration/TestInGUI.java b/src/test/java/de/neemann/digital/integration/TestInGUI.java index 1cba54178..9fa40b26c 100644 --- a/src/test/java/de/neemann/digital/integration/TestInGUI.java +++ b/src/test/java/de/neemann/digital/integration/TestInGUI.java @@ -1195,14 +1195,13 @@ public class TestInGUI extends TestCase { xMin -= loc.x + SIZE * 5; yMin -= loc.y + SIZE * 2; + boolean firstWire = true; for (Wire w : circuit.getWires()) { - guiTester.mouseClickNow(w.p1.x - xMin, w.p1.y - yMin, InputEvent.BUTTON1_DOWN_MASK); - if (w.p1.x != w.p2.x && w.p1.y != w.p2.y) - guiTester.typeNow("typed d"); - - guiTester.mouseClickNow(w.p2.x - xMin, w.p2.y - yMin, InputEvent.BUTTON1_DOWN_MASK); - Thread.sleep(50); - guiTester.mouseClickNow(w.p2.x - xMin, w.p2.y - yMin, InputEvent.BUTTON3_DOWN_MASK); + if (firstWire) { // Draw first wire twice! Sometimes the first wire is lost and i can't figure out why! + firstWire = false; // This is a dirty hack! + drawWire(guiTester, xMin, yMin, w); + } + drawWire(guiTester, xMin, yMin, w); } for (VisualElement v : circuit.getElements()) { @@ -1215,6 +1214,16 @@ public class TestInGUI extends TestCase { Thread.sleep(400); } } + + private void drawWire(GuiTester guiTester, int xMin, int yMin, Wire w) throws InterruptedException { + guiTester.mouseClickNow(w.p1.x - xMin, w.p1.y - yMin, InputEvent.BUTTON1_DOWN_MASK); + if (w.p1.x != w.p2.x && w.p1.y != w.p2.y) + guiTester.typeNow("typed d"); + + guiTester.mouseClickNow(w.p2.x - xMin, w.p2.y - yMin, InputEvent.BUTTON1_DOWN_MASK); + Thread.sleep(50); + guiTester.mouseClickNow(w.p2.x - xMin, w.p2.y - yMin, InputEvent.BUTTON3_DOWN_MASK); + } } private static Point getCircuitPos(Main main) {