Changeset 17742 in josm
- Timestamp:
- 2021-04-11T12:35:11+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
r17604 r17742 108 108 MultiCascade mc1 = new MultiCascade(); 109 109 css.apply(mc1, OsmUtils.createPrimitive("way highway=path"), 1, false); 110 assertEquals("green", mc1.getCascade( "default").get("text-color", null, String.class));111 assertEquals("brown", mc1.getCascade( "default").get("color", null, String.class));110 assertEquals("green", mc1.getCascade(null).get("text-color", null, String.class)); 111 assertEquals("brown", mc1.getCascade(null).get("color", null, String.class)); 112 112 MultiCascade mc2 = new MultiCascade(); 113 113 css.apply(mc2, OsmUtils.createPrimitive("way highway=residential"), 1, false); 114 assertEquals("orange", mc2.getCascade( "default").get("color", null, String.class));115 assertNull(mc2.getCascade( "default").get("text-color", null, String.class));114 assertEquals("orange", mc2.getCascade(null).get("color", null, String.class)); 115 assertNull(mc2.getCascade(null).get("text-color", null, String.class)); 116 116 MultiCascade mc3 = new MultiCascade(); 117 117 css.apply(mc3, OsmUtils.createPrimitive("way highway=footway"), 1, false); 118 assertEquals(ColorHelper.html2color("#FF6644"), mc3.getCascade( "default").get("color", null, Color.class));118 assertEquals(ColorHelper.html2color("#FF6644"), mc3.getCascade(null).get("color", null, Color.class)); 119 119 } 120 120 … … 350 350 MultiCascade mc = new MultiCascade(); 351 351 sheet.apply(mc, OsmUtils.createPrimitive("way foo=bar"), 20, false); 352 assertEquals(Float.valueOf(5f), mc.getCascade( Environment.DEFAULT_LAYER).get("width"));352 assertEquals(Float.valueOf(5f), mc.getCascade(null).get("width")); 353 353 sheet.apply(mc, OsmUtils.createPrimitive("way keyA=true"), 20, false); 354 assertEquals(Float.valueOf(15f), mc.getCascade( Environment.DEFAULT_LAYER).get("width"));354 assertEquals(Float.valueOf(15f), mc.getCascade(null).get("width")); 355 355 sheet.apply(mc, OsmUtils.createPrimitive("way keyB=true"), 20, false); 356 assertEquals(Float.valueOf(15f), mc.getCascade( Environment.DEFAULT_LAYER).get("width"));356 assertEquals(Float.valueOf(15f), mc.getCascade(null).get("width")); 357 357 sheet.apply(mc, OsmUtils.createPrimitive("way keyA=true keyB=true"), 20, false); 358 assertEquals(Float.valueOf(15f), mc.getCascade( Environment.DEFAULT_LAYER).get("width"));358 assertEquals(Float.valueOf(15f), mc.getCascade(null).get("width")); 359 359 } 360 360 … … 366 366 MultiCascade mc = new MultiCascade(); 367 367 sheet.apply(mc, OsmUtils.createPrimitive("way name=Foo"), 20, false); 368 assertEquals(" Foo", mc.getCascade( Environment.DEFAULT_LAYER).get("text"));368 assertEquals(" Foo", mc.getCascade(null).get("text")); 369 369 sheet.apply(mc, OsmUtils.createPrimitive("way rcn_ref=15"), 20, false); 370 assertEquals("15 ", mc.getCascade( Environment.DEFAULT_LAYER).get("text"));370 assertEquals("15 ", mc.getCascade(null).get("text")); 371 371 sheet.apply(mc, OsmUtils.createPrimitive("way rcn_ref=15 name=Foo"), 20, false); 372 assertEquals("15 Foo", mc.getCascade( Environment.DEFAULT_LAYER).get("text"));372 assertEquals("15 Foo", mc.getCascade(null).get("text")); 373 373 374 374 sheet = new MapCSSStyleSource("" + … … 376 376 sheet.loadStyleSource(); 377 377 sheet.apply(mc, OsmUtils.createPrimitive("way rcn_ref=15 ref=1.5 name=Foo"), 20, false); 378 assertEquals("15 - 1.5 - Foo", mc.getCascade( Environment.DEFAULT_LAYER).get("text"));378 assertEquals("15 - 1.5 - Foo", mc.getCascade(null).get("text")); 379 379 } 380 380 … … 384 384 getParser("{color: testcolour1#88DD22}").declaration().instructions.get(0).execute(e); 385 385 Color expected = new Color(0x88DD22); 386 assertEquals(expected, e.getCascade( Environment.DEFAULT_LAYER).get("color"));386 assertEquals(expected, e.getCascade(null).get("color")); 387 387 } 388 388 … … 392 392 getParser("{color: testcolour2#12345678}").declaration().instructions.get(0).execute(e); 393 393 Color expected = new Color(0x12, 0x34, 0x56, 0x78); 394 assertEquals(expected, e.getCascade( Environment.DEFAULT_LAYER).get("color"));394 assertEquals(expected, e.getCascade(null).get("color")); 395 395 } 396 396 … … 457 457 assertTrue(source.rules.get(0).matches(e)); 458 458 source.rules.get(0).declaration.execute(e); 459 assertEquals("x2;x10", e.getCascade( Environment.DEFAULT_LAYER).get("refs", null, String.class));459 assertEquals("x2;x10", e.getCascade(null).get("refs", null, String.class)); 460 460 } 461 461 … … 472 472 assertTrue(source.rules.get(0).matches(e)); 473 473 source.rules.get(0).declaration.execute(e); 474 assertEquals(Functions.join(",", "Alpha", "Beta"), e.getCascade( Environment.DEFAULT_LAYER).get("sorted", null, String.class));474 assertEquals(Functions.join(",", "Alpha", "Beta"), e.getCascade(null).get("sorted", null, String.class)); 475 475 476 476 source = new MapCSSStyleSource("way[ref] {sorted: join_list(\",\", sort_list(split(\";\", tag(\"ref\"))));}"); … … 479 479 assertTrue(source.rules.get(0).matches(e)); 480 480 source.rules.get(0).declaration.execute(e); 481 assertEquals(Functions.join(",", "A8", "A9"), e.getCascade( Environment.DEFAULT_LAYER).get("sorted", null, String.class));481 assertEquals(Functions.join(",", "A8", "A9"), e.getCascade(null).get("sorted", null, String.class)); 482 482 } 483 483 … … 537 537 assertTrue(source.rules.get(0).matches(e)); 538 538 source.rules.get(0).declaration.execute(e); 539 assertEquals((Integer) 1, e.getCascade( Environment.DEFAULT_LAYER).get("roles", null, Integer.class));539 assertEquals((Integer) 1, e.getCascade(null).get("roles", null, Integer.class)); 540 540 } 541 541 … … 589 589 590 590 sheet.apply(mc, OsmUtils.createPrimitive("way x=4 y=6 z=8 u=100"), 20, false); 591 assertEquals(Float.valueOf(4.0f), mc.getCascade( Environment.DEFAULT_LAYER).get("min_value", Float.NaN, Float.class));592 assertEquals(Float.valueOf(8.0f), mc.getCascade( Environment.DEFAULT_LAYER).get("max_value", Float.NaN, Float.class));591 assertEquals(Float.valueOf(4.0f), mc.getCascade(null).get("min_value", Float.NaN, Float.class)); 592 assertEquals(Float.valueOf(8.0f), mc.getCascade(null).get("max_value", Float.NaN, Float.class)); 593 593 594 594 sheet.apply(mc, OsmUtils.createPrimitive("way x=4 y=6 widths=1;2;8;56;3;a"), 20, false); 595 assertEquals(Float.valueOf(4f), mc.getCascade( Environment.DEFAULT_LAYER).get("min_value", -777f, Float.class));596 assertEquals(Float.valueOf(6f), mc.getCascade( Environment.DEFAULT_LAYER).get("max_value", -777f, Float.class));597 assertEquals(Float.valueOf(56f), mc.getCascade( Environment.DEFAULT_LAYER).get("max_split", -777f, Float.class));595 assertEquals(Float.valueOf(4f), mc.getCascade(null).get("min_value", -777f, Float.class)); 596 assertEquals(Float.valueOf(6f), mc.getCascade(null).get("max_value", -777f, Float.class)); 597 assertEquals(Float.valueOf(56f), mc.getCascade(null).get("max_split", -777f, Float.class)); 598 598 } 599 599
Note:
See TracChangeset
for help on using the changeset viewer.