Changeset 7081 in josm for trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyConditionTest.groovy
- Timestamp:
- 2014-05-09T04:49:54+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.
