From e36dea8789dca3f7af9aaa6bb1b1c8a7add82c42 Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Fri, 12 Jan 2018 01:26:40 +0000
Subject: [PATCH v1] Debugging test commit

---
 .../josm/gui/dialogs/MinimapDialogTest.java        | 30 +++++++++----------
 .../josm/testutils/JOSMTestRules.java              |  3 +-
 .../josm/testutils/TileSourceRule.java             | 35 ++++++++++++++++++++++
 3 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
index 1aa8a7b38..cc22a6da0 100644
--- a/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
+++ b/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
@@ -413,7 +413,7 @@ public class MinimapDialogTest {
      */
     @Test
     public void testShowDownloadedArea() throws Exception {
-        Main.pref.put("slippy_map_chooser.mapstyle", "Green Tiles");
+        Main.pref.put("slippy_map_chooser.mapstyle", "Green/white Stripes");
         Main.pref.putBoolean("slippy_map_chooser.show_downloaded_area", false);
 
         DataSet dataSet = new DataSet();
@@ -459,20 +459,20 @@ public class MinimapDialogTest {
             .build();
 
         // assert downloaded areas are not drawn
-        ImagePatternMatching.rowMatch(
-            paintedSlippyMap,
-            paintedSlippyMap.getHeight()/2,
-            paletteMap,
-            "^g+bv+bg+$",
-            true
-        );
-        ImagePatternMatching.columnMatch(
-            paintedSlippyMap,
-            paintedSlippyMap.getWidth()/2,
-            paletteMap,
-            "^g+bv+bg+$",
-            true
-        );
+//         ImagePatternMatching.rowMatch(
+//             paintedSlippyMap,
+//             paintedSlippyMap.getHeight()/2,
+//             paletteMap,
+//             "^g+bv+bg+$",
+//             true
+//         );
+//         ImagePatternMatching.columnMatch(
+//             paintedSlippyMap,
+//             paintedSlippyMap.getWidth()/2,
+//             paletteMap,
+//             "^g+bv+bg+$",
+//             true
+//         );
 
         // enable "show downloaded areas"
         GuiHelper.runInEDTAndWaitWithException(() -> this.getShowDownloadedAreaMenuItem().doClick());
diff --git a/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java b/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
index 2a3c5c51e..f141b187d 100644
--- a/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
+++ b/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
@@ -272,7 +272,8 @@ public class JOSMTestRules implements TestRule {
                 new TileSourceRule.ColorSource(Color.WHITE, "White Tiles", 256),
                 new TileSourceRule.ColorSource(Color.BLACK, "Black Tiles", 256),
                 new TileSourceRule.ColorSource(Color.MAGENTA, "Magenta Tiles", 256),
-                new TileSourceRule.ColorSource(Color.GREEN, "Green Tiles", 256)
+                new TileSourceRule.ColorSource(Color.GREEN, "Green Tiles", 256),
+                new TileSourceRule.VStripeSource(Color.GREEN, Color.WHITE, "Green/white Stripes", 256)
             )
         );
     }
diff --git a/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java b/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java
index d43c4120c..9066b3355 100644
--- a/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java
+++ b/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java
@@ -161,6 +161,41 @@ public class TileSourceRule extends WireMockRule {
         }
     }
 
+    /**
+     * A vertically striped tile source
+     */
+    public static class VStripeSource extends ColorSource {
+        protected final Color rightColor
+;
+        public VStripeSource(Color leftColor, Color rightColor, String label, int tileSize) {
+            super(leftColor, label, tileSize);
+            this.rightColor = rightColor;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(this.color, this.rightColor, this.label, this.tileSize, this.getClass());
+        }
+
+        @Override
+        public byte[] generatePayloadBytes() {
+            final BufferedImage image = new BufferedImage(this.tileSize, this.tileSize, BufferedImage.TYPE_INT_RGB);
+            Graphics2D g = image.createGraphics();
+            g.setBackground(this.color);
+            g.clearRect(0, 0, image.getWidth(), image.getHeight());
+            g.setColor(this.rightColor);
+            g.fillRect(0, 0, image.getWidth()/2, image.getHeight());
+
+            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            try {
+                ImageIO.write(image, "png", outputStream);
+            } catch (IOException e) {
+                Logging.trace(e);
+            }
+            return outputStream.toByteArray();
+        }
+    }
+
     protected final List<ConstSource> sourcesList;
     protected final boolean clearLayerList;
     protected final boolean clearSlippyMapSources;
-- 
2.11.0

