Changeset 12978 in josm for trunk/test/functional/org


Ignore:
Timestamp:
2017-10-10T15:04:35+02:00 (7 years ago)
Author:
bastiK
Message:

promote old MapCSS reference file to MapCSSRendererTest checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java

    r12966 r12978  
    117117
    118118                /** Tests text along a way */
    119                 new TestConfig("way-text", AREA_DEFAULT)
     119                new TestConfig("way-text", AREA_DEFAULT),
     120
     121                /** Another test for node shapes */
     122                new TestConfig("node-shapes2").setImageWidth(600),
     123                /** Tests default values for node shapes */
     124                new TestConfig("node-shapes-default"),
     125                /** Tests node shapes with both fill and stroke combined */
     126                new TestConfig("node-shapes-combined"),
     127                /** Another test for dashed ways */
     128                new TestConfig("way-dashes2"),
     129                /** Tests node text placement */
     130                new TestConfig("node-text2"),
     131                /** Tests relation link selector */
     132                new TestConfig("relation-linkselector"),
     133                /** Tests parent selector on relation */
     134                new TestConfig("relation-parentselector")
     135
    120136                ).map(e -> new Object[] {e, e.testDirectory})
    121137                .collect(Collectors.toList());
     
    162178
    163179        ProjectionBounds pb = new ProjectionBounds();
    164         pb.extend(Main.getProjection().latlon2eastNorth(testConfig.testArea.getMin()));
    165         pb.extend(Main.getProjection().latlon2eastNorth(testConfig.testArea.getMax()));
    166         double scale = (pb.maxEast - pb.minEast) / IMAGE_SIZE;
     180        pb.extend(Main.getProjection().latlon2eastNorth(testConfig.getTestArea().getMin()));
     181        pb.extend(Main.getProjection().latlon2eastNorth(testConfig.getTestArea().getMax()));
     182        double scale = (pb.maxEast - pb.minEast) / testConfig.imageWidth;
    167183
    168184        RenderingHelper.StyleData sd = new RenderingHelper.StyleData();
    169185        sd.styleUrl = testConfig.getStyleSourceUrl();
    170         RenderingHelper rh = new RenderingHelper(dataSet, testConfig.testArea, scale, Collections.singleton(sd));
     186        RenderingHelper rh = new RenderingHelper(dataSet, testConfig.getTestArea(), scale, Collections.singleton(sd));
    171187        rh.setFillBackground(false);
    172188        BufferedImage image = rh.render();
     
    180196
    181197        // now compute differences:
    182         assertEquals(IMAGE_SIZE, reference.getWidth());
    183         assertEquals(IMAGE_SIZE, reference.getHeight());
     198        assertEquals(image.getWidth(), reference.getWidth());
     199        assertEquals(image.getHeight(), reference.getHeight());
    184200
    185201        StringBuilder differences = new StringBuilder();
     
    246262    private static class TestConfig {
    247263        private final String testDirectory;
    248         private final Bounds testArea;
     264        private Bounds testArea;
    249265        private final ArrayList<String> fonts = new ArrayList<>();
     266        private DataSet ds;
     267        private int imageWidth = IMAGE_SIZE;
    250268
    251269        TestConfig(String testDirectory, Bounds testArea) {
     
    254272        }
    255273
     274        TestConfig(String testDirectory) {
     275            this.testDirectory = testDirectory;
     276        }
     277
     278        public TestConfig setImageWidth(int imageWidth) {
     279            this.imageWidth = imageWidth;
     280            return this;
     281        }
     282
    256283        public TestConfig usesFont(String string) {
    257284            this.fonts.add(string);
     
    272299
    273300        public DataSet getOsmDataSet() throws FileNotFoundException, IllegalDataException {
    274             return OsmReader.parseDataSet(new FileInputStream(getTestDirectory() + "/data.osm"), null);
     301            if (ds == null) {
     302                ds = OsmReader.parseDataSet(new FileInputStream(getTestDirectory() + "/data.osm"), null);
     303            }
     304            return ds;
     305        }
     306
     307        public Bounds getTestArea() throws FileNotFoundException, IllegalDataException {
     308            if (testArea == null) {
     309                testArea = getOsmDataSet().getDataSourceBounds().get(0);
     310            }
     311            return testArea;
    275312        }
    276313
Note: See TracChangeset for help on using the changeset viewer.