[10050] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.gui.layer.markerlayer;
|
---|
| 3 |
|
---|
| 4 | import static org.junit.Assert.assertEquals;
|
---|
| 5 | import static org.junit.Assert.assertNotNull;
|
---|
| 6 | import static org.junit.Assert.assertTrue;
|
---|
| 7 |
|
---|
| 8 | import java.awt.Color;
|
---|
| 9 | import java.util.Arrays;
|
---|
| 10 |
|
---|
[12564] | 11 | import org.junit.Before;
|
---|
| 12 | import org.junit.Rule;
|
---|
[10050] | 13 | import org.junit.Test;
|
---|
| 14 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
| 15 | import org.openstreetmap.josm.data.gpx.GpxConstants;
|
---|
| 16 | import org.openstreetmap.josm.data.gpx.GpxData;
|
---|
| 17 | import org.openstreetmap.josm.data.gpx.GpxLink;
|
---|
| 18 | import org.openstreetmap.josm.data.gpx.WayPoint;
|
---|
[12636] | 19 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
[12849] | 20 | import org.openstreetmap.josm.spi.preferences.Config;
|
---|
[12564] | 21 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
[10050] | 22 |
|
---|
[12564] | 23 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
| 24 |
|
---|
[10050] | 25 | /**
|
---|
| 26 | * Unit tests of {@link MarkerLayer} class.
|
---|
| 27 | */
|
---|
| 28 | public class MarkerLayerTest {
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * Setup tests
|
---|
| 32 | */
|
---|
[12564] | 33 | @Rule
|
---|
| 34 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
[12632] | 35 | public JOSMTestRules test = new JOSMTestRules().main().platform().preferences().projection();
|
---|
[12564] | 36 |
|
---|
| 37 | /**
|
---|
| 38 | * Setup tests
|
---|
| 39 | */
|
---|
| 40 | @Before
|
---|
| 41 | public void setUp() {
|
---|
[12849] | 42 | Config.getPref().putBoolean("marker.traceaudio", true);
|
---|
[10050] | 43 | }
|
---|
| 44 |
|
---|
| 45 | /**
|
---|
| 46 | * Unit test of {@link MarkerLayer#MarkerLayer}.
|
---|
| 47 | */
|
---|
| 48 | @Test
|
---|
[10378] | 49 | public void testMarkerLayer() {
|
---|
[10050] | 50 | assertEquals(Color.magenta, MarkerLayer.getGenericColor());
|
---|
| 51 | MarkerLayer layer = new MarkerLayer(new GpxData(), "foo", null, null);
|
---|
[12636] | 52 | MainApplication.getLayerManager().addLayer(layer);
|
---|
[10050] | 53 |
|
---|
| 54 | assertEquals("foo", layer.getName());
|
---|
[10824] | 55 | assertEquals(Color.magenta, layer.getColorProperty().get());
|
---|
[10050] | 56 | assertNotNull(layer.getIcon());
|
---|
| 57 | assertEquals("0 markers", layer.getToolTipText());
|
---|
| 58 | assertEquals("<html>foo consists of 0 markers</html>", layer.getInfoComponent());
|
---|
| 59 | assertTrue(layer.getMenuEntries().length > 10);
|
---|
| 60 |
|
---|
| 61 | GpxData gpx = new GpxData();
|
---|
| 62 | WayPoint wpt = new WayPoint(LatLon.ZERO);
|
---|
| 63 | wpt.attr.put(GpxConstants.META_LINKS, Arrays.asList(new GpxLink("https://josm.openstreetmap.de")));
|
---|
| 64 | wpt.addExtension("offset", "1.0");
|
---|
| 65 | gpx.waypoints.add(wpt);
|
---|
| 66 | wpt = new WayPoint(LatLon.ZERO);
|
---|
| 67 | wpt.addExtension("offset", "NaN");
|
---|
| 68 | gpx.waypoints.add(wpt);
|
---|
| 69 | layer = new MarkerLayer(gpx, "bar", null, null);
|
---|
| 70 |
|
---|
| 71 | assertEquals("bar", layer.getName());
|
---|
[10824] | 72 | assertEquals(Color.magenta, layer.getColorProperty().get());
|
---|
[10050] | 73 | assertNotNull(layer.getIcon());
|
---|
| 74 | assertEquals("3 markers", layer.getToolTipText());
|
---|
| 75 | assertEquals("<html>bar consists of 3 markers</html>", layer.getInfoComponent());
|
---|
| 76 | assertTrue(layer.getMenuEntries().length > 10);
|
---|
| 77 | }
|
---|
| 78 | }
|
---|