1 | // License: GPL. For details, see LICENSE file. |
---|
2 | package org.openstreetmap.josm.gui.mappaint |
---|
3 | |
---|
4 | import java.awt.Color; |
---|
5 | |
---|
6 | import org.junit.*; |
---|
7 | import org.openstreetmap.josm.fixtures.JOSMFixture |
---|
8 | import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy |
---|
9 | import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy |
---|
10 | import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy |
---|
11 | class MapCSSWithExtendedTextDirectivesTest { |
---|
12 | |
---|
13 | |
---|
14 | @BeforeClass |
---|
15 | public static void createJOSMFixture(){ |
---|
16 | JOSMFixture.createUnitTestFixture().init() |
---|
17 | } |
---|
18 | |
---|
19 | @Test |
---|
20 | public void createAutoTextElement() { |
---|
21 | Cascade c = new Cascade() |
---|
22 | c.put("text", new Keyword("auto")) |
---|
23 | |
---|
24 | TextElement te = TextElement.create(c, Color.WHITE) |
---|
25 | assert te.labelCompositionStrategy != null |
---|
26 | assert te.labelCompositionStrategy instanceof DeriveLabelFromNameTagsCompositionStrategy |
---|
27 | } |
---|
28 | |
---|
29 | @Test |
---|
30 | public void createTextElementComposingTextFromTag() { |
---|
31 | Cascade c = new Cascade() |
---|
32 | c.put("text", "my_name") |
---|
33 | |
---|
34 | TextElement te = TextElement.create(c, Color.WHITE) |
---|
35 | assert te.labelCompositionStrategy != null |
---|
36 | assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy |
---|
37 | assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name" |
---|
38 | } |
---|
39 | |
---|
40 | @Test |
---|
41 | public void createTextElementComposingTextFromTag_2() { |
---|
42 | Cascade c = new Cascade() |
---|
43 | c.put("text", new Keyword("my_name")) |
---|
44 | |
---|
45 | TextElement te = TextElement.create(c, Color.WHITE) |
---|
46 | assert te.labelCompositionStrategy != null |
---|
47 | assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy |
---|
48 | assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name" |
---|
49 | } |
---|
50 | |
---|
51 | @Test |
---|
52 | public void createNullStrategy() { |
---|
53 | Cascade c = new Cascade() |
---|
54 | |
---|
55 | TextElement te = TextElement.create(c, Color.WHITE) |
---|
56 | assert te.labelCompositionStrategy == null |
---|
57 | } |
---|
58 | } |
---|
59 | // License: GPL. For details, see LICENSE file. |
---|
60 | package org.openstreetmap.josm.gui.mappaint |
---|
61 | |
---|
62 | import java.awt.Color; |
---|
63 | |
---|
64 | import org.junit.*; |
---|
65 | import org.openstreetmap.josm.fixtures.JOSMFixture |
---|
66 | import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy |
---|
67 | import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy |
---|
68 | import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy |
---|
69 | class MapCSSWithExtendedTextDirectivesTest { |
---|
70 | |
---|
71 | |
---|
72 | @BeforeClass |
---|
73 | public static void createJOSMFixture(){ |
---|
74 | JOSMFixture.createUnitTestFixture().init() |
---|
75 | } |
---|
76 | |
---|
77 | @Test |
---|
78 | public void createAutoTextElement() { |
---|
79 | Cascade c = new Cascade() |
---|
80 | c.put("text", new Keyword("auto")) |
---|
81 | |
---|
82 | TextElement te = TextElement.create(c, Color.WHITE) |
---|
83 | assert te.labelCompositionStrategy != null |
---|
84 | assert te.labelCompositionStrategy instanceof DeriveLabelFromNameTagsCompositionStrategy |
---|
85 | } |
---|
86 | |
---|
87 | @Test |
---|
88 | public void createTextElementComposingTextFromTag() { |
---|
89 | Cascade c = new Cascade() |
---|
90 | c.put("text", "my_name") |
---|
91 | |
---|
92 | TextElement te = TextElement.create(c, Color.WHITE) |
---|
93 | assert te.labelCompositionStrategy != null |
---|
94 | assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy |
---|
95 | assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name" |
---|
96 | } |
---|
97 | |
---|
98 | @Test |
---|
99 | public void createTextElementComposingTextFromTag_2() { |
---|
100 | Cascade c = new Cascade() |
---|
101 | c.put("text", new Keyword("my_name")) |
---|
102 | |
---|
103 | TextElement te = TextElement.create(c, Color.WHITE) |
---|
104 | assert te.labelCompositionStrategy != null |
---|
105 | assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy |
---|
106 | assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name" |
---|
107 | } |
---|
108 | |
---|
109 | @Test |
---|
110 | public void createNullStrategy() { |
---|
111 | Cascade c = new Cascade() |
---|
112 | |
---|
113 | TextElement te = TextElement.create(c, Color.WHITE) |
---|
114 | assert te.labelCompositionStrategy == null |
---|
115 | } |
---|
116 | } |
---|