Changeset 13078 in josm for trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
- Timestamp:
- 2017-11-04T17:11:15+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r13021 r13078 2 2 package org.openstreetmap.josm.testutils; 3 3 4 import java.awt.Color; 4 5 import java.io.File; 5 6 import java.io.IOException; … … 57 58 private APIType useAPI = APIType.NONE; 58 59 private String i18n = null; 60 private TileSourceRule tileSourceRule; 59 61 private boolean platform; 60 62 private boolean useProjection; … … 243 245 244 246 /** 247 * Replace imagery sources with a default set of mock tile sources 248 * 249 * @return this instance, for easy chaining 250 */ 251 public JOSMTestRules fakeImagery() { 252 return this.fakeImagery( 253 new TileSourceRule( 254 true, 255 true, 256 true, 257 new TileSourceRule.ColorSource(Color.WHITE, "White Tiles", 256), 258 new TileSourceRule.ColorSource(Color.BLACK, "Black Tiles", 256), 259 new TileSourceRule.ColorSource(Color.MAGENTA, "Magenta Tiles", 256), 260 new TileSourceRule.ColorSource(Color.GREEN, "Green Tiles", 256) 261 ) 262 ); 263 } 264 265 /** 266 * Replace imagery sources with those from specific mock tile server setup 267 * @param tileSourceRule Tile source rule 268 * 269 * @return this instance, for easy chaining 270 */ 271 public JOSMTestRules fakeImagery(TileSourceRule tileSourceRule) { 272 this.preferences(); 273 this.tileSourceRule = tileSourceRule; 274 return this; 275 } 276 277 /** 245 278 * Use the {@link Main#main}, {@code Main.contentPanePrivate}, {@code Main.mainPanel}, 246 279 * {@link Main#menu}, {@link Main#toolbar} global variables in this test. … … 257 290 public Statement apply(Statement base, Description description) { 258 291 Statement statement = base; 292 // counter-intuitively, Statements which need to have their setup routines performed *after* another one need to 293 // be added into the chain *before* that one, so that it ends up on the "inside". 259 294 if (timeout > 0) { 260 295 // TODO: new DisableOnDebug(timeout) 261 296 statement = new FailOnTimeoutStatement(statement, timeout); 262 297 } 298 299 // this half of TileSourceRule's initialization must happen after josm is set up 300 if (this.tileSourceRule != null) { 301 statement = this.tileSourceRule.applyRegisterLayers(statement, description); 302 } 303 263 304 statement = new CreateJosmEnvironment(statement); 264 305 if (josmHome != null) { 265 306 statement = josmHome.apply(statement, description); 307 } 308 309 // run mock tile server as the outermost Statement (started first) so it can hopefully be initializing in 310 // parallel with other setup 311 if (this.tileSourceRule != null) { 312 statement = this.tileSourceRule.applyRunServer(statement, description); 266 313 } 267 314 return statement; … … 407 454 MainApplication.getLayerManager().resetState(); 408 455 eventManager.resetState(); 456 } 457 458 /** 459 * @return TileSourceRule which is automatically started by this rule 460 */ 461 public TileSourceRule getTileSourceRule() { 462 return this.tileSourceRule; 409 463 } 410 464
Note:
See TracChangeset
for help on using the changeset viewer.