source: josm/trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy@ 4074

Last change on this file since 4074 was 4074, checked in by bastiK, 13 years ago

mapcss: performance improvement for parent selector (by Gubaer)

File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint
3import java.awt.Color
4
5import org.junit.*
6import org.openstreetmap.josm.fixtures.JOSMFixture
7import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
8import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy
9import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.TagKeyReference
10class MapCSSWithExtendedTextDirectivesTest {
11
12
13 @BeforeClass
14 public static void createJOSMFixture(){
15 JOSMFixture.createUnitTestFixture().init()
16 }
17
18 @Test
19 public void createAutoTextElement() {
20 Cascade c = new Cascade()
21 c.put("text", new Keyword("auto"))
22
23 TextElement te = TextElement.create(c, Color.WHITE, false /* no default annotate */)
24 assert te.labelCompositionStrategy != null
25 assert te.labelCompositionStrategy instanceof DeriveLabelFromNameTagsCompositionStrategy
26 }
27
28 @Test
29 public void createTextElementComposingTextFromTag() {
30 Cascade c = new Cascade()
31 c.put("text", new TagKeyReference("my_name"))
32
33 TextElement te = TextElement.create(c, Color.WHITE, false /* no default annotate */)
34 assert te.labelCompositionStrategy != null
35 assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy
36 assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name"
37 }
38
39 @Test
40 public void createNullStrategy() {
41 Cascade c = new Cascade()
42
43 TextElement te = TextElement.create(c, Color.WHITE, false /* no default annotate */)
44 assert te.labelCompositionStrategy == null
45 }
46}
47
Note: See TracBrowser for help on using the repository browser.