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

Last change on this file since 11241 was 9954, checked in by Don-vip, 8 years ago

make MapScaler and SizeButton implement Accessible interface, add unit tests, fix checkstyle violation

  • Property svn:eol-style set to native
File size: 1.3 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.BeforeClass;
11import org.junit.Test;
12import org.openstreetmap.josm.JOSMFixture;
13import org.openstreetmap.josm.Main;
14import org.openstreetmap.josm.TestUtils;
15import org.openstreetmap.josm.gui.MapScaler.AccessibleMapScaler;
16
17/**
18 * Unit tests of {@link MapScaler} class.
19 */
20public class MapScalerTest {
21
22 /**
23 * Setup tests
24 */
25 @BeforeClass
26 public static void setUpBeforeClass() {
27 JOSMFixture.createUnitTestFixture().init(true);
28 }
29
30 /**
31 * Unit test of {@link MapScaler#MapScaler}.
32 */
33 @Test
34 public void testMapScaler() {
35 assertEquals(Color.WHITE, MapScaler.getColor());
36 MapScaler ms = new MapScaler(Main.map.mapView);
37 assertEquals("/MapView/Scaler", ms.helpTopic());
38 ms.paint(TestUtils.newGraphics());
39 AccessibleMapScaler ams = (AccessibleMapScaler) ms.getAccessibleContext();
40 assertEquals(1000.0, ams.getCurrentAccessibleValue().doubleValue(), 1e-3);
41 assertFalse(ams.setCurrentAccessibleValue(500));
42 assertNull(ams.getMinimumAccessibleValue());
43 assertNull(ams.getMaximumAccessibleValue());
44 }
45}
Note: See TracBrowser for help on using the repository browser.