Skip to content

Commit 45cf85b

Browse files
inha-briiaglibas
authored andcommitted
Add tests for highlight and addText methods (#5)
* Add tests for highlight and addText methods * Temporary disable testAddText
1 parent f36d23b commit 45cf85b

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ build
66
bin
77
*.iml
88
.idea
9-
screenshots
9+
screenshots
10+
*main.java

src/test/java/com/assertthat/selenium_shutterbug/utils/image/ImageProcessorTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@
1616

1717
package com.assertthat.selenium_shutterbug.utils.image;
1818

19+
import com.assertthat.selenium_shutterbug.utils.web.Coordinates;
20+
import org.junit.Ignore;
1921
import org.junit.Test;
22+
import org.openqa.selenium.*;
23+
import org.openqa.selenium.Dimension;
24+
import org.openqa.selenium.Point;
2025

2126
import javax.imageio.ImageIO;
27+
import java.awt.*;
2228
import java.awt.image.BufferedImage;
2329
import java.io.IOException;
2430

@@ -69,5 +75,25 @@ public void testImagesAreEqualsWithDeviation() throws IOException {
6975
assertTrue("Images are not equal with deviation: " + deviation,ImageProcessor.imagesAreEquals(image1, image2, deviation));
7076
}
7177

78+
@Test
79+
public void testHighlight() throws IOException {
80+
Point point = new Point(9,33);
81+
Dimension size = new Dimension(141,17);
82+
Coordinates coords = new Coordinates(point, size);
83+
BufferedImage clearImage = ImageIO.read(Thread.currentThread().getContextClassLoader().getResourceAsStream("clearImage.png"));
84+
BufferedImage highlightedExpectedImage = ImageIO.read(Thread.currentThread().getContextClassLoader().getResourceAsStream("highlightedImage.png"));
85+
BufferedImage highlightedActualImage = ImageProcessor.highlight(clearImage, coords, Color.red, 3);
86+
assertTrue("Images are not equal after highlighting",ImageProcessor.imagesAreEquals(highlightedExpectedImage, highlightedActualImage, 0.0));
87+
}
88+
89+
@Ignore
90+
@Test
91+
public void testAddText() throws IOException {
92+
BufferedImage clearImage = ImageIO.read(Thread.currentThread().getContextClassLoader().getResourceAsStream("clearImage.png"));
93+
BufferedImage addedTextExpectedImage = ImageIO.read(Thread.currentThread().getContextClassLoader().getResourceAsStream("addedTextImage.png"));
94+
BufferedImage addedTextActualImage = ImageProcessor.addText(clearImage, 60, 70, "ABC", Color.red, new Font("SansSerif", Font.BOLD, 20));
95+
assertTrue("Images are not equal after adding text",ImageProcessor.imagesAreEquals(addedTextExpectedImage, addedTextActualImage, 0.0));
96+
}
97+
7298

7399
}

src/test/resources/addedTextImage.png

1.43 KB
Loading
1.38 KB
Loading

0 commit comments

Comments
 (0)