Index: trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
===================================================================
--- trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java	(revision 19220)
+++ trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java	(revision 19221)
@@ -2,11 +2,8 @@
 package org.openstreetmap.josm.gui.mappaint;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
 import static org.junit.jupiter.api.Assumptions.assumeTrue;
-
-import java.awt.Color;
+import static org.openstreetmap.josm.testutils.ImageTestUtils.assertImageEquals;
+
 import java.awt.GraphicsEnvironment;
-import java.awt.Point;
 import java.awt.image.BufferedImage;
 import java.io.File;
@@ -15,5 +12,4 @@
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -21,5 +17,4 @@
 import java.util.Collections;
 import java.util.List;
-import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -40,5 +35,4 @@
 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
 import org.openstreetmap.josm.testutils.annotations.Projection;
-import org.openstreetmap.josm.tools.ColorHelper;
 import org.openstreetmap.josm.tools.Utils;
 
@@ -59,7 +53,4 @@
     private static final int IMAGE_SIZE = 256;
 
-    // development flag - set to true in order to update all reference images
-    private static final boolean UPDATE_ALL = false;
-
     /**
      * The different configurations of this test.
@@ -202,109 +193,4 @@
     }
 
-    /**
-     * Compares the reference image file with the actual images given as {@link BufferedImage}.
-     * @param testIdentifier a test identifier for error messages
-     * @param referenceImageFile the reference image file to be read using {@link ImageIO#read(File)}
-     * @param image the actual image
-     * @param thresholdPixels maximum number of differing pixels
-     * @param thresholdTotalColorDiff maximum sum of color value differences
-     * @param diffImageConsumer a consumer for a rendered image highlighting the differing pixels, may be null
-     * @throws IOException in case of I/O error
-     */
-    public static void assertImageEquals(
-            String testIdentifier, File referenceImageFile, BufferedImage image,
-            int thresholdPixels, int thresholdTotalColorDiff, Consumer<BufferedImage> diffImageConsumer) throws IOException {
-
-        // TODO move to separate class ImageTestUtils
-        if (UPDATE_ALL) {
-            ImageIO.write(image, "png", referenceImageFile);
-            return;
-        }
-        final BufferedImage reference = ImageIO.read(referenceImageFile);
-        assertImageEquals(testIdentifier, reference, image, thresholdPixels, thresholdTotalColorDiff, diffImageConsumer);
-    }
-
-    /**
-     * Compares the reference image file with the actual images given as {@link BufferedImage}.
-     * @param testIdentifier a test identifier for error messages
-     * @param reference the reference image
-     * @param image the actual image
-     * @param thresholdPixels maximum number of differing pixels
-     * @param thresholdTotalColorDiff maximum sum of color value differences
-     * @param diffImageConsumer a consumer for a rendered image highlighting the differing pixels, may be null
-     */
-    public static void assertImageEquals(String testIdentifier, BufferedImage reference, BufferedImage image,
-                                         int thresholdPixels, int thresholdTotalColorDiff, Consumer<BufferedImage> diffImageConsumer) {
-        assertEquals(reference.getWidth(), image.getWidth());
-        assertEquals(reference.getHeight(), image.getHeight());
-
-        StringBuilder differences = new StringBuilder();
-        ArrayList<Point> differencePoints = new ArrayList<>();
-        int colorDiffSum = 0;
-
-        for (int y = 0; y < reference.getHeight(); y++) {
-            for (int x = 0; x < reference.getWidth(); x++) {
-                int expected = reference.getRGB(x, y);
-                int result = image.getRGB(x, y);
-                int expectedAlpha = expected >> 24;
-                boolean colorsAreSame = expectedAlpha == 0 ? result >> 24 == 0 : expected == result;
-                if (!colorsAreSame) {
-                    Color expectedColor = new Color(expected, true);
-                    Color resultColor = new Color(result, true);
-                    int colorDiff = Math.abs(expectedColor.getRed() - resultColor.getRed())
-                            + Math.abs(expectedColor.getGreen() - resultColor.getGreen())
-                            + Math.abs(expectedColor.getBlue() - resultColor.getBlue());
-                    int alphaDiff = Math.abs(expectedColor.getAlpha() - resultColor.getAlpha());
-                    // Ignore small alpha differences due to Java versions, rendering libraries and so on
-                    if (alphaDiff <= 20) {
-                        alphaDiff = 0;
-                    }
-                    // Ignore small color differences for the same reasons, but also completely for almost-transparent pixels
-                    if (colorDiff <= 15 || resultColor.getAlpha() <= 20) {
-                        colorDiff = 0;
-                    }
-                    if (colorDiff + alphaDiff > 0) {
-                        differencePoints.add(new Point(x, y));
-                        if (differences.length() < 2000) {
-                            differences.append("\nDifference at ")
-                            .append(x)
-                            .append(",")
-                            .append(y)
-                            .append(": Expected ")
-                            .append(ColorHelper.color2html(expectedColor))
-                            .append(" but got ")
-                            .append(ColorHelper.color2html(resultColor))
-                            .append(" (color diff is ")
-                            .append(colorDiff)
-                            .append(", alpha diff is ")
-                            .append(alphaDiff)
-                            .append(")");
-                        }
-                    }
-                    colorDiffSum += colorDiff + alphaDiff;
-                }
-            }
-        }
-
-        if (differencePoints.size() > thresholdPixels || colorDiffSum > thresholdTotalColorDiff) {
-            // Add a nice image that highlights the differences:
-            BufferedImage diffImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
-            for (Point p : differencePoints) {
-                diffImage.setRGB(p.x, p.y, 0xffff0000);
-            }
-            if (diffImageConsumer != null) {
-                diffImageConsumer.accept(diffImage);
-            }
-
-            if (differencePoints.size() > thresholdPixels) {
-                fail(MessageFormat.format("Images for test {0} differ at {1} points, threshold is {2}: {3}",
-                        testIdentifier, differencePoints.size(), thresholdPixels, differences.toString()));
-            } else {
-                fail(MessageFormat.format("Images for test {0} differ too much in color, value is {1}, permitted threshold is {2}: {3}",
-                        testIdentifier, colorDiffSum, thresholdTotalColorDiff, differences.toString()));
-            }
-        }
-    }
-
     private void loadPrimitiveStyle(OsmPrimitive n) {
         n.setHighlighted(n.isKeyTrue("highlight"));
Index: trunk/test/functional/org/openstreetmap/josm/tools/ImageProviderTest.java
===================================================================
--- trunk/test/functional/org/openstreetmap/josm/tools/ImageProviderTest.java	(revision 19220)
+++ trunk/test/functional/org/openstreetmap/josm/tools/ImageProviderTest.java	(revision 19221)
@@ -6,5 +6,5 @@
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.openstreetmap.josm.gui.mappaint.MapCSSRendererTest.assertImageEquals;
+import static org.openstreetmap.josm.testutils.ImageTestUtils.assertImageEquals;
 
 import java.awt.Dimension;
