From d0efbcdbfa004dbaae10110157ea5daf354d761e Mon Sep 17 00:00:00 2001 From: hneemann Date: Fri, 2 Feb 2018 18:23:36 +0100 Subject: [PATCH] gui tests are running on Win7 --- .../neemann/digital/integration/GuiTester.java | 8 +++++++- .../neemann/digital/integration/TestInGUI.java | 16 ++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/test/java/de/neemann/digital/integration/GuiTester.java b/src/test/java/de/neemann/digital/integration/GuiTester.java index b6e716fde..367b7730b 100644 --- a/src/test/java/de/neemann/digital/integration/GuiTester.java +++ b/src/test/java/de/neemann/digital/integration/GuiTester.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import static java.awt.event.InputEvent.*; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; public class GuiTester { @@ -548,7 +549,12 @@ public class GuiTester { * @param expectedColor the expected color */ public ColorPicker(Class target, int x, int y, Color expectedColor) { - this(target, x, y, (c) -> assertEquals(expectedColor, c)); + this(target, x, y, (c) -> { + boolean ok = (Math.abs (expectedColor.getRed() - c.getRed()) < 5) + && (Math.abs(expectedColor.getGreen() - c.getGreen()) < 5) + && (Math.abs(expectedColor.getBlue() - c.getBlue()) < 5); + assertTrue("expected:<" + expectedColor + "> but was:<" + c + ">", ok); + }); } /** diff --git a/src/test/java/de/neemann/digital/integration/TestInGUI.java b/src/test/java/de/neemann/digital/integration/TestInGUI.java index 273038c5d..86b127e63 100644 --- a/src/test/java/de/neemann/digital/integration/TestInGUI.java +++ b/src/test/java/de/neemann/digital/integration/TestInGUI.java @@ -201,14 +201,14 @@ public class TestInGUI extends TestCase { .use(createNew4VarTruthTable) .add(new EnterTruthTable(0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1)) .press("F1") - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 144, 109, new Color(191,127,127))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 110, new Color(127,127,191))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 82, 168, new Color(255,127,127))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 170, new Color(127,255,127))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 143, 232, new Color(127,127,255))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 265, 230, new Color(255,127,255))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 83, 292, new Color(227,227,127))) - .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 204, 291, new Color(127,255,255))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 144, 109, new Color(191, 127, 127))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 110, new Color(127, 127, 191))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 82, 168, new Color(255, 127, 127))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 170, new Color(127, 255, 127))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 143, 232, new Color(127, 127, 255))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 265, 230, new Color(255, 127, 255))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 83, 292, new Color(227, 227, 127))) + .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 204, 291, new Color(127, 255, 255))) // .add(new GuiTester.ColorPickerCreator(KarnaughMapComponent.class)) // .ask("Shows the k-map a checkerboard pattern?") .add(new GuiTester.CloseTopMost())