Skip to content

Commit

Permalink
add two test cases and relavent pictures for solving issue romankh3#211
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheese-Bar committed Apr 19, 2022
1 parent bc9197e commit 842cbd8
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,44 @@ public void shouldProperlyCompareMisSizedImages() {
assertTrue(differenceLessThan2);
}

@DisplayName("Should properly compare in bug 211")
@Test
public void shouldProperlyCompareInBug211() {
//given
BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expected#211.png");
BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actual#211.png");
BufferedImage resultImage = readImageFromResources("result#211.png");

//when
ImageComparisonResult imageComparisonResult =
new ImageComparison(expectedImage, actualImage)
.setPixelToleranceLevel(0.0)
.compareImages();

//then
assertEquals(MISMATCH, imageComparisonResult.getImageComparisonState());
assertImagesEqual(resultImage, imageComparisonResult.getResult());
}

@DisplayName("Should properly compare pure color in issue 211")
@Test
public void shouldProperlyComparePureColorIn211() {
//given
BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expectedColor#211.png");
BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actualColor#211.png");
BufferedImage resultImage = readImageFromResources("resultColor#211.png");

//when
ImageComparisonResult imageComparisonResult =
new ImageComparison(expectedImage, actualImage)
.setPixelToleranceLevel(0.079)
.compareImages();

//then
assertEquals(MISMATCH, imageComparisonResult.getImageComparisonState());
assertImagesEqual(resultImage, imageComparisonResult.getResult());
}

private void assertImagesEqual(BufferedImage expected, BufferedImage actual) {
if (expected.getWidth() != actual.getWidth() || expected.getHeight() != actual.getHeight()) {
fail("Images have different dimensions");
Expand Down
Binary file added src/test/resources/actual#211.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/test/resources/actualColor#211.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/test/resources/expected#211.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/test/resources/expectedColor#211.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/test/resources/result#211.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/test/resources/resultColor#211.png
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 842cbd8

Please sign in to comment.