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 |
|
---|
11 | import org.junit.Before;
|
---|
12 | import org.junit.Rule;
|
---|
13 | import org.junit.Test;
|
---|
14 | import org.openstreetmap.josm.Main;
|
---|
15 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
16 | import org.openstreetmap.josm.data.gpx.GpxConstants;
|
---|
17 | import org.openstreetmap.josm.data.gpx.GpxData;
|
---|
18 | import org.openstreetmap.josm.data.gpx.GpxLink;
|
---|
19 | import org.openstreetmap.josm.data.gpx.WayPoint;
|
---|
20 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
21 |
|
---|
22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Unit tests of {@link MarkerLayer} class.
|
---|
26 | */
|
---|
27 | public class MarkerLayerTest {
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Setup tests
|
---|
31 | */
|
---|
32 | @Rule
|
---|
33 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
34 | public JOSMTestRules test = new JOSMTestRules().mainMenu().platform().preferences().projection();
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Setup tests
|
---|
38 | */
|
---|
39 | @Before
|
---|
40 | public void setUp() {
|
---|
41 | Main.pref.put("marker.traceaudio", true);
|
---|
42 | }
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Unit test of {@link MarkerLayer#MarkerLayer}.
|
---|
46 | */
|
---|
47 | @Test
|
---|
48 | public void testMarkerLayer() {
|
---|
49 | assertEquals(Color.magenta, MarkerLayer.getGenericColor());
|
---|
50 | MarkerLayer layer = new MarkerLayer(new GpxData(), "foo", null, null);
|
---|
51 | Main.getLayerManager().addLayer(layer);
|
---|
52 |
|
---|
53 | assertEquals("foo", layer.getName());
|
---|
54 | assertEquals(Color.magenta, layer.getColorProperty().get());
|
---|
55 | assertNotNull(layer.getIcon());
|
---|
56 | assertEquals("0 markers", layer.getToolTipText());
|
---|
57 | assertEquals("<html>foo consists of 0 markers</html>", layer.getInfoComponent());
|
---|
58 | assertTrue(layer.getMenuEntries().length > 10);
|
---|
59 |
|
---|
60 | GpxData gpx = new GpxData();
|
---|
61 | WayPoint wpt = new WayPoint(LatLon.ZERO);
|
---|
62 | wpt.attr.put(GpxConstants.META_LINKS, Arrays.asList(new GpxLink("https://josm.openstreetmap.de")));
|
---|
63 | wpt.addExtension("offset", "1.0");
|
---|
64 | gpx.waypoints.add(wpt);
|
---|
65 | wpt = new WayPoint(LatLon.ZERO);
|
---|
66 | wpt.addExtension("offset", "NaN");
|
---|
67 | gpx.waypoints.add(wpt);
|
---|
68 | layer = new MarkerLayer(gpx, "bar", null, null);
|
---|
69 |
|
---|
70 | assertEquals("bar", layer.getName());
|
---|
71 | assertEquals(Color.magenta, layer.getColorProperty().get());
|
---|
72 | assertNotNull(layer.getIcon());
|
---|
73 | assertEquals("3 markers", layer.getToolTipText());
|
---|
74 | assertEquals("<html>bar consists of 3 markers</html>", layer.getInfoComponent());
|
---|
75 | assertTrue(layer.getMenuEntries().length > 10);
|
---|
76 | }
|
---|
77 | }
|
---|