Skip to content

Commit 3986f63

Browse files
committed
[improve-html-report] - fixes for unit tests
1 parent 41d548c commit 3986f63

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.itarray</groupId>
88
<artifactId>automotion</artifactId>
9-
<version>2.1.0-beta2</version>
9+
<version>2.1.0-rc1</version>
1010
<name>Automotion</name>
1111
<description>Library for smart visual automation testing</description>
1212
<url>https://automotion.itarray.net</url>
@@ -213,7 +213,7 @@
213213
<dependency>
214214
<groupId>javax.mail</groupId>
215215
<artifactId>javax.mail-api</artifactId>
216-
<version>1.6.0</version>
216+
<version>1.6.1</version>
217217
</dependency>
218218
<dependency>
219219
<groupId>com.optimaize.languagedetector</groupId>
@@ -242,12 +242,12 @@
242242
<dependency>
243243
<groupId>com.webfirmframework</groupId>
244244
<artifactId>wffweb</artifactId>
245-
<version>2.1.15</version>
245+
<version>3.0.0</version>
246246
</dependency>
247247
<dependency>
248248
<groupId>org.assertj</groupId>
249249
<artifactId>assertj-core</artifactId>
250-
<version>3.9.0</version>
250+
<version>3.9.1</version>
251251
<scope>test</scope>
252252
</dependency>
253253
<dependency>

src/main/java/net/itarray/automotion/internal/DrawableScreenshot.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,24 @@
1515
public class DrawableScreenshot {
1616

1717
private final DrawingConfiguration drawingConfiguration;
18+
private final Vector extend;
1819
private TransformedGraphics graphics;
1920
private File screenshotName;
2021
private File drawingsOutput;
2122
private BufferedImage drawings;
22-
private final Vector extend;
2323

2424
public DrawableScreenshot(Vector extend, SimpleTransform transform, DrawingConfiguration drawingConfiguration, String rootElementReadableName, File screenshotName) {
2525
this.drawingConfiguration = drawingConfiguration;
2626
this.screenshotName = screenshotName;
27+
File imgFolder = new File(TARGET_AUTOMOTION_IMG);
28+
if (!imgFolder.exists()) {
29+
imgFolder.mkdir();
30+
}
2731
drawingsOutput = new File(TARGET_AUTOMOTION_IMG + rootElementReadableName.replaceAll("[\\W]|_", "") + "-draw-" + System.currentTimeMillis() + Helper.getGeneratedStringWithLength(7) + ".png");
2832

2933
try {
3034
this.extend = extend;
31-
drawings = new BufferedImage(extend.getX().intValue(), extend.getY().intValue(),
32-
BufferedImage.TYPE_INT_ARGB);
35+
drawings = new BufferedImage(extend.getX().intValue(), extend.getY().intValue(), BufferedImage.TYPE_INT_ARGB);
3336

3437
Graphics2D g2d = drawings.createGraphics();
3538

@@ -66,10 +69,14 @@ public void drawHorizontalLine(Scalar y) {
6669

6770
public void saveDrawing() {
6871
try {
69-
ImageIO.write(drawings, "png", drawingsOutput);
70-
} catch (IOException | NullPointerException e) {}
72+
if (drawings != null && drawingsOutput != null) {
73+
ImageIO.write(drawings, "png", drawingsOutput);
74+
}
75+
} catch (NullPointerException | IOException ignored) {}
7176

72-
drawings.getGraphics().dispose();
77+
if (drawings != null) {
78+
drawings.getGraphics().dispose();
79+
}
7380
}
7481

7582
public void drawRoot(UIElement rootElement) {

0 commit comments

Comments
 (0)