Changeset 7123 in josm
- Timestamp:
- 2014-05-14T13:43:45+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy
r7115 r7123 10 10 import org.openstreetmap.josm.data.coor.LatLon 11 11 import org.openstreetmap.josm.data.osm.DataSet 12 import org.openstreetmap.josm.data.osm.OsmPrimitive13 12 import org.openstreetmap.josm.data.osm.Way 14 13 import org.openstreetmap.josm.gui.mappaint.Environment … … 19 18 class MapCSSParserTest { 20 19 21 protected static OsmPrimitive getPrimitive(String key, String value) {22 def w = new Way()23 w.put(key, value)24 return w25 }26 27 20 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)) 29 22 } 30 23 … … 64 57 @Test 65 58 public void testClassMatching() throws Exception { 66 def css = new MapCSSStyleSource("") 67 getParser("" + 59 def css = new MapCSSStyleSource("" + 68 60 "way[highway=footway] { set .path; color: #FF6644; width: 2; }\n" + 69 61 "way[highway=path] { set path; color: brown; width: 2; }\n" + … … 71 63 "way.path { text:auto; text-color: green; text-position: line; text-offset: 5; }\n" + 72 64 "way!.path { color: orange; }\n" 73 ).sheet(css) 65 ) 66 css.loadStyleSource() 74 67 assert css.getErrors().isEmpty() 75 68 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); 77 70 assert "green".equals(mc1.getCascade("default").get("text-color", null, String.class)) 78 71 assert "brown".equals(mc1.getCascade("default").get("color", null, String.class)) 79 72 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); 81 74 assert "orange".equals(mc2.getCascade("default").get("color", null, String.class)) 82 75 assert mc2.getCascade("default").get("text-color", null, String.class) == null 83 76 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); 85 78 assert ColorHelper.html2color("#FF6644").equals(mc3.getCascade("default").get("color", null, Color.class)) 86 79 } … … 205 198 @Test 206 199 public void testTicket8568() throws Exception { 207 def sheet = new MapCSSStyleSource("") 208 getParser("" + 200 def sheet = new MapCSSStyleSource("" + 209 201 "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() 211 204 def mc = new MultiCascade() 212 205 sheet.apply(mc, TestUtils.createPrimitive("way foo=bar"), 20, null, false) … … 222 215 @Test 223 216 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() 226 220 def mc = new MultiCascade() 227 221 sheet.apply(mc, TestUtils.createPrimitive("way name=Foo"), 20, null, false) … … 232 226 assert mc.getCascade(Environment.DEFAULT_LAYER).get("text") == "15 Foo" 233 227 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() 236 231 sheet.apply(mc, TestUtils.createPrimitive("way rcn_ref=15 ref=1.5 name=Foo"), 20, null, false) 237 232 assert mc.getCascade(Environment.DEFAULT_LAYER).get("text") == "15 - 1.5 - Foo"
Note:
See TracChangeset
for help on using the changeset viewer.