Ignore:
Timestamp:
2020-02-22T13:50:09+01:00 (5 years ago)
Author:
simon04
Message:

see #14088 - Add ImageProviderTest.testGetPadded

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/ImageProviderTest.java

    r14201 r15897  
    55import static org.junit.Assert.assertFalse;
    66import static org.junit.Assert.assertNotNull;
     7import static org.junit.Assert.assertNull;
    78
     9import java.awt.Dimension;
    810import java.awt.Transparency;
    911import java.awt.image.BufferedImage;
    1012import java.io.File;
    1113import java.io.IOException;
     14import java.util.EnumSet;
    1215import java.util.logging.Handler;
    1316import java.util.logging.LogRecord;
     
    1720
    1821import org.junit.BeforeClass;
     22import org.junit.Rule;
    1923import org.junit.Test;
    2024import org.openstreetmap.josm.JOSMFixture;
    2125import org.openstreetmap.josm.TestUtils;
     26import org.openstreetmap.josm.data.osm.Node;
     27import org.openstreetmap.josm.data.osm.OsmUtils;
     28import org.openstreetmap.josm.testutils.JOSMTestRules;
     29import org.openstreetmap.josm.tools.ImageProvider.GetPaddedOptions;
    2230
    2331import com.kitfox.svg.SVGConst;
     
    2937 */
    3038public class ImageProviderTest {
     39   
     40    /**
     41     * Setup test.
     42     */
     43    @Rule
     44    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     45    public JOSMTestRules test = new JOSMTestRules().mapStyles().presets();
    3146
    3247    private static final class LogHandler14319 extends Handler {
     
    116131                "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="));
    117132    }
     133
     134    /**
     135     * Unit test of {@link ImageProvider#getPadded}.
     136     */
     137    @Test
     138    public void testGetPadded() {
     139        final EnumSet<GetPaddedOptions> noDefault = EnumSet.of(GetPaddedOptions.NO_DEFAULT);
     140        final Dimension iconSize = new Dimension(16, 16);
     141
     142        assertNull(ImageProvider.getPadded(new Node(), new Dimension(0, 0)));
     143        assertNotNull(ImageProvider.getPadded(new Node(), iconSize));
     144        assertNull(ImageProvider.getPadded(new Node(), iconSize, noDefault));
     145        assertNotNull(ImageProvider.getPadded(OsmUtils.createPrimitive("node amenity=restaurant"), iconSize, noDefault));
     146        assertNull(ImageProvider.getPadded(OsmUtils.createPrimitive("node barrier=hedge"), iconSize,
     147                EnumSet.of(GetPaddedOptions.NO_DEFAULT, GetPaddedOptions.NO_DEPRECATED)));
     148        assertNotNull(ImageProvider.getPadded(OsmUtils.createPrimitive("way waterway=stream"), iconSize, noDefault));
     149        assertNotNull(ImageProvider.getPadded(OsmUtils.createPrimitive("relation type=route route=railway"), iconSize, noDefault));
     150    }
    118151}
Note: See TracChangeset for help on using the changeset viewer.