Changeset 16235 in josm
- Timestamp:
- 2020-04-06T00:29:19+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
r16224 r16235 82 82 return Stream.of( 83 83 /** Tests for StyledMapRenderer#drawNodeSymbol */ 84 new TestConfig("node-shapes", AREA_DEFAULT), 84 new TestConfig("node-shapes", AREA_DEFAULT) 85 .setThresholdPixels(100).setThresholdTotalColorDiff(2_110), 85 86 86 87 /** Text for nodes */ 87 88 new TestConfig("node-text", AREA_DEFAULT).usesFont("DejaVu Sans") 88 .setThresholdPixels( 100).setThresholdTotalColorDiff(100),89 .setThresholdPixels(530).setThresholdTotalColorDiff(23_800), 89 90 90 91 /** Tests that StyledMapRenderer#drawWay respects width */ 91 new TestConfig("way-width", AREA_DEFAULT), 92 new TestConfig("way-width", AREA_DEFAULT) 93 .setThresholdPixels(280).setThresholdTotalColorDiff(22_500), 92 94 93 95 /** Tests the way color property, including alpha */ 94 new TestConfig("way-color", AREA_DEFAULT), 96 new TestConfig("way-color", AREA_DEFAULT) 97 .setThresholdPixels(100).setThresholdTotalColorDiff(3_400), 95 98 96 99 /** Tests dashed ways. */ 97 new TestConfig("way-dashes", AREA_DEFAULT), 100 new TestConfig("way-dashes", AREA_DEFAULT) 101 .setThresholdPixels(460).setThresholdTotalColorDiff(12_100), 98 102 99 103 /** Tests dashed way clamping algorithm */ 100 new TestConfig("way-dashes-clamp", AREA_DEFAULT), 104 new TestConfig("way-dashes-clamp", AREA_DEFAULT) 105 .setThresholdPixels(200).setThresholdTotalColorDiff(6_800), 101 106 102 107 /** Tests fill-color property */ … … 104 109 105 110 /** Tests the fill-image property. */ 106 new TestConfig("area-fill-image", AREA_DEFAULT), 111 new TestConfig("area-fill-image", AREA_DEFAULT) 112 .setThresholdPixels(420).setThresholdTotalColorDiff(11_200), 107 113 108 114 /** Tests area label drawing/placement */ 109 new TestConfig("area-text", AREA_DEFAULT).setThresholdPixels(50).setThresholdTotalColorDiff(50), 115 new TestConfig("area-text", AREA_DEFAULT) 116 .setThresholdPixels(550).setThresholdTotalColorDiff(17_400), 110 117 111 118 /** Tests area icon drawing/placement */ 112 new TestConfig("area-icon", AREA_DEFAULT), 119 new TestConfig("area-icon", AREA_DEFAULT) 120 .setThresholdPixels(680).setThresholdTotalColorDiff(23_000), 113 121 114 122 /** Tests if all styles are sorted correctly. Tests {@link StyleRecord#compareTo(StyleRecord)} */ 115 new TestConfig("order", AREA_DEFAULT), 123 new TestConfig("order", AREA_DEFAULT) 124 .setThresholdPixels(2050).setThresholdTotalColorDiff(101_800), 116 125 117 126 /** Tests repeat-image feature for ways */ 118 new TestConfig("way-repeat-image", AREA_DEFAULT), 127 new TestConfig("way-repeat-image", AREA_DEFAULT) 128 .setThresholdPixels(2100).setThresholdTotalColorDiff(93_000), 119 129 /** Tests the clamping for repeat-images and repeat-image-phase */ 120 new TestConfig("way-repeat-image-clamp", AREA_DEFAULT), 130 new TestConfig("way-repeat-image-clamp", AREA_DEFAULT) 131 .setThresholdPixels(80).setThresholdTotalColorDiff(2_300), 121 132 122 133 /** Tests text along a way */ 123 new TestConfig("way-text", AREA_DEFAULT).setThresholdPixels(20).setThresholdTotalColorDiff(40), 134 new TestConfig("way-text", AREA_DEFAULT) 135 .setThresholdPixels(3400).setThresholdTotalColorDiff(122_700), 124 136 125 137 /** Another test for node shapes */ 126 new TestConfig("node-shapes2").setImageWidth(600), 138 new TestConfig("node-shapes2").setImageWidth(600) 139 .setThresholdPixels(1230).setThresholdTotalColorDiff(43_700), 127 140 /** Tests default values for node shapes */ 128 new TestConfig("node-shapes-default"), 141 new TestConfig("node-shapes-default") 142 .setThresholdPixels(10).setThresholdTotalColorDiff(270), 129 143 /** Tests node shapes with both fill and stroke combined */ 130 new TestConfig("node-shapes-combined"), 144 new TestConfig("node-shapes-combined") 145 .setThresholdPixels(360).setThresholdTotalColorDiff(9_200), 131 146 /** Another test for dashed ways */ 132 new TestConfig("way-dashes2"), 147 new TestConfig("way-dashes2") 148 .setThresholdPixels(340).setThresholdTotalColorDiff(16_100), 133 149 /** Tests node text placement */ 134 new TestConfig("node-text2").setThresholdPixels(30).setThresholdTotalColorDiff(50), 150 new TestConfig("node-text2") 151 .setThresholdPixels(1020).setThresholdTotalColorDiff(345_000), 135 152 /** Tests relation link selector */ 136 new TestConfig("relation-linkselector"), 153 new TestConfig("relation-linkselector") 154 .setThresholdPixels(430).setThresholdTotalColorDiff(13_000), 137 155 /** Tests parent selector on relation */ 138 new TestConfig("relation-parentselector"), 156 new TestConfig("relation-parentselector") 157 .setThresholdPixels(310).setThresholdTotalColorDiff(8_200), 139 158 140 159 /** Tests evaluation of expressions */ 141 new TestConfig("eval").setImageWidth(600).setThresholdPixels(100).setThresholdTotalColorDiff(100) 160 new TestConfig("eval").setImageWidth(600) 161 .setThresholdPixels(6610).setThresholdTotalColorDiff(3_304_000) 142 162 143 163 ).map(e -> new Object[] {e, e.testDirectory}) … … 217 237 int result = image.getRGB(x, y); 218 238 if (!colorsAreSame(expected, result)) { 219 differencePoints.add(new Point(x, y));220 239 Color expectedColor = new Color(expected, true); 221 240 Color resultColor = new Color(result, true); … … 224 243 + Math.abs(expectedColor.getBlue() - resultColor.getBlue()); 225 244 int alphaDiff = Math.abs(expectedColor.getAlpha() - resultColor.getAlpha()); 226 if (differences.length() < 500) { 227 differences.append("\nDifference at ") 228 .append(x) 229 .append(",") 230 .append(y) 231 .append(": Expected ") 232 .append(ColorHelper.color2html(expectedColor)) 233 .append(" but got ") 234 .append(ColorHelper.color2html(resultColor)) 235 .append(" (color diff is ") 236 .append(colorDiff) 237 .append(", alpha diff is ") 238 .append(alphaDiff) 239 .append(")"); 245 // Ignore small alpha differences due to Java versions, rendering libraries and so on 246 if (alphaDiff <= 20) { 247 alphaDiff = 0; 248 } 249 // Ignore small color differences for the same reasons, but also completely for almost-transparent pixels 250 if (colorDiff <= 15 || resultColor.getAlpha() <= 20) { 251 colorDiff = 0; 252 } 253 if (colorDiff + alphaDiff > 0) { 254 differencePoints.add(new Point(x, y)); 255 if (differences.length() < 2000) { 256 differences.append("\nDifference at ") 257 .append(x) 258 .append(",") 259 .append(y) 260 .append(": Expected ") 261 .append(ColorHelper.color2html(expectedColor)) 262 .append(" but got ") 263 .append(ColorHelper.color2html(resultColor)) 264 .append(" (color diff is ") 265 .append(colorDiff) 266 .append(", alpha diff is ") 267 .append(alphaDiff) 268 .append(")"); 269 } 240 270 } 241 271 colorDiffSum += colorDiff + alphaDiff;
Note:
See TracChangeset
for help on using the changeset viewer.