Skip to content

Commit

Permalink
Added bmp support for fuzzy image testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylussaud committed Aug 28, 2024
1 parent 05b1e37 commit 2980604
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Obeo.
* Copyright (c) 2017, 2024 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -138,6 +138,26 @@ public static void assertPNG(File diffOutput, InputStream expectedIs, InputStrea
}
}

/**
* Asserts that the given expected and actual PNGs look like each other.
*
* @param diffOutput
* the difference PNG or <code>null</code>
* @param expectedIs
* the expected PNG
* @param actualIs
* the actual PNG
* @param threshold
* the difference threshold of a block
*/
public static void assertBMP(File diffOutput, InputStream expectedIs, InputStream actualIs, double threshold) {
try {
assertTrue(fuzzyCompareImage("BMP", diffOutput, expectedIs, actualIs, threshold));
} catch (IOException e) {
fail(e.getMessage());
}
}

/**
* Asserts that the given expected and actual JPGs look like each other.
*
Expand All @@ -162,7 +182,7 @@ public static void assertJPG(File diffOutput, InputStream expectedIs, InputStrea
* Tells if the actual image look like the expected image.
*
* @param imageFormat
* GIF,PNG, or JPG
* GIF, PNG, BMP, or JPG
* @param diffOutput
* the difference {@link File} or <code>null</code>
* @param expectedIs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016 Obeo.
* Copyright (c) 2016, 2024 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -355,6 +355,9 @@ public static void assertArchiveContent(URIConverter uriConverter, URI expectedU
} else if (entry.getKey().endsWith(".png")) {
final File imageDiff = getDiffImageFile(expectedURI.toFileString(), entry.getKey());
ImageTestUtils.assertPNG(imageDiff, expectedInputStream, actualInputStream, IMAGE_THRESHOLD);
} else if (entry.getKey().endsWith(".bmp")) {
final File imageDiff = getDiffImageFile(expectedURI.toFileString(), entry.getKey());
ImageTestUtils.assertBMP(imageDiff, expectedInputStream, actualInputStream, IMAGE_THRESHOLD);
} else {
final String expectedHash = getZipEntryHash(expectedInputStream, entry.getKey());
final String actualHash = getZipEntryHash(actualInputStream, entry.getKey());
Expand Down

0 comments on commit 2980604

Please sign in to comment.