source: josm/trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayerTest.java@ 10824

Last change on this file since 10824 was 10824, checked in by Don-vip, 8 years ago

see #13309 - Caching and notifying preferences (patch by michael2402) - gsoc-core

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer.markerlayer;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertTrue;
7
8import java.awt.Color;
9import java.util.Arrays;
10
11import org.junit.BeforeClass;
12import org.junit.Test;
13import org.openstreetmap.josm.JOSMFixture;
14import org.openstreetmap.josm.Main;
15import org.openstreetmap.josm.data.coor.LatLon;
16import org.openstreetmap.josm.data.gpx.GpxConstants;
17import org.openstreetmap.josm.data.gpx.GpxData;
18import org.openstreetmap.josm.data.gpx.GpxLink;
19import org.openstreetmap.josm.data.gpx.WayPoint;
20
21/**
22 * Unit tests of {@link MarkerLayer} class.
23 */
24public 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}
Note: See TracBrowser for help on using the repository browser.