Changeset 14062 in josm for trunk/test/unit/org
- Timestamp:
- 2018-07-28T20:28:36+02:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackActionTest.java
r12636 r14062 2 2 package org.openstreetmap.josm.gui.layer.gpx; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.Assert.assertNotNull; 5 6 import static org.junit.Assert.assertNull; … … 15 16 import org.openstreetmap.josm.io.GpxReaderTest; 16 17 import org.openstreetmap.josm.testutils.JOSMTestRules; 18 import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; 19 20 import com.google.common.collect.ImmutableMap; 17 21 18 22 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 31 35 32 36 private static PleaseWaitRunnable createTask(String file) throws Exception { 37 // click "Download" when presented with the appropriate HelpAwareOptionPane 38 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(ImmutableMap.of( 39 "DownloadAlongPanel", "Download" 40 )) { 41 // expected "message" for HelpAwareOptionPane call is not a simple string, so instead 42 // just detect the class name of the message object 43 @Override 44 protected String getStringFromMessage(final Object message) { 45 return message instanceof String ? (String) message : message.getClass().getSimpleName(); 46 } 47 }; 48 33 49 final OsmDataLayer layer = new OsmDataLayer(new DataSet(), DownloadAlongTrackActionTest.class.getName(), null); 34 50 try { … … 36 52 // Perform action 37 53 final GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + file); 38 return new DownloadAlongTrackAction(gpx).createTask(); 54 final PleaseWaitRunnable retval = new DownloadAlongTrackAction(gpx).createTask(); 55 56 // assert that we were indeed presented with the expected HelpAwareOptionPane 57 assertEquals(1, haMocker.getInvocationLog().size()); 58 assertEquals(0, haMocker.getInvocationLog().get(0)[0]); 59 assertEquals("DownloadAlongPanel", haMocker.getInvocationLog().get(0)[1]); 60 assertEquals("Download from OSM along this track", haMocker.getInvocationLog().get(0)[2]); 61 62 return retval; 39 63 } finally { 40 64 // Ensure we clean the place before leaving, even if test fails. -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
r14054 r14062 232 232 assertEquals(1, haMocker.getInvocationLog().size()); 233 233 Object[] invocationLogEntry = haMocker.getInvocationLog().get(0); 234 assertEquals( 2, (int) invocationLogEntry[0]);234 assertEquals(1, (int) invocationLogEntry[0]); 235 235 assertEquals("Restart", invocationLogEntry[2]); 236 236 … … 354 354 assertEquals(1, haMocker.getInvocationLog().size()); 355 355 Object[] invocationLogEntry = haMocker.getInvocationLog().get(0); 356 assertEquals( 2, (int) invocationLogEntry[0]);356 assertEquals(1, (int) invocationLogEntry[0]); 357 357 assertEquals("Restart", invocationLogEntry[2]); 358 358 -
trunk/test/unit/org/openstreetmap/josm/testutils/mockers/HelpAwareOptionPaneMocker.java
r14052 r14062 101 101 )); 102 102 } 103 // buttons are numbered with 1-based indexing 104 return optIndex.getAsInt() + 1; 103 return optIndex.getAsInt(); 105 104 } 106 105 } … … 162 161 retval 163 162 )); 164 } else if (retval > (options == null ? 0 : options.length )) { // NOTE 1-based indexing163 } else if (retval > (options == null ? 0 : options.length-1)) { 165 164 fail(String.format( 166 165 "Invalid result for HelpAwareOptionPane: %s (in call with options = %s)",
Note:
See TracChangeset
for help on using the changeset viewer.