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 java.util.Collections;
|
---|
8 |
|
---|
9 | import org.junit.Rule;
|
---|
10 | import org.junit.Test;
|
---|
11 | import org.openstreetmap.josm.Main;
|
---|
12 | import org.openstreetmap.josm.data.notes.Note;
|
---|
13 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
14 | import org.openstreetmap.josm.data.osm.NoteData;
|
---|
15 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
16 | import org.openstreetmap.josm.gui.MapFrame;
|
---|
17 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
18 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
19 |
|
---|
20 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Unit tests for class {@link AddNoteAction}.
|
---|
24 | */
|
---|
25 | public class AddNoteActionTest {
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Setup test.
|
---|
29 | */
|
---|
30 | @Rule
|
---|
31 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
32 | public JOSMTestRules test = new JOSMTestRules().platform().main().projection();
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Unit test of {@link AddNoteAction#enterMode} and {@link AddNoteAction#exitMode}.
|
---|
36 | */
|
---|
37 | @Test
|
---|
38 | public void testMode() {
|
---|
39 | OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
|
---|
40 | try {
|
---|
41 | Main.getLayerManager().addLayer(layer);
|
---|
42 | AddNoteAction mapMode = new AddNoteAction(new NoteData(Collections.<Note>emptyList()));
|
---|
43 | MapFrame map = MainApplication.getMap();
|
---|
44 | MapMode oldMapMode = map.mapMode;
|
---|
45 | assertTrue(map.selectMapMode(mapMode));
|
---|
46 | assertEquals(mapMode, map.mapMode);
|
---|
47 | assertTrue(map.selectMapMode(oldMapMode));
|
---|
48 | } finally {
|
---|
49 | Main.getLayerManager().removeLayer(layer);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|