Changeset 7081 in josm for trunk/test/unit/org/openstreetmap/josm/gui
- Timestamp:
- 2014-05-09T04:49:54+02:00 (12 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui
- Files:
-
- 12 edited
-
JosmUserIdentityManagerTest.groovy (modified) (1 diff)
-
SystemOfMeasurementTest.java (modified) (2 diffs)
-
conflict/nodes/NodeListMergeModelTest.java (modified) (2 diffs)
-
conflict/properties/PropertiesMergeModelTest.java (modified) (3 diffs)
-
conflict/tags/TagMergeItemTest.java (modified) (2 diffs)
-
conflict/tags/TagMergeModelTest.java (modified) (2 diffs)
-
mappaint/MapCSSWithExtendedTextDirectivesTest.groovy (modified) (3 diffs)
-
mappaint/mapcss/ChildOrParentSelectorTest.groovy (modified) (15 diffs)
-
mappaint/mapcss/KeyConditionTest.groovy (modified) (6 diffs)
-
mappaint/mapcss/KeyValueConditionTest.groovy (modified) (6 diffs)
-
mappaint/mapcss/MapCSSParserTest.groovy (modified) (5 diffs)
-
tagging/TaggingPresetReaderTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/JosmUserIdentityManagerTest.groovy
r7068 r7081 14 14 final shouldFail = new GroovyTestCase().&shouldFail 15 15 16 private static JOSMFixture josmFixture17 18 16 @BeforeClass 19 17 public static void initTestCase() { 20 josmFixture =JOSMFixture.createFunctionalTestFixture()18 JOSMFixture.createUnitTestFixture().init() 21 19 } 22 20 -
trunk/test/unit/org/openstreetmap/josm/gui/SystemOfMeasurementTest.java
r6992 r7081 9 9 import org.junit.BeforeClass; 10 10 import org.junit.Test; 11 import org.openstreetmap.josm. Main;11 import org.openstreetmap.josm.JOSMFixture; 12 12 import org.openstreetmap.josm.data.SystemOfMeasurement; 13 13 … … 22 22 @BeforeClass 23 23 public static void setUp() { 24 Main.initApplicationPreferences();24 JOSMFixture.createUnitTestFixture().init(); 25 25 } 26 26 -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModelTest.java
r7005 r7081 18 18 import org.junit.BeforeClass; 19 19 import org.junit.Test; 20 import org.openstreetmap.josm. Main;20 import org.openstreetmap.josm.JOSMFixture; 21 21 import org.openstreetmap.josm.data.osm.DatasetFactory; 22 22 import org.openstreetmap.josm.data.osm.Node; … … 31 31 @BeforeClass 32 32 public static void init() { 33 Main.initApplicationPreferences();33 JOSMFixture.createUnitTestFixture().init(); 34 34 } 35 35 -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java
r7005 r7081 12 12 import org.junit.BeforeClass; 13 13 import org.junit.Test; 14 import org.openstreetmap.josm. Main;14 import org.openstreetmap.josm.JOSMFixture; 15 15 import org.openstreetmap.josm.data.conflict.Conflict; 16 16 import org.openstreetmap.josm.data.coor.LatLon; … … 20 20 import org.openstreetmap.josm.data.osm.Relation; 21 21 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.data.projection.Projections;23 22 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; 24 23 import org.openstreetmap.josm.gui.conflict.pair.properties.PropertiesMergeModel; … … 46 45 @BeforeClass 47 46 public static void init() { 48 Main.setProjection(Projections.getProjectionByCode("EPSG:4326")); 49 Main.initApplicationPreferences(); 47 JOSMFixture.createUnitTestFixture().init(); 50 48 } 51 49 -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeItemTest.java
r7005 r7081 8 8 import org.junit.BeforeClass; 9 9 import org.junit.Test; 10 import org.openstreetmap.josm. Main;10 import org.openstreetmap.josm.JOSMFixture; 11 11 import org.openstreetmap.josm.data.osm.Node; 12 12 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; … … 17 17 @BeforeClass 18 18 public static void init() { 19 Main.initApplicationPreferences();19 JOSMFixture.createUnitTestFixture().init(); 20 20 } 21 21 -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeModelTest.java
r7005 r7081 12 12 import org.junit.BeforeClass; 13 13 import org.junit.Test; 14 import org.openstreetmap.josm. Main;14 import org.openstreetmap.josm.JOSMFixture; 15 15 import org.openstreetmap.josm.data.osm.Node; 16 16 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; … … 23 23 @BeforeClass 24 24 public static void init() { 25 Main.initApplicationPreferences();25 JOSMFixture.createUnitTestFixture().init(); 26 26 } 27 27 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy
r7068 r7081 4 4 5 5 import org.junit.* 6 import org.openstreetmap.josm.JOSMFixture ;6 import org.openstreetmap.josm.JOSMFixture 7 7 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy 8 8 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy 9 9 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.TagKeyReference 10 10 11 class MapCSSWithExtendedTextDirectivesTest { 11 12 12 13 13 @BeforeClass … … 20 20 Cascade c = new Cascade() 21 21 c.put("text", new Keyword("auto")) 22 22 23 23 TextElement te = TextElement.create(c, Color.WHITE, false /* no default annotate */) 24 24 assert te.labelCompositionStrategy != null 25 25 assert te.labelCompositionStrategy instanceof DeriveLabelFromNameTagsCompositionStrategy 26 26 } 27 27 28 28 @Test 29 29 public void createTextElementComposingTextFromTag() { 30 30 Cascade c = new Cascade() 31 31 c.put("text", new TagKeyReference("my_name")) 32 32 33 33 TextElement te = TextElement.create(c, Color.WHITE, false /* no default annotate */) 34 34 assert te.labelCompositionStrategy != null … … 36 36 assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name" 37 37 } 38 38 39 39 @Test 40 40 public void createNullStrategy() { 41 41 Cascade c = new Cascade() 42 42 43 43 TextElement te = TextElement.create(c, Color.WHITE, false /* no default annotate */) 44 assert te .labelCompositionStrategy== null44 assert te == null 45 45 } 46 46 } 47 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.groovy
r7068 r7081 7 7 8 8 import org.junit.* 9 import org.openstreetmap.josm.JOSMFixture ;9 import org.openstreetmap.josm.JOSMFixture 10 10 import org.openstreetmap.josm.data.coor.LatLon 11 11 import org.openstreetmap.josm.data.osm.DataSet … … 19 19 class ChildOrParentSelectorTest { 20 20 static private Logger logger = Logger.getLogger(ChildOrParentSelectorTest.class.getName()); 21 21 22 22 def shouldFail = new GroovyTestCase().&shouldFail 23 23 24 24 def DataSet ds; 25 25 26 26 @BeforeClass 27 27 public static void createJOSMFixture(){ 28 28 JOSMFixture.createUnitTestFixture().init() 29 29 } 30 30 31 31 @Before 32 32 public void setUp() { 33 33 ds = new DataSet() 34 34 } 35 35 36 36 def relation(id) { 37 37 def r = new Relation(id,1) … … 39 39 return r 40 40 } 41 41 42 42 def node(id) { 43 43 def n = new Node(id,1) … … 46 46 return n 47 47 } 48 48 49 49 def way(id){ 50 50 def w = new Way(id,1) … … 52 52 return w 53 53 } 54 54 55 55 def ChildOrParentSelector parse(css){ 56 56 MapCSSStyleSource source = new MapCSSStyleSource(css) 57 57 source.loadStyleSource() 58 58 assert source.rules.size() == 1 59 assert source.rules[0].selectors.size() == 1 60 return source.rules[0].selectors[0] 59 return source.rules[0].selector 61 60 } 62 61 63 62 @Test 64 63 @Ignore … … 68 67 """ 69 68 ChildOrParentSelector selector = parse(css) 70 69 71 70 Relation r = relation(1) 72 71 Node n = node(1) 73 72 r.addMember(new RelationMember("my_role", n)) 74 73 Environment e = new Environment().withChild(n) 75 76 assert selector.matches(e) 74 75 assert selector.matches(e) 77 76 } 78 77 79 78 @Test 80 79 @Ignore … … 84 83 """ 85 84 ChildOrParentSelector selector = parse(css) 86 85 87 86 Relation r = relation(1) 88 87 Node n = node(1) 89 88 r.addMember(new RelationMember("my_role", n)) 90 89 Environment e = new Environment().withChild(n) 91 90 92 91 assert selector.matches(e) 93 92 } 94 93 95 94 @Test 96 95 @Ignore … … 100 99 """ 101 100 ChildOrParentSelector selector = parse(css) 102 101 103 102 Relation r = relation(1) 104 103 Node n = node(1) 105 104 r.addMember(new RelationMember("my_role", n)) 106 105 Environment e = new Environment().withChild(n) 107 106 108 107 assert !selector.matches(e) 109 108 } 110 109 111 110 @Test 112 111 @Ignore … … 114 113 def css = """ 115 114 way < relation {} 116 """ 115 """ 117 116 ChildOrParentSelector selector = parse(css) 118 assert selector. parentSelector119 117 assert selector.type == Selector.ChildOrParentSelectorType.PARENT 118 120 119 } 121 120 @Test … … 124 123 way <[role != "my_role"] relation {} 125 124 """ 126 ChildOrParentSelector selector = parse(css) 127 assert selector. parentSelector128 125 ChildOrParentSelector selector = parse(css) 126 assert selector.type == Selector.ChildOrParentSelectorType.PARENT 127 129 128 Relation r = relation(1) 130 129 Way w1 = way(1) … … 133 132 Way w2 = way(2) 134 133 w2.setNodes([node(21), node(22)]) 135 134 136 135 Way w3 = way(3) 137 136 w3.setNodes([node(31), node(32)]) … … 140 139 r.addMember(new RelationMember("my_role", w2)) 141 140 r.addMember(new RelationMember("another role", w3)) 142 141 143 142 Environment e = new Environment().withPrimitive(r) 144 143 assert selector.matches(e) 145 144 } 146 145 147 146 @Test 148 147 public void matches_6() { … … 150 149 relation >[role != "my_role"] way {} 151 150 """ 152 ChildOrParentSelector selector = parse(css) 153 151 ChildOrParentSelector selector = parse(css) 152 154 153 Relation r = relation(1) 155 154 Way w1 = way(1) … … 158 157 Way w2 = way(2) 159 158 w2.setNodes([node(21), node(22)]) 160 159 161 160 Way w3 = way(3) 162 161 w3.setNodes([node(31), node(32)]) … … 165 164 r.addMember(new RelationMember("my_role", w2)) 166 165 r.addMember(new RelationMember("another role", w3)) 167 166 168 167 Environment e = new Environment().withPrimitive(w1) 169 168 assert !selector.matches(e) 170 169 171 170 e = new Environment().withPrimitive(w2) 172 171 assert !selector.matches(e) 173 172 174 173 e = new Environment().withPrimitive(w3) 175 174 assert selector.matches(e) -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyConditionTest.groovy
r7068 r7081 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm.JOSMFixture ;7 import org.openstreetmap.josm.JOSMFixture 8 8 import org.openstreetmap.josm.data.coor.LatLon 9 9 import org.openstreetmap.josm.data.osm.DataSet … … 17 17 18 18 def shouldFail = new GroovyTestCase().&shouldFail 19 19 20 20 def DataSet ds; 21 21 22 22 @BeforeClass 23 23 public static void createJOSMFixture(){ 24 24 JOSMFixture.createUnitTestFixture().init() 25 25 } 26 26 27 27 @Before 28 28 public void setUp() { 29 29 ds = new DataSet() 30 30 } 31 31 32 32 def relation(id) { 33 33 def r = new Relation(id,1) … … 35 35 return r 36 36 } 37 37 38 38 def node(id) { 39 39 def n = new Node(id,1) … … 42 42 return n 43 43 } 44 44 45 45 @Test 46 46 public void create() { 47 47 48 48 // ["a label"] 49 Condition c = Condition.create("a key", false, false, Context.PRIMITIVE)49 Condition c = Condition.createKeyCondition("a key", false, Condition.KeyMatchType.FALSE, Context.PRIMITIVE) 50 50 // ["a label"?] 51 c = Condition.create("a key", false, true, Context.PRIMITIVE)51 c = Condition.createKeyCondition("a key", false, Condition.KeyMatchType.TRUE, Context.PRIMITIVE) 52 52 // [!"a label"] 53 c = Condition.create("a key", true, false, Context.PRIMITIVE)53 c = Condition.createKeyCondition("a key", true, Condition.KeyMatchType.FALSE, Context.PRIMITIVE) 54 54 // [!"a label"?] 55 c = Condition.create("a key", true, true, Context.PRIMITIVE)56 55 c = Condition.createKeyCondition("a key", true, Condition.KeyMatchType.TRUE, Context.PRIMITIVE) 56 57 57 // ["a label"] 58 c = Condition.create("a key", false, false, Context.LINK)58 c = Condition.createKeyCondition("a key", false, null, Context.LINK) 59 59 // [!"a label"] 60 c = Condition.create("a key", true, false, Context.LINK)61 60 c = Condition.createKeyCondition("a key", true, null, Context.LINK) 61 62 62 shouldFail(MapCSSException) { 63 63 // ["a label"?] 64 c = Condition.create("a key", false, true, Context.LINK)64 c = Condition.createKeyCondition("a key", false, Condition.KeyMatchType.TRUE, Context.LINK) 65 65 } 66 66 67 67 shouldFail(MapCSSException) { 68 68 // [!"a label"?] 69 c = Condition.create("a key", true, true, Context.LINK)69 c = Condition.createKeyCondition("a key", true, Condition.KeyMatchType.TRUE, Context.LINK) 70 70 } 71 71 } 72 72 73 73 @Test 74 74 public void applies_1() { … … 76 76 Node n = node(1) 77 77 r.addMember(new RelationMember("my_role", n)) 78 78 79 79 Environment e = new Environment().withPrimitive(n).withParent(r).withIndex(0).withLinkContext() 80 81 Condition cond = Condition.create("my_role", false, false, Context.LINK)82 assert cond.applies(e) 83 84 cond = Condition.create("my_role", true, false, Context.LINK)80 81 Condition cond = Condition.createKeyCondition("my_role", false, null, Context.LINK) 82 assert cond.applies(e) 83 84 cond = Condition.createKeyCondition("my_role", true, null, Context.LINK) 85 85 assert !cond.applies(e) 86 86 } 87 87 88 88 @Test 89 89 public void applies_2() { … … 91 91 Node n = node(1) 92 92 r.addMember(new RelationMember("my_role", n)) 93 93 94 94 Environment e = new Environment().withPrimitive(n).withParent(r).withIndex(0).withLinkContext() 95 96 Condition cond = Condition.create("another_role", false, false, Context.LINK)95 96 Condition cond = Condition.createKeyCondition("another_role", false, null, Context.LINK) 97 97 assert !cond.applies(e) 98 99 cond = Condition.create("another_role", true, false, Context.LINK)98 99 cond = Condition.createKeyCondition("another_role", true, null, Context.LINK) 100 100 assert cond.applies(e) 101 } 101 } 102 102 } 103 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyValueConditionTest.groovy
r7068 r7081 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm.JOSMFixture ;7 import org.openstreetmap.josm.JOSMFixture 8 8 import org.openstreetmap.josm.data.coor.LatLon 9 9 import org.openstreetmap.josm.data.osm.DataSet … … 19 19 20 20 def shouldFail = new GroovyTestCase().&shouldFail 21 21 22 22 def DataSet ds; 23 23 24 24 @BeforeClass 25 25 public static void createJOSMFixture(){ 26 26 JOSMFixture.createUnitTestFixture().init() 27 27 } 28 28 29 29 @Before 30 30 public void setUp() { 31 31 ds = new DataSet() 32 32 } 33 33 34 34 def relation(id) { 35 35 def r = new Relation(id,1) … … 37 37 return r 38 38 } 39 39 40 40 def node(id) { 41 41 def n = new Node(id,1) … … 44 44 return n 45 45 } 46 46 47 47 @Test 48 48 public void create() { 49 Condition c = Condition.create("a key", "a value", Op.EQ, Context.PRIMITIVE) 50 51 c = Condition.create("role", "a role", Op.EQ, Context.LINK) 52 c = Condition.create("RoLe", "a role", Op.EQ, Context.LINK) 53 49 Condition c = Condition.createKeyValueCondition("a key", "a value", Op.EQ, Context.PRIMITIVE, false) 50 51 c = Condition.createKeyValueCondition("role", "a role", Op.EQ, Context.LINK, false) 52 c = Condition.createKeyValueCondition("RoLe", "a role", Op.EQ, Context.LINK, false) 53 54 54 shouldFail(MapCSSException) { 55 c = Condition.create("an arbitry tag", "a role", Op.EQ, Context.LINK) 55 c = Condition.createKeyValueCondition("an arbitry tag", "a role", Op.EQ, Context.LINK, false) 56 56 } 57 57 } 58 58 59 59 @Test 60 60 public void applies_1() { … … 62 62 Node n = node(1) 63 63 r.addMember(new RelationMember("my_role", n)) 64 64 65 65 Environment e = new Environment().withPrimitive(n).withParent(r).withLinkContext().withIndex(0) 66 66 67 67 Condition cond = new Condition.RoleCondition("my_role", Op.EQ) 68 assert cond.applies(e) 69 68 assert cond.applies(e) 69 70 70 cond = new Condition.RoleCondition("another_role", Op.EQ) 71 71 assert !cond.applies(e) 72 72 } 73 73 74 74 @Test 75 75 public void applies_2() { … … 77 77 Node n = node(1) 78 78 r.addMember(new RelationMember("my_role", n)) 79 79 80 80 Environment e = new Environment().withPrimitive(n).withParent(r).withIndex(0).withLinkContext() 81 82 Condition cond = Condition.create("role", "my_role", Op.NEQ, Context.LINK) 81 82 Condition cond = Condition.createKeyValueCondition("role", "my_role", Op.NEQ, Context.LINK, false) 83 83 assert !cond.applies(e) 84 85 cond = Condition.create("role", "another_role", Op.NEQ, Context.LINK) 84 85 cond = Condition.createKeyValueCondition("role", "another_role", Op.NEQ, Context.LINK, false) 86 86 assert cond.applies(e) 87 87 } 88 89 90 91 88 } 92 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy
r7068 r7081 5 5 import org.junit.Before 6 6 import org.junit.Test 7 import org.openstreetmap.josm.JOSMFixture 7 8 import org.openstreetmap.josm.Main 8 import org.openstreetmap.josm.TestUtils ;9 import org.openstreetmap.josm.TestUtils 9 10 import org.openstreetmap.josm.data.coor.LatLon 10 11 import org.openstreetmap.josm.data.osm.DataSet 11 12 import org.openstreetmap.josm.data.osm.OsmPrimitive 12 13 import org.openstreetmap.josm.data.osm.Way 13 import org.openstreetmap.josm.data.projection.Projections14 14 import org.openstreetmap.josm.gui.mappaint.Environment 15 15 import org.openstreetmap.josm.gui.mappaint.MultiCascade … … 35 35 @Before 36 36 public void setUp() throws Exception { 37 Main.initApplicationPreferences() 38 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); 37 JOSMFixture.createUnitTestFixture().init(); 39 38 } 40 39 … … 57 56 public void testClassCondition() throws Exception { 58 57 def conditions = ((Selector.GeneralSelector) getParser("way[name=X].highway:closed").selector()).conds 59 assert conditions.get(0) instanceof Condition.KeyValueCondition 58 assert conditions.get(0) instanceof Condition.SimpleKeyValueCondition 60 59 assert conditions.get(0).applies(getEnvironment("name", "X")) 61 60 assert conditions.get(1) instanceof Condition.ClassCondition … … 89 88 @Test 90 89 public void testEqualCondition() throws Exception { 91 def condition = (Condition.KeyValueCondition) getParser("[surface=paved]").condition(Condition.Context.PRIMITIVE) 92 assert condition instanceof Condition.KeyValueCondition 93 assert Condition.Op.EQ.equals(condition.op) 90 def condition = (Condition.SimpleKeyValueCondition) getParser("[surface=paved]").condition(Condition.Context.PRIMITIVE) 91 assert condition instanceof Condition.SimpleKeyValueCondition 94 92 assert "surface".equals(condition.k) 95 93 assert "paved".equals(condition.v) … … 215 213 216 214 @Test 217 public void testTicket8071 1() throws Exception {215 public void testTicket8071() throws Exception { 218 216 def sheet = new MapCSSStyleSource("") 219 217 getParser("*[rcn_ref], *[name] {text: concat(tag(rcn_ref), \" \", tag(name)); }").sheet(sheet) -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java
r7068 r7081 13 13 import org.junit.BeforeClass; 14 14 import org.junit.Test; 15 import org.openstreetmap.josm. Main;15 import org.openstreetmap.josm.JOSMFixture; 16 16 import org.openstreetmap.josm.TestUtils; 17 17 import org.openstreetmap.josm.tools.Utils; … … 28 28 @BeforeClass 29 29 public static void setUp() { 30 Main.initApplicationPreferences();30 JOSMFixture.createUnitTestFixture().init(); 31 31 } 32 32
Note:
See TracChangeset
for help on using the changeset viewer.
