1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions.mapmode;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertTrue;
|
---|
6 |
|
---|
7 | import org.junit.Rule;
|
---|
8 | import org.junit.Test;
|
---|
9 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
10 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
11 | import org.openstreetmap.josm.gui.MapFrame;
|
---|
12 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
13 | import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;
|
---|
14 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
15 |
|
---|
16 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Unit tests for class {@link PlayHeadDragMode}.
|
---|
20 | */
|
---|
21 | public class PlayHeadDragModeTest {
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Setup test.
|
---|
25 | */
|
---|
26 | @Rule
|
---|
27 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
28 | public JOSMTestRules test = new JOSMTestRules().platform().platform().main().projection();
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Unit test of {@link PlayHeadDragMode#enterMode} and {@link PlayHeadDragMode#exitMode}.
|
---|
32 | */
|
---|
33 | @Test
|
---|
34 | public void testMode() {
|
---|
35 | OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
|
---|
36 | try {
|
---|
37 | MainApplication.getLayerManager().addLayer(layer);
|
---|
38 | PlayHeadDragMode mapMode = new PlayHeadDragMode(PlayHeadMarker.create());
|
---|
39 | MapFrame map = MainApplication.getMap();
|
---|
40 | MapMode oldMapMode = map.mapMode;
|
---|
41 | assertTrue(map.selectMapMode(mapMode));
|
---|
42 | assertEquals(mapMode, map.mapMode);
|
---|
43 | assertTrue(map.selectMapMode(oldMapMode));
|
---|
44 | } finally {
|
---|
45 | MainApplication.getLayerManager().removeLayer(layer);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|