1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import org.junit.jupiter.api.Test;
|
---|
7 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
8 | import org.openstreetmap.josm.data.imagery.ImageryInfo;
|
---|
9 | import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
|
---|
10 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
11 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
12 |
|
---|
13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Unit tests of {@link TMSLayer} class.
|
---|
17 | */
|
---|
18 | public class TMSLayerTest {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Setup tests
|
---|
22 | */
|
---|
23 | @RegisterExtension
|
---|
24 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
25 | public JOSMTestRules test = new JOSMTestRules().main().projection();
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Creates a new TMS layer.
|
---|
29 | * @return a new TMS layer
|
---|
30 | */
|
---|
31 | public static TMSLayer createTmsLayer() {
|
---|
32 | return new TMSLayer(new ImageryInfo("test tms", "http://localhost", "tms", null, null));
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Creates a new Bing layer.
|
---|
37 | * @return a new Bing layer
|
---|
38 | */
|
---|
39 | public static TMSLayer createBingLayer() {
|
---|
40 | return new TMSLayer(new ImageryInfo("test bing", "http://localhost", "bing", null, null));
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Creates a new Scanex layer.
|
---|
45 | * @return a new Scanex layer
|
---|
46 | */
|
---|
47 | public static TMSLayer createScanexLayer() {
|
---|
48 | return new TMSLayer(new ImageryInfo("test scanex", "http://localhost", "scanex", null, null));
|
---|
49 | }
|
---|
50 |
|
---|
51 | private static void test(ImageryType expected, TMSLayer layer) {
|
---|
52 | try {
|
---|
53 | MainApplication.getLayerManager().addLayer(layer);
|
---|
54 | assertEquals(expected, layer.getInfo().getImageryType());
|
---|
55 | } finally {
|
---|
56 | // Ensure we clean the place before leaving, even if test fails.
|
---|
57 | MainApplication.getLayerManager().removeLayer(layer);
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Unit test of {@link TMSLayer#TMSLayer}.
|
---|
63 | */
|
---|
64 | @Test
|
---|
65 | void testTMSLayer() {
|
---|
66 | test(ImageryType.TMS, createTmsLayer());
|
---|
67 | test(ImageryType.BING, createBingLayer());
|
---|
68 | test(ImageryType.SCANEX, createScanexLayer());
|
---|
69 | }
|
---|
70 | }
|
---|