Changeset 8784 in josm for trunk


Ignore:
Timestamp:
2015-09-22T20:37:48+02:00 (9 years ago)
Author:
simon04
Message:

see #11278 - Add test case w.r.t. parent_tag

This checks whether the child's tag equals the parent's tag.

File:
1 edited

Legend:

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

    r8775 r8784  
    1010import org.openstreetmap.josm.data.osm.DataSet
    1111import org.openstreetmap.josm.data.osm.OsmUtils
     12import org.openstreetmap.josm.data.osm.Node
    1213import org.openstreetmap.josm.data.osm.Way
    1314import org.openstreetmap.josm.gui.mappaint.Environment
     
    231232
    232233    @Test
     234    public void testParentTag() throws Exception {
     235        def c1 = getParser("way[foo] > node[tag(\"foo\")=parent_tag(\"foo\")] {}").child_selector()
     236        def ds = new DataSet()
     237        def w1 = new Way()
     238        def w2 = new Way()
     239        def n1 = new Node(new LatLon(1, 1))
     240        def n2 = new Node(new LatLon(2, 2))
     241        w1.put("foo", "123")
     242        w2.put("foo", "123")
     243        n1.put("foo", "123")
     244        n2.put("foo", "0")
     245        ds.addPrimitive(w1)
     246        ds.addPrimitive(n1)
     247        ds.addPrimitive(n2)
     248        w1.addNode(n1)
     249        w2.addNode(n2)
     250        assert c1.matches(new Environment(n1))
     251        assert !c1.matches(new Environment(n2))
     252        assert !c1.matches(new Environment(w1))
     253        assert !c1.matches(new Environment(w2))
     254        n1.put("foo", "0")
     255        assert !c1.matches(new Environment(n1))
     256        n1.put("foo", "123")
     257        assert c1.matches(new Environment(n1))
     258    }
     259
     260    @Test
    233261    public void testTicket8568() throws Exception {
    234262        def sheet = new MapCSSStyleSource("" +
Note: See TracChangeset for help on using the changeset viewer.