Ignore:
Timestamp:
2018-07-28T20:28:36+02:00 (6 years ago)
Author:
Don-vip
Message:

see #16010 - bugfixes (patch by ris)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackActionTest.java

    r12636 r14062  
    22package org.openstreetmap.josm.gui.layer.gpx;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertNotNull;
    56import static org.junit.Assert.assertNull;
     
    1516import org.openstreetmap.josm.io.GpxReaderTest;
    1617import org.openstreetmap.josm.testutils.JOSMTestRules;
     18import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker;
     19
     20import com.google.common.collect.ImmutableMap;
    1721
    1822import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    3135
    3236    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
    3349        final OsmDataLayer layer = new OsmDataLayer(new DataSet(), DownloadAlongTrackActionTest.class.getName(), null);
    3450        try {
     
    3652            // Perform action
    3753            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;
    3963        } finally {
    4064            // Ensure we clean the place before leaving, even if test fails.
Note: See TracChangeset for help on using the changeset viewer.