1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer.markerlayer;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import java.net.URL;
|
---|
7 |
|
---|
8 | import org.junit.jupiter.api.Test;
|
---|
9 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
10 | import org.openstreetmap.josm.TestUtils;
|
---|
11 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
12 | import org.openstreetmap.josm.data.gpx.GpxData;
|
---|
13 | import org.openstreetmap.josm.data.gpx.WayPoint;
|
---|
14 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
15 | import org.openstreetmap.josm.tools.PlatformManager;
|
---|
16 | import org.openstreetmap.josm.tools.PlatformHook;
|
---|
17 |
|
---|
18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
19 |
|
---|
20 | import mockit.Expectations;
|
---|
21 | import mockit.Injectable;
|
---|
22 | import mockit.Mocked;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Unit tests of {@link WebMarker} class.
|
---|
26 | */
|
---|
27 | class WebMarkerTest {
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Setup tests
|
---|
31 | */
|
---|
32 | @RegisterExtension
|
---|
33 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
34 | public JOSMTestRules test = new JOSMTestRules().preferences().https();
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Unit test of {@link WebMarker#WebMarker}.
|
---|
38 | * @param mockPlatformHook platform hook mock
|
---|
39 | * @param platformManager {@link PlatformManager} mock
|
---|
40 | * @throws Exception in case of error
|
---|
41 | */
|
---|
42 | @Test
|
---|
43 | void testWebMarker(@Injectable final PlatformHook mockPlatformHook,
|
---|
44 | @Mocked final PlatformManager platformManager) throws Exception {
|
---|
45 | TestUtils.assumeWorkingJMockit();
|
---|
46 | new Expectations() {{
|
---|
47 | PlatformManager.getPlatform(); result = mockPlatformHook;
|
---|
48 | mockPlatformHook.openUrl("http://example.com"); result = null; times = 1;
|
---|
49 | }};
|
---|
50 |
|
---|
51 | WebMarker marker = new WebMarker(
|
---|
52 | LatLon.ZERO,
|
---|
53 | new URL("http://example.com"),
|
---|
54 | new MarkerLayer(new GpxData(), null, null, null),
|
---|
55 | 1d, 2d);
|
---|
56 | marker.actionPerformed(null);
|
---|
57 | assertEquals("", marker.getText());
|
---|
58 | WayPoint wpt = marker.convertToWayPoint();
|
---|
59 | assertEquals(LatLon.ZERO, wpt.getCoor());
|
---|
60 | }
|
---|
61 | }
|
---|