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.BeforeClass;
|
---|
12 | import org.junit.Test;
|
---|
13 | import org.openstreetmap.josm.JOSMFixture;
|
---|
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 |
|
---|
21 | /**
|
---|
22 | * Unit tests of {@link MarkerLayer} class.
|
---|
23 | */
|
---|
24 | public class MarkerLayerTest {
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Setup tests
|
---|
28 | */
|
---|
29 | @BeforeClass
|
---|
30 | public static void setUpBeforeClass() {
|
---|
31 | JOSMFixture.createUnitTestFixture().init(true);
|
---|
32 | Main.pref.put("marker.traceaudio", true);
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Unit test of {@link MarkerLayer#MarkerLayer}.
|
---|
37 | */
|
---|
38 | @Test
|
---|
39 | public void testMarkerLayer() {
|
---|
40 | assertEquals(Color.magenta, MarkerLayer.getGenericColor());
|
---|
41 | MarkerLayer layer = new MarkerLayer(new GpxData(), "foo", null, null);
|
---|
42 |
|
---|
43 | assertEquals("foo", layer.getName());
|
---|
44 | assertEquals(Color.magenta, layer.getColorProperty().get());
|
---|
45 | assertNotNull(layer.getIcon());
|
---|
46 | assertEquals("0 markers", layer.getToolTipText());
|
---|
47 | assertEquals("<html>foo consists of 0 markers</html>", layer.getInfoComponent());
|
---|
48 | assertTrue(layer.getMenuEntries().length > 10);
|
---|
49 |
|
---|
50 | GpxData gpx = new GpxData();
|
---|
51 | WayPoint wpt = new WayPoint(LatLon.ZERO);
|
---|
52 | wpt.attr.put(GpxConstants.META_LINKS, Arrays.asList(new GpxLink("https://josm.openstreetmap.de")));
|
---|
53 | wpt.addExtension("offset", "1.0");
|
---|
54 | gpx.waypoints.add(wpt);
|
---|
55 | wpt = new WayPoint(LatLon.ZERO);
|
---|
56 | wpt.addExtension("offset", "NaN");
|
---|
57 | gpx.waypoints.add(wpt);
|
---|
58 | layer = new MarkerLayer(gpx, "bar", null, null);
|
---|
59 |
|
---|
60 | assertEquals("bar", layer.getName());
|
---|
61 | assertEquals(Color.magenta, layer.getColorProperty().get());
|
---|
62 | assertNotNull(layer.getIcon());
|
---|
63 | assertEquals("3 markers", layer.getToolTipText());
|
---|
64 | assertEquals("<html>bar consists of 3 markers</html>", layer.getInfoComponent());
|
---|
65 | assertTrue(layer.getMenuEntries().length > 10);
|
---|
66 | }
|
---|
67 | }
|
---|