Changeset 19055 in josm for trunk/test
- Timestamp:
- 2024-04-23T18:41:05+02:00 (7 months ago)
- Location:
- trunk/test
- Files:
-
- 23 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
r18870 r19055 21 21 import java.util.Collections; 22 22 import java.util.List; 23 import java.util.Locale;24 23 import java.util.function.Consumer; 25 24 import java.util.stream.Collectors; … … 42 41 import org.openstreetmap.josm.testutils.annotations.Projection; 43 42 import org.openstreetmap.josm.tools.ColorHelper; 44 import org.openstreetmap.josm.tools.Utils;45 43 46 44 /** … … 70 68 public static Collection<Object[]> runs() { 71 69 return Stream.of( 72 /* *Tests for StyledMapRenderer#drawNodeSymbol */70 /* Tests for StyledMapRenderer#drawNodeSymbol */ 73 71 new TestConfig("node-shapes", AREA_DEFAULT) 74 72 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 75 73 76 /* *Text for nodes */74 /* Text for nodes */ 77 75 new TestConfig("node-text", AREA_DEFAULT).usesFont("DejaVu Sans") 78 76 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 79 77 80 /* *Tests that StyledMapRenderer#drawWay respects width */78 /* Tests that StyledMapRenderer#drawWay respects width */ 81 79 new TestConfig("way-width", AREA_DEFAULT) 82 80 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 83 81 84 /* *Tests the way color property, including alpha */82 /* Tests the way color property, including alpha */ 85 83 new TestConfig("way-color", AREA_DEFAULT) 86 84 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 87 85 88 /* *Tests dashed ways. */86 /* Tests dashed ways. */ 89 87 new TestConfig("way-dashes", AREA_DEFAULT) 90 88 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 91 89 92 /* *Tests dashed way clamping algorithm */90 /* Tests dashed way clamping algorithm */ 93 91 new TestConfig("way-dashes-clamp", AREA_DEFAULT) 94 92 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 95 93 96 /* *Tests fill-color property */94 /* Tests fill-color property */ 97 95 new TestConfig("area-fill-color", AREA_DEFAULT), 98 96 99 /* *Tests the fill-image property. */97 /* Tests the fill-image property. */ 100 98 new TestConfig("area-fill-image", AREA_DEFAULT) 101 99 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 102 100 103 /* *Tests area label drawing/placement */101 /* Tests area label drawing/placement */ 104 102 new TestConfig("area-text", AREA_DEFAULT) 105 103 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 106 104 107 /* *Tests area icon drawing/placement */105 /* Tests area icon drawing/placement */ 108 106 new TestConfig("area-icon", AREA_DEFAULT) 109 107 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 110 108 111 /* *Tests if all styles are sorted correctly. Tests {@link StyleRecord#compareTo(StyleRecord)} */109 /* Tests if all styles are sorted correctly. Tests {@link StyleRecord#compareTo(StyleRecord)} */ 112 110 new TestConfig("order", AREA_DEFAULT) 113 111 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 114 112 115 /* *Tests repeat-image feature for ways */113 /* Tests repeat-image feature for ways */ 116 114 new TestConfig("way-repeat-image", AREA_DEFAULT) 117 115 .setThresholdPixels(2100).setThresholdTotalColorDiff(93_000), 118 /* *Tests the clamping for repeat-images and repeat-image-phase */116 /* Tests the clamping for repeat-images and repeat-image-phase */ 119 117 new TestConfig("way-repeat-image-clamp", AREA_DEFAULT) 120 118 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 121 119 122 /* *Tests text along a way */120 /* Tests text along a way */ 123 121 new TestConfig("way-text", AREA_DEFAULT) 124 122 .setThresholdPixels(3400).setThresholdTotalColorDiff(0), 125 123 126 /* *Another test for node shapes */124 /* Another test for node shapes */ 127 125 new TestConfig("node-shapes2").setImageWidth(600) 128 126 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 129 /* *Tests default values for node shapes */127 /* Tests default values for node shapes */ 130 128 new TestConfig("node-shapes-default") 131 129 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 132 /* *Tests node shapes with both fill and stroke combined */130 /* Tests node shapes with both fill and stroke combined */ 133 131 new TestConfig("node-shapes-combined") 134 132 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 135 /* *Another test for dashed ways */133 /* Another test for dashed ways */ 136 134 new TestConfig("way-dashes2") 137 135 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 138 /* *Tests node text placement */136 /* Tests node text placement */ 139 137 new TestConfig("node-text2") 140 138 .setThresholdPixels(1020).setThresholdTotalColorDiff(0), 141 /* *Tests relation link selector */139 /* Tests relation link selector */ 142 140 new TestConfig("relation-linkselector") 143 141 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 144 /* *Tests parent selector on relation */142 /* Tests parent selector on relation */ 145 143 new TestConfig("relation-parentselector") 146 144 .setThresholdPixels(0).setThresholdTotalColorDiff(0), 147 145 148 /* *Tests evaluation of expressions */146 /* Tests evaluation of expressions */ 149 147 new TestConfig("eval").setImageWidth(600) 150 148 .setThresholdPixels(6610).setThresholdTotalColorDiff(0) … … 163 161 @MethodSource("runs") 164 162 void testRender(TestConfig testConfig, String ignored) throws Exception { 165 // This test only runs on OpenJDK.166 // It is ignored for other Java versions since they differ slightly in their rendering engine.167 String javaHome = System.getProperty("java.home");168 assumeTrue(javaHome != null && javaHome.toLowerCase(Locale.ENGLISH).contains("openjdk"), "Test requires openJDK");169 170 163 List<String> fonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); 171 164 for (String font : testConfig.fonts) { … … 228 221 } 229 222 final BufferedImage reference = ImageIO.read(referenceImageFile); 230 assertEquals( image.getWidth(), reference.getWidth());231 assertEquals( image.getHeight(), reference.getHeight());223 assertEquals(reference.getWidth(), image.getWidth()); 224 assertEquals(reference.getHeight(), image.getHeight()); 232 225 233 226 StringBuilder differences = new StringBuilder(); … … 331 324 /** 332 325 * Set the number of pixels that can differ. 333 * 326 * <p> 334 327 * Needed due to somewhat platform dependent font rendering. 335 328 * @param thresholdPixels the number of pixels that can differ … … 359 352 360 353 public File getReference() { 361 // Java 8 renders SVG images differently, thus, use separate reference files362 final String javaSuffix = Utils.getJavaVersion() == 8 ? "-java8" : "";363 return new File(getTestDirectory() + "/reference " + javaSuffix + ".png");354 // Sometimes Java changes how things are rendered. When that happens, use separate reference files. It is 355 // usually "reference" + javaSuffix + ".png". 356 return new File(getTestDirectory() + "/reference.png"); 364 357 } 365 358 -
trunk/test/functional/org/openstreetmap/josm/tools/ImageProviderTest.java
r18856 r19055 189 189 190 190 private static File getReferenceFile(String reference) { 191 // Java 8 and Java 21 render SVG images differently, thus, use separate reference files 192 final String javaSuffix; 193 switch (Utils.getJavaVersion()) { 194 case 8: javaSuffix = "-java8"; 195 break; 196 case 21: javaSuffix = "-java21"; 197 break; 198 default: javaSuffix = ""; 199 } 191 // Java 11-17 and Java 21 render SVG images differently, thus, use separate reference files 192 final String javaSuffix = Utils.getJavaVersion() == 21 ? "-java21" : ""; 200 193 return new File(TestUtils.getTestDataRoot() + "/" + ImageProviderTest.class.getSimpleName() + javaSuffix + "/" + reference + ".png"); 201 194 } -
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r19054 r19055 24 24 import org.openstreetmap.josm.testutils.annotations.I18n; 25 25 import org.openstreetmap.josm.tools.UncheckedParseException; 26 import org.openstreetmap.josm.tools.Utils; 26 27 27 28 import net.trajano.commons.testing.UtilityClassTestUtil; … … 153 154 @Test 154 155 void testFormatTime() { 155 assertEquals("12:00 AM", DateUtils.formatTime(new Date(0), DateFormat.SHORT)); 156 assertEquals("1:00 AM", DateUtils.formatTime(new Date(60 * 60 * 1000), DateFormat.SHORT)); 157 assertEquals("12:00 AM", DateUtils.formatTime(new Date(999), DateFormat.SHORT)); 156 // Somewhere between Java 17 and Java 21, a non-breaking space replaced the original space between the time and AM/PM. 157 final var separator = Utils.getJavaVersion() >= 21 ? '\u202f' : ' '; 158 final var twelveAM = "12:00" + separator + "AM"; 159 assertEquals(twelveAM, DateUtils.formatTime(new Date(0), DateFormat.SHORT)); 160 assertEquals("1:00" + separator + "AM", DateUtils.formatTime(new Date(60 * 60 * 1000), DateFormat.SHORT)); 161 assertEquals(twelveAM, DateUtils.formatTime(new Date(999), DateFormat.SHORT)); 158 162 // ignore seconds 159 assertEquals( "12:00 AM", DateUtils.formatTime(new Date(5999), DateFormat.SHORT));163 assertEquals(twelveAM, DateUtils.formatTime(new Date(5999), DateFormat.SHORT)); 160 164 161 165 setTimeZone(TimeZone.getTimeZone("Europe/Berlin")); 162 assertEquals("1:00:00 166 assertEquals("1:00:00" + separator + "AM GMT+01:00", DateUtils.formatTime(new Date(0), DateFormat.LONG), "This is mostly dependent upon java.locale.providers. CET is also OK."); 163 167 } 164 168
Note:
See TracChangeset
for help on using the changeset viewer.