source: josm/trunk/test/unit/org/openstreetmap/josm/tools/ImageProviderTest.java@ 10103

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

javadoc update

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6
7import java.awt.Transparency;
8import java.awt.image.BufferedImage;
9import java.io.File;
10import java.io.IOException;
11
12import org.junit.BeforeClass;
13import org.junit.Test;
14import org.openstreetmap.josm.JOSMFixture;
15import org.openstreetmap.josm.TestUtils;
16
17/**
18 * Unit tests of {@link ImageProvider} class.
19 */
20public 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 /**
55 * Test fetching an image using {@code wiki://} protocol.
56 */
57 @Test
58 public void testWikiProtocol() {
59 // https://commons.wikimedia.org/wiki/File:OpenJDK_logo.svg
60 assertNotNull(ImageProvider.get("wiki://OpenJDK_logo.svg"));
61 }
62}
Note: See TracBrowser for help on using the repository browser.