Changeset 3991 in josm


Ignore:
Timestamp:
2011-03-14T00:25:41+01:00 (9 years ago)
Author:
bastiK
Message:

fix wrongly applied patch

Location:
trunk/test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/data/styles/label-from-tag.mapcss

    r3989 r3991  
    1818   font-size: 12;
    1919}
    20 
    21 /*
    22  * Simple test style sheet. Includes a style for nodes where the label is derived
    23  * from the value of a specific tag.
    24  *
    25  */
    26  
    27 meta {
    28     title: "Test style - Deriving labels from tags";
    29 }
    30 
    31 canvas {
    32     background-color: #000000;
    33 }
    34 
    35 node {
    36    text: my_label_tag;  /* take the value of the tag 'my_label_tag' as text */
    37    text-color: white;   
    38    font-size: 12;
    39 }
    40 
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategyTest.groovy

    r3988 r3991  
    6565    }
    6666}
    67 // License: GPL. For details, see LICENSE file.
    68 package org.openstreetmap.josm.gui.mappaint
    6967
    70 import org.junit.*
    71 import org.openstreetmap.josm.fixtures.JOSMFixture;
    72 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
    73 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy;
    74 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy
    75 import org.openstreetmap.josm.data.osm.Node;
    76 
    77 class LabelCompositionStrategyTest {
    78    
    79     @BeforeClass
    80     public static void createJOSMFixture(){
    81         JOSMFixture.createUnitTestFixture().init()
    82     }
    83 
    84     @Test
    85     public void createStaticLabelCompositionStrategy() {
    86         def n = new Node()
    87        
    88         def strat = new StaticLabelCompositionStrategy(null)
    89         assert strat.compose(n) == null
    90        
    91         strat = new StaticLabelCompositionStrategy("a label")
    92         assert strat.compose(n) == "a label"       
    93     }
    94    
    95     @Test
    96     public void createTagLookupCompositionStrategy() {
    97         def n = new Node()
    98         n.put("my-tag", "my-value")
    99        
    100         def strat = new TagLookupCompositionStrategy(null)
    101         assert strat.compose(n) == null
    102        
    103         strat = new TagLookupCompositionStrategy("name")
    104         assert strat.compose(n) == null
    105        
    106         strat = new TagLookupCompositionStrategy("my-tag")
    107         assert strat.compose(n) == "my-value"
    108     }
    109    
    110     @Test
    111     public void createDeriveLabelFromNameTagsCompositionStrategy() {
    112         def n
    113         def strat
    114        
    115         strat = new DeriveLabelFromNameTagsCompositionStrategy()
    116         strat.setNameTags(null)
    117         assert strat.getNameTags() == []
    118        
    119         strat = new DeriveLabelFromNameTagsCompositionStrategy()
    120         strat.setNameTags(["name", "brand"])
    121         assert strat.getNameTags() == ["name", "brand"]
    122        
    123         n = new Node()
    124         n.put("brand", "my brand")       
    125         assert strat.compose(n) == "my brand"
    126        
    127         n = new Node()
    128         n.put("name", "my name")
    129         n.put("brand", "my brand")
    130         assert strat.compose(n) == "my name"       
    131     }
    132 }
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy

    r3988 r3991  
    5757    }
    5858}
    59 // License: GPL. For details, see LICENSE file.
    60 package org.openstreetmap.josm.gui.mappaint
    6159
    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 }
Note: See TracChangeset for help on using the changeset viewer.