1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertFalse;
|
---|
6 | import static org.junit.Assert.assertNull;
|
---|
7 |
|
---|
8 | import java.awt.Color;
|
---|
9 |
|
---|
10 | import org.junit.Rule;
|
---|
11 | import org.junit.Test;
|
---|
12 | import org.openstreetmap.josm.TestUtils;
|
---|
13 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
14 | import org.openstreetmap.josm.gui.MapScaler.AccessibleMapScaler;
|
---|
15 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
16 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
17 |
|
---|
18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Unit tests of {@link MapScaler} class.
|
---|
22 | */
|
---|
23 | public class MapScalerTest {
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Setup tests
|
---|
27 | */
|
---|
28 | @Rule
|
---|
29 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
30 | public JOSMTestRules test = new JOSMTestRules().main().projection();
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Unit test of {@link MapScaler#MapScaler}.
|
---|
34 | */
|
---|
35 | @Test
|
---|
36 | public void testMapScaler() {
|
---|
37 | MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), "", null));
|
---|
38 | assertEquals(Color.WHITE, MapScaler.getColor());
|
---|
39 | MapScaler ms = new MapScaler(MainApplication.getMap().mapView);
|
---|
40 | assertEquals("/MapView/Scaler", ms.helpTopic());
|
---|
41 | ms.paint(TestUtils.newGraphics());
|
---|
42 | AccessibleMapScaler ams = (AccessibleMapScaler) ms.getAccessibleContext();
|
---|
43 | assertEquals(1000.0, ams.getCurrentAccessibleValue().doubleValue(), 1e-3);
|
---|
44 | assertFalse(ams.setCurrentAccessibleValue(500));
|
---|
45 | assertNull(ams.getMinimumAccessibleValue());
|
---|
46 | assertNull(ams.getMaximumAccessibleValue());
|
---|
47 | }
|
---|
48 | }
|
---|