Skip to content

Commit

Permalink
Add dist test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Aug 14, 2023
1 parent e068c54 commit ac026b6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private File getRelatedFile(final String name) {
*
* @return a number between 0 and 10000 or Double.MAX_VALUE on images format error.
*/
private double calcDistance(final BufferedImage actual) {
double calcDistance(final BufferedImage actual) {
// There are several ways to calculate distances between two vectors,
// we will calculate the sum of the distances between the RGB values of
// pixels in the same positions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public abstract class AbstractMapfishSpringTest {
public static File getFile(Class<?> testClass, String fileName) {
final URL resource = testClass.getResource(fileName);
if (resource == null) {
throw new AssertionError("Unable to find test resource: " + fileName);
throw new AssertionError(
"Unable to find test resource: " + fileName + ", on: " + testClass.getName());
}

return new File(resource.getFile());
Expand Down
15 changes: 0 additions & 15 deletions core/src/test/java/org/mapfish/print/CheckTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.mapfish.print.test.util;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import javax.imageio.ImageIO;
import org.junit.Test;
import org.mapfish.print.AbstractMapfishSpringTest;

public class ImageSimilarityTest extends AbstractMapfishSpringTest {

/** Ensure that we ar not regenerating the expected images in the CI. */
@Test
public void testNotRegenerateImage() throws Exception {
assertFalse(
"This flag should not be committed as true", ImageSimilarity.REGENERATE_EXPECTED_IMAGES);
}

/** Test that we get a distance in images with small differences. */
@Test
public void testSmallDist() throws Exception {
assertTrue(
new ImageSimilarity(getFile("imageSimilarity/with.png"))
.calcDistance(ImageIO.read(getFile("imageSimilarity/without.png")))
> 0);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ac026b6

Please sign in to comment.