Ticket #15630: v1-0001-Debugging-test-commit.patch

File v1-0001-Debugging-test-commit.patch, 5.0 KB (added by ris, 8 years ago)
  • test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    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 b public class MinimapDialogTest {  
    413413     */
    414414    @Test
    415415    public void testShowDownloadedArea() throws Exception {
    416         Main.pref.put("slippy_map_chooser.mapstyle", "Green Tiles");
     416        Main.pref.put("slippy_map_chooser.mapstyle", "Green/white Stripes");
    417417        Main.pref.putBoolean("slippy_map_chooser.show_downloaded_area", false);
    418418
    419419        DataSet dataSet = new DataSet();
    public class MinimapDialogTest {  
    459459            .build();
    460460
    461461        // assert downloaded areas are not drawn
    462         ImagePatternMatching.rowMatch(
    463             paintedSlippyMap,
    464             paintedSlippyMap.getHeight()/2,
    465             paletteMap,
    466             "^g+bv+bg+$",
    467             true
    468         );
    469         ImagePatternMatching.columnMatch(
    470             paintedSlippyMap,
    471             paintedSlippyMap.getWidth()/2,
    472             paletteMap,
    473             "^g+bv+bg+$",
    474             true
    475         );
     462//         ImagePatternMatching.rowMatch(
     463//             paintedSlippyMap,
     464//             paintedSlippyMap.getHeight()/2,
     465//             paletteMap,
     466//             "^g+bv+bg+$",
     467//             true
     468//         );
     469//         ImagePatternMatching.columnMatch(
     470//             paintedSlippyMap,
     471//             paintedSlippyMap.getWidth()/2,
     472//             paletteMap,
     473//             "^g+bv+bg+$",
     474//             true
     475//         );
    476476
    477477        // enable "show downloaded areas"
    478478        GuiHelper.runInEDTAndWaitWithException(() -> this.getShowDownloadedAreaMenuItem().doClick());
  • test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    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 b public class JOSMTestRules implements TestRule {  
    272272                new TileSourceRule.ColorSource(Color.WHITE, "White Tiles", 256),
    273273                new TileSourceRule.ColorSource(Color.BLACK, "Black Tiles", 256),
    274274                new TileSourceRule.ColorSource(Color.MAGENTA, "Magenta Tiles", 256),
    275                 new TileSourceRule.ColorSource(Color.GREEN, "Green Tiles", 256)
     275                new TileSourceRule.ColorSource(Color.GREEN, "Green Tiles", 256),
     276                new TileSourceRule.VStripeSource(Color.GREEN, Color.WHITE, "Green/white Stripes", 256)
    276277            )
    277278        );
    278279    }
  • test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java

    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 b public class TileSourceRule extends WireMockRule {  
    161161        }
    162162    }
    163163
     164    /**
     165     * A vertically striped tile source
     166     */
     167    public static class VStripeSource extends ColorSource {
     168        protected final Color rightColor
     169;
     170        public VStripeSource(Color leftColor, Color rightColor, String label, int tileSize) {
     171            super(leftColor, label, tileSize);
     172            this.rightColor = rightColor;
     173        }
     174
     175        @Override
     176        public int hashCode() {
     177            return Objects.hash(this.color, this.rightColor, this.label, this.tileSize, this.getClass());
     178        }
     179
     180        @Override
     181        public byte[] generatePayloadBytes() {
     182            final BufferedImage image = new BufferedImage(this.tileSize, this.tileSize, BufferedImage.TYPE_INT_RGB);
     183            Graphics2D g = image.createGraphics();
     184            g.setBackground(this.color);
     185            g.clearRect(0, 0, image.getWidth(), image.getHeight());
     186            g.setColor(this.rightColor);
     187            g.fillRect(0, 0, image.getWidth()/2, image.getHeight());
     188
     189            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
     190            try {
     191                ImageIO.write(image, "png", outputStream);
     192            } catch (IOException e) {
     193                Logging.trace(e);
     194            }
     195            return outputStream.toByteArray();
     196        }
     197    }
     198
    164199    protected final List<ConstSource> sourcesList;
    165200    protected final boolean clearLayerList;
    166201    protected final boolean clearSlippyMapSources;