Changeset 8775 in josm for trunk/test


Ignore:
Timestamp:
2015-09-21T21:45:50+02:00 (4 years ago)
Author:
simon04
Message:

fix #8170 - MapCSS: add functions parent_tags(key) and join_list(sep, list)

The method parent_tags(key) returns all parent's values for key as a list ordered by a natural ordering.
The method join_list(sep, list) joins the elements of list to one string separated by sep.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy

    r8657 r8775  
    322322
    323323    @Test
     324    public void testParentTags() throws Exception {
     325        def ds = new DataSet()
     326        def n = new org.openstreetmap.josm.data.osm.Node(new LatLon(1, 2))
     327        n.put("foo", "bar")
     328        def w1 = new Way()
     329        w1.put("ref", "x10")
     330        def w2 = new Way()
     331        w2.put("ref", "x2")
     332        def w3 = new Way()
     333        ds.addPrimitive(n)
     334        ds.addPrimitive(w1)
     335        ds.addPrimitive(w2)
     336        ds.addPrimitive(w3)
     337        w1.addNode(n)
     338        w2.addNode(n)
     339        w3.addNode(n)
     340
     341        MapCSSStyleSource source = new MapCSSStyleSource("node[foo=bar] {refs: join_list(\";\", parent_tags(\"ref\"));}")
     342        source.loadStyleSource()
     343        assert source.rules.size() == 1
     344        def e = new Environment(n, new MultiCascade(), Environment.DEFAULT_LAYER, null)
     345        assert source.rules.get(0).selector.matches(e)
     346        source.rules.get(0).declaration.execute(e)
     347        assert e.getCascade(Environment.DEFAULT_LAYER).get("refs", null, String.class) == "x2;x10"
     348    }
     349
     350    @Test
    324351    public void testSiblingSelectorInterpolation() throws Exception {
    325352        def s1 = (Selector.ChildOrParentSelector) getParser(
Note: See TracChangeset for help on using the changeset viewer.