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

Last change on this file since 7081 was 7081, checked in by Don-vip, 8 years ago

fixes for unit tests

File size: 1.6 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.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
10
11class MapCSSWithExtendedTextDirectivesTest {
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 == null
45    }
46}
Note: See TracBrowser for help on using the repository browser.