source: josm/trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplayTest.java

Last change on this file was 13127, checked in by Don-vip, 15 months ago

see #15476, fix #15511 - fix image scaling regression and makes geoimage feature more configurable through prefs (adjustable max zoom, zoom-step, click zooming with mouse buttons (e.g. if a mouse wheel is not present). Patch by cmuelle8

  • 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.layer.geoimage;
3
4import static org.junit.Assert.assertEquals;
5
6import java.awt.Dimension;
7import java.awt.Rectangle;
8
9import org.junit.Rule;
10import org.junit.Test;
11import org.openstreetmap.josm.gui.layer.geoimage.ImageDisplay.VisRect;
12import org.openstreetmap.josm.testutils.JOSMTestRules;
13
14import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15
16/**
17 * Unit tests of {@link ImageDisplay} class.
18 */
19public class ImageDisplayTest {
20    /**
21     * We need prefs for this.
22     */
23    @Rule
24    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
25    public JOSMTestRules test = new JOSMTestRules().preferences();
26
27    /**
28     * Unit test of {@link ImageDisplay#calculateDrawImageRectangle}.
29     */
30    @Test
31    public void testCalculateDrawImageRectangle() {
32        assertEquals(new Rectangle(),
33                ImageDisplay.calculateDrawImageRectangle(new VisRect(), new Dimension()));
34        assertEquals(new Rectangle(0, 0, 10, 5),
35                ImageDisplay.calculateDrawImageRectangle(new VisRect(0, 0, 10, 5), new Dimension(10, 5)));
36        assertEquals(new Rectangle(0, 0, 10, 5),
37                ImageDisplay.calculateDrawImageRectangle(new VisRect(0, 0, 20, 10), new Dimension(10, 5)));
38        assertEquals(new Rectangle(0, 0, 20, 10),
39                ImageDisplay.calculateDrawImageRectangle(new VisRect(0, 0, 10, 5), new Dimension(20, 10)));
40        assertEquals(new Rectangle(5, 0, 24, 12),
41                ImageDisplay.calculateDrawImageRectangle(new VisRect(0, 0, 10, 5), new Dimension(35, 12)));
42        assertEquals(new Rectangle(0, 1, 8, 4),
43                ImageDisplay.calculateDrawImageRectangle(new VisRect(0, 0, 10, 5), new Dimension(8, 6)));
44    }
45}
Note: See TracBrowser for help on using the repository browser.