1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer.gpx;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertNotNull;
|
---|
5 | import static org.junit.Assert.assertNull;
|
---|
6 |
|
---|
7 | import org.junit.Rule;
|
---|
8 | import org.junit.Test;
|
---|
9 | import org.openstreetmap.josm.Main;
|
---|
10 | import org.openstreetmap.josm.TestUtils;
|
---|
11 | import org.openstreetmap.josm.data.gpx.GpxData;
|
---|
12 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
13 | import org.openstreetmap.josm.gui.PleaseWaitRunnable;
|
---|
14 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
15 | import org.openstreetmap.josm.io.GpxReaderTest;
|
---|
16 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
17 |
|
---|
18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Unit tests of {@link DownloadAlongTrackAction} class.
|
---|
22 | */
|
---|
23 | public class DownloadAlongTrackActionTest {
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * The test rules for this test
|
---|
27 | */
|
---|
28 | @Rule
|
---|
29 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
30 | public JOSMTestRules test = new JOSMTestRules().preferences().platform();
|
---|
31 |
|
---|
32 | private static PleaseWaitRunnable createTask(String file) throws Exception {
|
---|
33 | final OsmDataLayer layer = new OsmDataLayer(new DataSet(), DownloadAlongTrackActionTest.class.getName(), null);
|
---|
34 | try {
|
---|
35 | Main.getLayerManager().addLayer(layer);
|
---|
36 | // Perform action
|
---|
37 | final GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + file);
|
---|
38 | return new DownloadAlongTrackAction(gpx).createTask();
|
---|
39 | } finally {
|
---|
40 | // Ensure we clean the place before leaving, even if test fails.
|
---|
41 | Main.getLayerManager().removeLayer(layer);
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Test action with nominal data set.
|
---|
47 | * @throws Exception if an error occurs
|
---|
48 | */
|
---|
49 | @Test
|
---|
50 | public void testDownload() throws Exception {
|
---|
51 | assertNotNull(createTask("minimal.gpx"));
|
---|
52 | }
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Test action with empty data set.
|
---|
56 | * @throws Exception if an error occurs
|
---|
57 | */
|
---|
58 | @Test
|
---|
59 | public void testDownloadEmpty() throws Exception {
|
---|
60 | assertNull(createTask("empty.gpx"));
|
---|
61 | }
|
---|
62 | }
|
---|