Changeset 11698 in josm


Ignore:
Timestamp:
2017-03-08T16:07:36+01:00 (8 years ago)
Author:
michael2402
Message:

Add test that tests if elements are ordered correctly.

Location:
trunk/test
Files:
4 added
1 edited

Legend:

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

    r11697 r11698  
    3434import org.openstreetmap.josm.data.Bounds;
    3535import org.openstreetmap.josm.data.osm.DataSet;
     36import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3637import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    3738import org.openstreetmap.josm.gui.NavigatableComponent;
     
    7071    /**
    7172     * The different configurations of this test.
     73     *
    7274     * @return The parameters.
    7375     */
     
    8890
    8991                /** Tests dashed ways. */
    90                 new TestConfig("way-dashes", AREA_DEFAULT)
     92                new TestConfig("way-dashes", AREA_DEFAULT),
     93
     94                /** Tests if all styles are sorted correctly. Tests {@link StyleRecord#compareTo(StyleRecord)} */
     95                new TestConfig("order", AREA_DEFAULT)
    9196
    9297                ).map(e -> new Object[] {e, e.testDirectory})
     
    113118
    114119        List<String> fonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
    115         for(String font : testConfig.fonts) {
     120        for (String font : testConfig.fonts) {
    116121            Assume.assumeTrue("Test requires font: " + font, fonts.contains(font));
    117122        }
     
    138143            }
    139144            MapPaintStyles.getStyles().setStyleSources(Arrays.asList(source));
     145            MapPaintStyles.fireMapPaintSylesUpdated();
     146            MapPaintStyles.getStyles().clearCached();
    140147
    141148        } finally {
     
    162169        };
    163170        nc.zoomTo(testConfig.testArea);
    164         dataSet.allPrimitives().stream().forEach(n -> n.setHighlighted(n.isKeyTrue("highlight")));
    165         dataSet.allPrimitives().stream().filter(n -> n.isKeyTrue("disabled")).forEach(n -> n.setDisabledState(false));
     171        dataSet.allPrimitives().stream().forEach(this::loadPrimitiveStyle);
     172        dataSet.setSelected(dataSet.allPrimitives().stream().filter(n -> n.isKeyTrue("selected")).collect(Collectors.toList()));
     173
    166174        Graphics2D g = image.createGraphics();
    167175        // Force all render hints to be defaults - do not use platform values
     
    217225            ImageIO.write(diffImage, "png", new File(testConfig.getTestDirectory() + "/test-differences.png"));
    218226
    219             fail(MessageFormat.format("Images for test {1} differ at {2} points: {3}",
     227            fail(MessageFormat.format("Images for test {0} differ at {1} points: {2}",
    220228                    testConfig.testDirectory, differencePoints.size(), differences.toString()));
     229        }
     230    }
     231
     232    private void loadPrimitiveStyle(OsmPrimitive n) {
     233        n.setHighlighted(n.isKeyTrue("highlight"));
     234        if (n.isKeyTrue("disabled")) {
     235            n.setDisabledState(false);
    221236        }
    222237    }
Note: See TracChangeset for help on using the changeset viewer.