source: josm/trunk/test/unit/org/openstreetmap/josm/gui/MapScalerTest.java@ 12630

Last change on this file since 12630 was 12630, checked in by Don-vip, 7 years ago

see #15182 - deprecate Main.map and Main.isDisplayingMapView(). Replacements: gui.MainApplication.getMap() / gui.MainApplication.isDisplayingMapView()

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