Changeset 7123 in josm for trunk


Ignore:
Timestamp:
2014-05-14T13:43:45+02:00 (6 years ago)
Author:
simon04
Message:

Fix MapCSSParserTest tests

File:
1 edited

Legend:

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

    r7115 r7123  
    1010import org.openstreetmap.josm.data.coor.LatLon
    1111import org.openstreetmap.josm.data.osm.DataSet
    12 import org.openstreetmap.josm.data.osm.OsmPrimitive
    1312import org.openstreetmap.josm.data.osm.Way
    1413import org.openstreetmap.josm.gui.mappaint.Environment
     
    1918class MapCSSParserTest {
    2019
    21     protected static OsmPrimitive getPrimitive(String key, String value) {
    22         def w = new Way()
    23         w.put(key, value)
    24         return w
    25     }
    26 
    2720    protected static Environment getEnvironment(String key, String value) {
    28         return new Environment().withPrimitive(getPrimitive(key, value))
     21        return new Environment().withPrimitive(TestUtils.createPrimitive("way " + key + "=" + value))
    2922    }
    3023
     
    6457    @Test
    6558    public void testClassMatching() throws Exception {
    66         def css = new MapCSSStyleSource("")
    67         getParser("" +
     59        def css = new MapCSSStyleSource("" +
    6860                "way[highway=footway] { set .path; color: #FF6644; width: 2; }\n" +
    6961                "way[highway=path]    { set path; color: brown; width: 2; }\n" +
     
    7163                "way.path             { text:auto; text-color: green; text-position: line; text-offset: 5; }\n" +
    7264                "way!.path            { color: orange; }\n"
    73         ).sheet(css)
     65        )
     66        css.loadStyleSource()
    7467        assert css.getErrors().isEmpty()
    7568        def mc1 = new MultiCascade()
    76         css.apply(mc1, getPrimitive("highway", "path"), 1, null, false);
     69        css.apply(mc1, TestUtils.createPrimitive("way highway=path"), 1, null, false);
    7770        assert "green".equals(mc1.getCascade("default").get("text-color", null, String.class))
    7871        assert "brown".equals(mc1.getCascade("default").get("color", null, String.class))
    7972        def mc2 = new MultiCascade()
    80         css.apply(mc2, getPrimitive("highway", "residential"), 1, null, false);
     73        css.apply(mc2, TestUtils.createPrimitive("way highway=residential"), 1, null, false);
    8174        assert "orange".equals(mc2.getCascade("default").get("color", null, String.class))
    8275        assert mc2.getCascade("default").get("text-color", null, String.class) == null
    8376        def mc3 = new MultiCascade()
    84         css.apply(mc3, getPrimitive("highway", "footway"), 1, null, false);
     77        css.apply(mc3, TestUtils.createPrimitive("way highway=footway"), 1, null, false);
    8578        assert ColorHelper.html2color("#FF6644").equals(mc3.getCascade("default").get("color", null, Color.class))
    8679    }
     
    205198    @Test
    206199    public void testTicket8568() throws Exception {
    207         def sheet = new MapCSSStyleSource("")
    208         getParser("" +
     200        def sheet = new MapCSSStyleSource("" +
    209201                "way { width: 5; }\n" +
    210                 "way[keyA], way[keyB] { width: eval(prop(width)+10); }").sheet(sheet)
     202                "way[keyA], way[keyB] { width: eval(prop(width)+10); }")
     203        sheet.loadStyleSource()
    211204        def mc = new MultiCascade()
    212205        sheet.apply(mc, TestUtils.createPrimitive("way foo=bar"), 20, null, false)
     
    222215    @Test
    223216    public void testTicket8071() throws Exception {
    224         def sheet = new MapCSSStyleSource("")
    225         getParser("*[rcn_ref], *[name] {text: concat(tag(rcn_ref), \" \", tag(name)); }").sheet(sheet)
     217        def sheet = new MapCSSStyleSource("" +
     218                "*[rcn_ref], *[name] {text: concat(tag(rcn_ref), \" \", tag(name)); }")
     219        sheet.loadStyleSource()
    226220        def mc = new MultiCascade()
    227221        sheet.apply(mc, TestUtils.createPrimitive("way name=Foo"), 20, null, false)
     
    232226        assert mc.getCascade(Environment.DEFAULT_LAYER).get("text") == "15 Foo"
    233227
    234         sheet = new MapCSSStyleSource("")
    235         getParser("*[rcn_ref], *[name] {text: join(\" - \", tag(rcn_ref), tag(ref), tag(name)); }").sheet(sheet)
     228        sheet = new MapCSSStyleSource("" +
     229                "*[rcn_ref], *[name] {text: join(\" - \", tag(rcn_ref), tag(ref), tag(name)); }")
     230        sheet.loadStyleSource()
    236231        sheet.apply(mc, TestUtils.createPrimitive("way rcn_ref=15 ref=1.5 name=Foo"), 20, null, false)
    237232        assert mc.getCascade(Environment.DEFAULT_LAYER).get("text") == "15 - 1.5 - Foo"
Note: See TracChangeset for help on using the changeset viewer.