|
16 | 16 |
|
17 | 17 | package com.assertthat.selenium_shutterbug.utils.image;
|
18 | 18 |
|
| 19 | +import com.assertthat.selenium_shutterbug.utils.web.Coordinates; |
| 20 | +import org.junit.Ignore; |
19 | 21 | import org.junit.Test;
|
| 22 | +import org.openqa.selenium.*; |
| 23 | +import org.openqa.selenium.Dimension; |
| 24 | +import org.openqa.selenium.Point; |
20 | 25 |
|
21 | 26 | import javax.imageio.ImageIO;
|
| 27 | +import java.awt.*; |
22 | 28 | import java.awt.image.BufferedImage;
|
23 | 29 | import java.io.IOException;
|
24 | 30 |
|
@@ -69,5 +75,25 @@ public void testImagesAreEqualsWithDeviation() throws IOException {
|
69 | 75 | assertTrue("Images are not equal with deviation: " + deviation,ImageProcessor.imagesAreEquals(image1, image2, deviation));
|
70 | 76 | }
|
71 | 77 |
|
| 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 | + |
72 | 98 |
|
73 | 99 | }
|
0 commit comments