1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 |
|
---|
6 | import org.junit.BeforeClass;
|
---|
7 | import org.junit.Test;
|
---|
8 | import org.openstreetmap.josm.JOSMFixture;
|
---|
9 | import org.openstreetmap.josm.Main;
|
---|
10 | import org.openstreetmap.josm.data.imagery.ImageryInfo;
|
---|
11 | import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Unit tests of {@link TMSLayer} class.
|
---|
15 | */
|
---|
16 | public class TMSLayerTest {
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Setup tests
|
---|
20 | */
|
---|
21 | @BeforeClass
|
---|
22 | public static void setUpBeforeClass() {
|
---|
23 | JOSMFixture.createUnitTestFixture().init(true);
|
---|
24 | }
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Creates a new TMS layer.
|
---|
28 | * @return a new TMS layer
|
---|
29 | */
|
---|
30 | public static TMSLayer createTmsLayer() {
|
---|
31 | return new TMSLayer(new ImageryInfo("test tms", "http://localhost", "tms", null, null));
|
---|
32 | }
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Creates a new Bing layer.
|
---|
36 | * @return a new Bing layer
|
---|
37 | */
|
---|
38 | public static TMSLayer createBingLayer() {
|
---|
39 | return new TMSLayer(new ImageryInfo("test bing", "http://localhost", "bing", null, null));
|
---|
40 | }
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Creates a new Scanex layer.
|
---|
44 | * @return a new Scanex layer
|
---|
45 | */
|
---|
46 | public static TMSLayer createScanexLayer() {
|
---|
47 | return new TMSLayer(new ImageryInfo("test scanex", "http://localhost", "scanex", null, null));
|
---|
48 | }
|
---|
49 |
|
---|
50 | private static void test(ImageryType expected, TMSLayer layer) {
|
---|
51 | Main.main.addLayer(layer);
|
---|
52 | assertEquals(expected, layer.getInfo().getImageryType());
|
---|
53 | }
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Unit test of {@link TMSLayer#TMSLayer}.
|
---|
57 | */
|
---|
58 | @Test
|
---|
59 | public void testTMSLayer() {
|
---|
60 | test(ImageryType.TMS, createTmsLayer());
|
---|
61 | test(ImageryType.BING, createBingLayer());
|
---|
62 | test(ImageryType.SCANEX, createScanexLayer());
|
---|
63 | }
|
---|
64 | }
|
---|