[3988] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.gui.mappaint
|
---|
| 3 |
|
---|
[4069] | 4 | import java.awt.Color
|
---|
[3988] | 5 |
|
---|
[4069] | 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.TagLookupCompositionStrategy
|
---|
[3988] | 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)
|
---|
| 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", "my_name")
|
---|
| 32 |
|
---|
| 33 | TextElement te = TextElement.create(c, Color.WHITE)
|
---|
| 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 createTextElementComposingTextFromTag_2() {
|
---|
| 41 | Cascade c = new Cascade()
|
---|
| 42 | c.put("text", new Keyword("my_name"))
|
---|
| 43 |
|
---|
| 44 | TextElement te = TextElement.create(c, Color.WHITE)
|
---|
| 45 | assert te.labelCompositionStrategy != null
|
---|
| 46 | assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy
|
---|
| 47 | assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name"
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | @Test
|
---|
| 51 | public void createNullStrategy() {
|
---|
| 52 | Cascade c = new Cascade()
|
---|
| 53 |
|
---|
| 54 | TextElement te = TextElement.create(c, Color.WHITE)
|
---|
| 55 | assert te.labelCompositionStrategy == null
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 |
|
---|