Changeset 7068 in josm for trunk/test/unit/org/openstreetmap/josm/gui
- Timestamp:
- 2014-05-06T01:24:41+02:00 (12 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui
- Files:
-
- 9 edited
-
JosmUserIdentityManagerTest.groovy (modified) (7 diffs)
-
mappaint/LabelCompositionStrategyTest.groovy (modified) (1 diff)
-
mappaint/MapCSSWithExtendedTextDirectivesTest.groovy (modified) (1 diff)
-
mappaint/mapcss/ChildOrParentSelectorTest.groovy (modified) (2 diffs)
-
mappaint/mapcss/KeyConditionTest.groovy (modified) (2 diffs)
-
mappaint/mapcss/KeyValueConditionTest.groovy (modified) (2 diffs)
-
mappaint/mapcss/MapCSSParserTest.groovy (modified) (1 diff)
-
mappaint/mapcss/ParsingLinkSelectorTest.groovy (modified) (1 diff)
-
tagging/TaggingPresetReaderTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/JosmUserIdentityManagerTest.groovy
r2690 r7068 2 2 package org.openstreetmap.josm.gui; 3 3 4 import org.junit. BeforeClass;5 import org.junit.Test 6 import org. openstreetmap.josm.Main;7 import org. openstreetmap.josm.data.osm.UserInfo;8 import org.openstreetmap.josm. fixtures.JOSMFixture;9 10 import static org.junit.Assert.*;4 import static org.junit.Assert.* 5 6 import org.junit.BeforeClass 7 import org.junit.Test 8 import org.openstreetmap.josm.JOSMFixture 9 import org.openstreetmap.josm.Main 10 import org.openstreetmap.josm.data.osm.UserInfo 11 11 12 12 class JosmUserIdentityManagerTest { 13 13 14 14 final shouldFail = new GroovyTestCase().&shouldFail 15 15 16 16 private static JOSMFixture josmFixture 17 17 18 18 @BeforeClass 19 19 public static void initTestCase() { 20 20 josmFixture = JOSMFixture.createFunctionalTestFixture() 21 21 } 22 22 23 23 @Test 24 24 public void test_SingletonAccess() { 25 26 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 25 26 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 27 27 28 28 // created ? 29 29 assert im != null 30 31 // registered as listener ? 30 31 // registered as listener ? 32 32 assert Main.pref.@listeners.contains(im) 33 33 34 34 JosmUserIdentityManager im2 = JosmUserIdentityManager.getInstance() 35 35 36 36 // only one instance 37 assert im == im2 38 } 39 37 assert im == im2 38 } 39 40 40 @Test 41 41 public void test_setAnonymouse() { 42 42 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 43 43 44 44 im.setPartiallyIdentified "test" 45 45 im.setAnonymous() 46 46 47 47 assert im.isAnonymous() 48 48 assert ! im.isPartiallyIdentified() 49 49 assert ! im.isFullyIdentified() 50 50 51 51 assert im.getUserId() == 0 52 52 assert im.getUserName() == null 53 53 assert im.getUserInfo() == null 54 54 } 55 55 56 56 @Test 57 57 public void test_setPartiallyIdentified() { 58 58 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 59 59 60 60 im.setPartiallyIdentified "test" 61 61 62 62 shouldFail(IllegalArgumentException) { 63 63 im.setPartiallyIdentified null 64 64 } 65 65 66 66 shouldFail(IllegalArgumentException) { 67 67 im.setPartiallyIdentified "" 68 68 } 69 69 70 70 shouldFail(IllegalArgumentException) { 71 71 im.setPartiallyIdentified " \t " 72 72 } 73 73 74 74 im.setPartiallyIdentified "test" 75 75 76 76 assert ! im.isAnonymous() 77 77 assert im.isPartiallyIdentified() 78 78 assert ! im.isFullyIdentified() 79 79 80 80 assert im.getUserId() == 0 81 81 assert im.getUserName() == "test" 82 82 assert im.getUserInfo() == null 83 83 } 84 85 84 85 86 86 @Test 87 87 public void test_setFullyIdentified() { … … 89 89 90 90 UserInfo userInfo = new UserInfo(id: 1, description: "a description") 91 91 92 92 im.setFullyIdentified "test", userInfo 93 93 94 94 shouldFail(IllegalArgumentException) { 95 95 im.setFullyIdentified null, userInfo … … 104 104 im.setFullyIdentified "test", null 105 105 } 106 106 107 107 im.setFullyIdentified "test", userInfo 108 108 109 109 assert ! im.isAnonymous() 110 110 assert ! im.isPartiallyIdentified() 111 111 assert im.isFullyIdentified() 112 112 113 113 assert im.getUserId() == 1 114 114 assert im.getUserName() == "test" 115 115 assert im.getUserInfo() == userInfo 116 116 } 117 117 118 118 /** 119 119 * Preferences include neither an url nor a user name => we have 120 * an anonymous user 121 */ 122 @Test 120 * an anonymous user 121 */ 122 @Test 123 123 public void initFromPreferences_1() { 124 124 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 125 126 // reset it 127 im.@userName = null 128 im.@userInfo = null 129 125 126 // reset it 127 im.@userName = null 128 im.@userInfo = null 129 130 130 Main.pref.put "osm-server.url", null 131 131 Main.pref.put "osm-server.username", null 132 133 im.initFromPreferences() 134 135 assert im.isAnonymous() 136 } 137 132 133 im.initFromPreferences() 134 135 assert im.isAnonymous() 136 } 137 138 138 /** 139 139 * Preferences include neither an url nor a user name => we have 140 * an annoymous user 141 */ 142 @Test 140 * an annoymous user 141 */ 142 @Test 143 143 public void initFromPreferences_2() { 144 144 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 145 146 // reset it 147 im.@userName = null 148 im.@userInfo = null 149 145 146 // reset it 147 im.@userName = null 148 im.@userInfo = null 149 150 150 // for this test we disable the listener 151 151 Main.pref.removePreferenceChangeListener im 152 153 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 154 Main.pref.put "osm-server.username", null 155 156 im.initFromPreferences() 157 158 assert im.isAnonymous() 159 } 160 161 /** 162 * Preferences include an user name => we have a partially identified user 163 */ 164 @Test 152 153 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 154 Main.pref.put "osm-server.username", null 155 156 im.initFromPreferences() 157 158 assert im.isAnonymous() 159 } 160 161 /** 162 * Preferences include an user name => we have a partially identified user 163 */ 164 @Test 165 165 public void initFromPreferences_3() { 166 166 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() … … 169 169 Main.pref.removePreferenceChangeListener im 170 170 171 // reset it 172 im.@userName = null 173 im.@userInfo = null 174 171 // reset it 172 im.@userName = null 173 im.@userInfo = null 174 175 175 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 176 176 Main.pref.put "osm-server.username", "test" 177 178 im.initFromPreferences() 179 180 assert im.isPartiallyIdentified() 181 } 182 177 178 im.initFromPreferences() 179 180 assert im.isPartiallyIdentified() 181 } 182 183 183 /** 184 184 * Preferences include an user name which is different from the current 185 185 * user name and we are currently fully identifed => josm user becomes 186 * partially identified 187 */ 188 @Test 186 * partially identified 187 */ 188 @Test 189 189 public void initFromPreferences_4() { 190 190 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() … … 194 194 195 195 im.setFullyIdentified "test1", new UserInfo(id: 1) 196 196 197 197 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 198 198 Main.pref.put "osm-server.username", "test2" 199 200 im.initFromPreferences() 201 202 assert im.isPartiallyIdentified() 203 } 204 199 200 im.initFromPreferences() 201 202 assert im.isPartiallyIdentified() 203 } 204 205 205 /** 206 206 * Preferences include an user name which is the same as the current … … 208 208 * fully identified 209 209 */ 210 @Test 210 @Test 211 211 public void initFromPreferences_5() { 212 212 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() … … 214 214 // for this test we disable the listener 215 215 Main.pref.removePreferenceChangeListener im 216 216 217 217 im.setFullyIdentified "test1", new UserInfo(id: 1) 218 218 219 219 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 220 220 Main.pref.put "osm-server.username", "test1" 221 222 im.initFromPreferences() 223 221 222 im.initFromPreferences() 223 224 224 assert im.isFullyIdentified() 225 225 } 226 227 @Test 226 227 @Test 228 228 public void apiUrlChanged() { 229 229 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 230 231 // make sure im is a preference change listener 230 231 // make sure im is a preference change listener 232 232 Main.pref.addPreferenceChangeListener im 233 234 // reset it 235 im.@userName = null 236 im.@userInfo = null 237 238 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 239 assert im.isAnonymous() 240 233 234 // reset it 235 im.@userName = null 236 im.@userInfo = null 237 238 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 239 assert im.isAnonymous() 240 241 241 Main.pref.put "osm-server.url", null 242 242 assert im.isAnonymous() 243 244 // reset it 243 244 // reset it 245 245 im.@userName = "test" 246 246 im.@userInfo = null 247 248 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 249 assert im.isPartiallyIdentified() 250 assert im.getUserName() == "test" 251 247 248 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 249 assert im.isPartiallyIdentified() 250 assert im.getUserName() == "test" 251 252 252 Main.pref.put "osm-server.url", null 253 253 assert im.isAnonymous() 254 255 // reset it 254 255 // reset it 256 256 im.@userName = "test" 257 257 im.@userInfo = new UserInfo(id:1) 258 259 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 260 assert im.isPartiallyIdentified() 261 assert im.getUserName() == "test" 262 263 // reset it 258 259 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 260 assert im.isPartiallyIdentified() 261 assert im.getUserName() == "test" 262 263 // reset it 264 264 im.@userName = "test" 265 265 im.@userInfo = new UserInfo(id:1) 266 267 266 267 268 268 Main.pref.put "osm-server.url", null 269 assert im.isAnonymous() 270 } 271 272 @Test 269 assert im.isAnonymous() 270 } 271 272 @Test 273 273 public void userNameChanged() { 274 274 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 275 276 // make sure im is a preference change listener 275 276 // make sure im is a preference change listener 277 277 Main.pref.addPreferenceChangeListener im 278 279 // reset it 280 im.@userName = null 281 im.@userInfo = null 282 278 279 // reset it 280 im.@userName = null 281 im.@userInfo = null 282 283 283 Main.pref.put "osm-server.username", "test" 284 284 assert im.isPartiallyIdentified() 285 285 assert im.getUserName() == "test" 286 287 Main.pref.put "osm-server.username", null 288 assert im.isAnonymous() 289 290 // reset it 286 287 Main.pref.put "osm-server.username", null 288 assert im.isAnonymous() 289 290 // reset it 291 291 im.@userName = "test1" 292 292 im.@userInfo = null 293 293 294 294 Main.pref.put "osm-server.username", "test2" 295 295 assert im.isPartiallyIdentified() 296 296 assert im.getUserName() == "test2" 297 298 Main.pref.put "osm-server.username", null 299 assert im.isAnonymous() 300 301 // reset it 297 298 Main.pref.put "osm-server.username", null 299 assert im.isAnonymous() 300 301 // reset it 302 302 im.@userName = "test1" 303 303 im.@userInfo = new UserInfo(id:1) 304 304 305 305 Main.pref.put "osm-server.username", "test2" 306 306 assert im.isPartiallyIdentified() 307 307 assert im.getUserName() == "test2" 308 309 // reset it 308 309 // reset it 310 310 im.@userName = "test1" 311 311 im.@userInfo = new UserInfo(id:1) 312 313 314 Main.pref.put "osm-server.username", null 315 assert im.isAnonymous() 312 313 314 Main.pref.put "osm-server.username", null 315 assert im.isAnonymous() 316 316 } 317 317 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategyTest.groovy
r3991 r7068 3 3 4 4 import org.junit.* 5 import org.openstreetmap.josm. fixtures.JOSMFixture;5 import org.openstreetmap.josm.JOSMFixture; 6 6 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy 7 7 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy; -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy
r4074 r7068 4 4 5 5 import org.junit.* 6 import org.openstreetmap.josm. fixtures.JOSMFixture6 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 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.groovy
r4069 r7068 7 7 8 8 import org.junit.* 9 import org.openstreetmap.josm.JOSMFixture; 9 10 import org.openstreetmap.josm.data.coor.LatLon 10 11 import org.openstreetmap.josm.data.osm.DataSet … … 13 14 import org.openstreetmap.josm.data.osm.RelationMember 14 15 import org.openstreetmap.josm.data.osm.Way 15 import org.openstreetmap.josm.fixtures.JOSMFixture16 16 import org.openstreetmap.josm.gui.mappaint.Environment 17 17 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyConditionTest.groovy
r4074 r7068 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm.JOSMFixture; 7 8 import org.openstreetmap.josm.data.coor.LatLon 8 9 import org.openstreetmap.josm.data.osm.DataSet … … 10 11 import org.openstreetmap.josm.data.osm.Relation 11 12 import org.openstreetmap.josm.data.osm.RelationMember 12 import org.openstreetmap.josm.fixtures.JOSMFixture13 13 import org.openstreetmap.josm.gui.mappaint.Environment 14 14 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyValueConditionTest.groovy
r4074 r7068 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm.JOSMFixture; 7 8 import org.openstreetmap.josm.data.coor.LatLon 8 9 import org.openstreetmap.josm.data.osm.DataSet … … 10 11 import org.openstreetmap.josm.data.osm.Relation 11 12 import org.openstreetmap.josm.data.osm.RelationMember 12 import org.openstreetmap.josm.fixtures.JOSMFixture13 13 import org.openstreetmap.josm.gui.mappaint.Environment 14 14 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy
r7066 r7068 5 5 import org.junit.Before 6 6 import org.junit.Test 7 import org.openstreetmap.TestUtils8 7 import org.openstreetmap.josm.Main 8 import org.openstreetmap.josm.TestUtils; 9 9 import org.openstreetmap.josm.data.coor.LatLon 10 10 import org.openstreetmap.josm.data.osm.DataSet -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ParsingLinkSelectorTest.groovy
r4074 r7068 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm. fixtures.JOSMFixture7 import org.openstreetmap.josm.JOSMFixture; 8 8 9 9 -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java
r6881 r7068 13 13 import org.junit.BeforeClass; 14 14 import org.junit.Test; 15 import org.openstreetmap.TestUtils;16 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.TestUtils; 17 17 import org.openstreetmap.josm.tools.Utils; 18 18 import org.xml.sax.SAXException;
Note:
See TracChangeset
for help on using the changeset viewer.
