Index: trunk/test/data/renderer/order/data.osm
===================================================================
--- trunk/test/data/renderer/order/data.osm (revision 11698)
+++ trunk/test/data/renderer/order/data.osm (revision 11698)
@@ -0,0 +1,606 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: trunk/test/data/renderer/order/style.mapcss
===================================================================
--- trunk/test/data/renderer/order/style.mapcss (revision 11698)
+++ trunk/test/data/renderer/order/style.mapcss (revision 11698)
@@ -0,0 +1,83 @@
+canvas {
+ default-points: true;
+ default-lines: false;
+}
+
+way[color=A] {
+ color: blue;
+ fill-color: blue;
+ width: 5;
+}
+
+way[color=B] {
+ color: green;
+ fill-color: green;
+ width: 5;
+}
+
+way[color=A]:selected {
+}
+
+way[color=B]:selected {
+}
+
+node[color=EndNode] {
+ symbol-shape: circle;
+ symbol-size: 2;
+ symbol-fill-color: yellow;
+}
+
+node[color=N] {
+ symbol-shape: circle;
+ symbol-size: 20;
+ symbol-fill-color: blue;
+ major-z-index: 4.1;
+}
+
+way[z-index] {
+ z-index: eval(tag("z-index"));
+}
+
+way[test=object-z-index-1] {
+ object-z-index: 10.000;
+}
+
+way[test=object-z-index-1]::B {
+ object-z-index: 9.999;
+ color: yellow;
+ width: 5;
+}
+
+way[test=object-z-index-1b] {
+ object-z-index: 9.999;
+}
+
+way[test=object-z-index-1b]::B {
+ object-z-index: 10.000;
+ color: yellow;
+ width: 5;
+}
+
+way[test=object-z-index-2] {
+ object-z-index: 0.00;
+}
+
+way[test=object-z-index-2]::B {
+ object-z-index: 0.01;
+ color: yellow;
+ width: 5;
+}
+
+way[test=object-z-index-2b] {
+ object-z-index: 0.02;
+}
+
+way[test=object-z-index-2b]::B {
+ object-z-index: 0.01;
+ color: yellow;
+ width: 5;
+}
+
+way[major-z-index] {
+ major-z-index: eval(tag("major-z-index"));
+}
Index: trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java (revision 11697)
+++ trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java (revision 11698)
@@ -34,4 +34,5 @@
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
import org.openstreetmap.josm.gui.NavigatableComponent;
@@ -70,4 +71,5 @@
/**
* The different configurations of this test.
+ *
* @return The parameters.
*/
@@ -88,5 +90,8 @@
/** Tests dashed ways. */
- new TestConfig("way-dashes", AREA_DEFAULT)
+ new TestConfig("way-dashes", AREA_DEFAULT),
+
+ /** Tests if all styles are sorted correctly. Tests {@link StyleRecord#compareTo(StyleRecord)} */
+ new TestConfig("order", AREA_DEFAULT)
).map(e -> new Object[] {e, e.testDirectory})
@@ -113,5 +118,5 @@
List fonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
- for(String font : testConfig.fonts) {
+ for (String font : testConfig.fonts) {
Assume.assumeTrue("Test requires font: " + font, fonts.contains(font));
}
@@ -138,4 +143,6 @@
}
MapPaintStyles.getStyles().setStyleSources(Arrays.asList(source));
+ MapPaintStyles.fireMapPaintSylesUpdated();
+ MapPaintStyles.getStyles().clearCached();
} finally {
@@ -162,6 +169,7 @@
};
nc.zoomTo(testConfig.testArea);
- dataSet.allPrimitives().stream().forEach(n -> n.setHighlighted(n.isKeyTrue("highlight")));
- dataSet.allPrimitives().stream().filter(n -> n.isKeyTrue("disabled")).forEach(n -> n.setDisabledState(false));
+ dataSet.allPrimitives().stream().forEach(this::loadPrimitiveStyle);
+ dataSet.setSelected(dataSet.allPrimitives().stream().filter(n -> n.isKeyTrue("selected")).collect(Collectors.toList()));
+
Graphics2D g = image.createGraphics();
// Force all render hints to be defaults - do not use platform values
@@ -217,6 +225,13 @@
ImageIO.write(diffImage, "png", new File(testConfig.getTestDirectory() + "/test-differences.png"));
- fail(MessageFormat.format("Images for test {1} differ at {2} points: {3}",
+ fail(MessageFormat.format("Images for test {0} differ at {1} points: {2}",
testConfig.testDirectory, differencePoints.size(), differences.toString()));
+ }
+ }
+
+ private void loadPrimitiveStyle(OsmPrimitive n) {
+ n.setHighlighted(n.isKeyTrue("highlight"));
+ if (n.isKeyTrue("disabled")) {
+ n.setDisabledState(false);
}
}