Changeset 16768 in josm for trunk/test/unit/org
- Timestamp:
- 2020-07-14T20:19:40+02:00 (4 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java
r15539 r16768 13 13 import java.util.List; 14 14 import java.util.Locale; 15 import java.util.Objects;16 15 import java.util.Set; 17 import java.util.concurrent.ExecutionException;18 import java.util.concurrent.TimeUnit;19 import java.util.concurrent.TimeoutException;20 16 21 17 import org.junit.BeforeClass; … … 29 25 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 30 26 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; 27 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetsTest; 31 28 import org.openstreetmap.josm.gui.tagging.presets.items.Link; 32 29 import org.openstreetmap.josm.spi.preferences.Config; … … 116 113 Collection<TaggingPreset> presets = TaggingPresetReader.readAll(source.url, true); 117 114 assertFalse(presets.isEmpty()); 118 // wait for asynchronous icon loading 119 presets.parallelStream().map(TaggingPreset::getIconLoadingTask).filter(Objects::nonNull).forEach(t -> { 120 try { 121 t.get(30, TimeUnit.SECONDS); 122 } catch (InterruptedException | ExecutionException | TimeoutException e) { 123 Logging.error(e); 124 } 125 }); 115 TaggingPresetsTest.waitForIconLoading(presets); 126 116 // check that links are correct and not redirections 127 117 presets.parallelStream().flatMap(x -> x.data.stream().filter(i -> i instanceof Link).map(i -> ((Link) i).getUrl())).forEach(u -> { -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetsTest.java
r16182 r16768 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.tagging.presets; 3 4 import java.util.Collection; 5 import java.util.Objects; 6 import java.util.concurrent.ExecutionException; 7 import java.util.concurrent.TimeUnit; 8 import java.util.concurrent.TimeoutException; 3 9 4 10 import org.junit.Rule; 5 11 import org.junit.Test; 6 12 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 import org.openstreetmap.josm.tools.Logging; 7 14 8 15 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 29 36 UtilityClassTestUtil.assertUtilityClassWellDefined(TaggingPresets.class); 30 37 } 38 39 /** 40 * Wait for asynchronous icon loading 41 * @param presets presets collection 42 */ 43 public static void waitForIconLoading(Collection<TaggingPreset> presets) { 44 presets.parallelStream().map(TaggingPreset::getIconLoadingTask).filter(Objects::nonNull).forEach(t -> { 45 try { 46 t.get(30, TimeUnit.SECONDS); 47 } catch (InterruptedException | ExecutionException | TimeoutException e) { 48 Logging.error(e); 49 } 50 }); 51 } 31 52 } -
trunk/test/unit/org/openstreetmap/josm/tools/ImageProviderTest.java
r16764 r16768 6 6 import static org.junit.Assert.assertFalse; 7 7 import static org.junit.Assert.assertNotNull; 8 import static org.junit.Assert.assertNull;9 8 import static org.junit.Assert.assertTrue; 10 9 … … 23 22 import java.io.File; 24 23 import java.io.IOException; 25 import java.util.EnumSet;26 24 import java.util.List; 27 25 import java.util.logging.Handler; … … 40 38 import org.openstreetmap.josm.JOSMFixture; 41 39 import org.openstreetmap.josm.TestUtils; 42 import org.openstreetmap.josm.data.osm.Node;43 import org.openstreetmap.josm.data.osm.OsmUtils;44 40 import org.openstreetmap.josm.testutils.JOSMTestRules; 45 import org.openstreetmap.josm.tools.ImageProvider.GetPaddedOptions;46 41 47 42 import com.kitfox.svg.SVGConst; … … 59 54 @Rule 60 55 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 61 public JOSMTestRules test = new JOSMTestRules() .mapStyles().presets();56 public JOSMTestRules test = new JOSMTestRules(); 62 57 63 58 private static final class LogHandler14319 extends Handler { … … 151 146 "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4"+ 152 147 "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==")); 153 }154 155 /**156 * Unit test of {@link ImageProvider#getPadded}.157 */158 @Test159 public void testGetPadded() {160 final EnumSet<GetPaddedOptions> noDefault = EnumSet.of(GetPaddedOptions.NO_DEFAULT);161 final Dimension iconSize = new Dimension(16, 16);162 163 assertNull(ImageProvider.getPadded(new Node(), new Dimension(0, 0)));164 assertNotNull(ImageProvider.getPadded(new Node(), iconSize));165 assertNull(ImageProvider.getPadded(new Node(), iconSize, noDefault));166 assertNotNull(ImageProvider.getPadded(OsmUtils.createPrimitive("node amenity=restaurant"), iconSize, noDefault));167 assertNull(ImageProvider.getPadded(OsmUtils.createPrimitive("node barrier=hedge"), iconSize,168 EnumSet.of(GetPaddedOptions.NO_DEFAULT, GetPaddedOptions.NO_DEPRECATED)));169 assertNotNull(ImageProvider.getPadded(OsmUtils.createPrimitive("way waterway=stream"), iconSize, noDefault));170 assertNotNull(ImageProvider.getPadded(OsmUtils.createPrimitive("relation type=route route=railway"), iconSize, noDefault));171 148 } 172 149
Note:
See TracChangeset
for help on using the changeset viewer.