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.BeforeClass;
|
---|
10 | import org.junit.Test;
|
---|
11 | import org.openstreetmap.josm.JOSMFixture;
|
---|
12 | import org.openstreetmap.josm.Main;
|
---|
13 | import org.openstreetmap.josm.data.notes.Note;
|
---|
14 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
15 | import org.openstreetmap.josm.data.osm.NoteData;
|
---|
16 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Unit tests for class {@link AddNoteAction}.
|
---|
20 | */
|
---|
21 | public class AddNoteActionTest {
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Setup test.
|
---|
25 | */
|
---|
26 | @BeforeClass
|
---|
27 | public static void setUp() {
|
---|
28 | JOSMFixture.createUnitTestFixture().init(true);
|
---|
29 | }
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * Unit test of {@link AddNoteAction#enterMode} and {@link AddNoteAction#exitMode}.
|
---|
33 | */
|
---|
34 | @Test
|
---|
35 | public void testMode() {
|
---|
36 | OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
|
---|
37 | try {
|
---|
38 | Main.main.addLayer(layer);
|
---|
39 | AddNoteAction mapMode = new AddNoteAction(Main.map, new NoteData(Collections.<Note>emptyList()));
|
---|
40 | MapMode oldMapMode = Main.map.mapMode;
|
---|
41 | assertTrue(Main.map.selectMapMode(mapMode));
|
---|
42 | assertEquals(mapMode, Main.map.mapMode);
|
---|
43 | assertTrue(Main.map.selectMapMode(oldMapMode));
|
---|
44 | } finally {
|
---|
45 | Main.main.removeLayer(layer);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|