1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertNotNull;
|
---|
6 |
|
---|
7 | import java.awt.Transparency;
|
---|
8 | import java.awt.image.BufferedImage;
|
---|
9 | import java.io.File;
|
---|
10 | import java.io.IOException;
|
---|
11 |
|
---|
12 | import org.junit.BeforeClass;
|
---|
13 | import org.junit.Test;
|
---|
14 | import org.openstreetmap.josm.JOSMFixture;
|
---|
15 | import org.openstreetmap.josm.TestUtils;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Unit tests of {@link ImageProvider} class.
|
---|
19 | */
|
---|
20 | public class ImageProviderTest {
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Setup test.
|
---|
24 | */
|
---|
25 | @BeforeClass
|
---|
26 | public static void setUp() {
|
---|
27 | JOSMFixture.createUnitTestFixture().init();
|
---|
28 | }
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/9984">#9984</a>
|
---|
32 | * @throws IOException if an error occurs during reading
|
---|
33 | */
|
---|
34 | @Test
|
---|
35 | public void testTicket9984() throws IOException {
|
---|
36 | File file = new File(TestUtils.getRegressionDataFile(9984, "tile.png"));
|
---|
37 | assertEquals(Transparency.TRANSLUCENT, ImageProvider.read(file, true, true).getTransparency());
|
---|
38 | assertEquals(Transparency.TRANSLUCENT, ImageProvider.read(file, false, true).getTransparency());
|
---|
39 | assertEquals(Transparency.OPAQUE, ImageProvider.read(file, false, false).getTransparency());
|
---|
40 | assertEquals(Transparency.OPAQUE, ImageProvider.read(file, true, false).getTransparency());
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/10030">#10030</a>
|
---|
45 | * @throws IOException if an error occurs during reading
|
---|
46 | */
|
---|
47 | @Test
|
---|
48 | public void testTicket10030() throws IOException {
|
---|
49 | File file = new File(TestUtils.getRegressionDataFile(10030, "tile.jpg"));
|
---|
50 | BufferedImage img = ImageProvider.read(file, true, true);
|
---|
51 | assertNotNull(img);
|
---|
52 | }
|
---|
53 |
|
---|
54 | @Test
|
---|
55 | public void testWikiProtocol() throws Exception {
|
---|
56 | // https://commons.wikimedia.org/wiki/File:OpenJDK_logo.svg
|
---|
57 | assertNotNull(ImageProvider.get("wiki://OpenJDK_logo.svg"));
|
---|
58 | }
|
---|
59 | }
|
---|