1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint
|
---|
3 | import java.awt.Color
|
---|
4 |
|
---|
5 | import org.junit.*
|
---|
6 | import org.openstreetmap.josm.fixtures.JOSMFixture
|
---|
7 | import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
|
---|
8 | import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy
|
---|
9 | import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.TagKeyReference
|
---|
10 | class 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 |
|
---|