@@ -40,14 +40,20 @@ protected ResponsiveUIValidatorBase(UISnapshot snapshot) {
4040 tolerance = scalar (0 );
4141 }
4242
43+
44+ private DrawableScreenshot getDrawableScreenshot () {
45+ if (drawableScreenshot == null ) {
46+ File screenshotName = snapshot .takeScreenshot ();
47+ Vector extend = driver .getExtend (screenshotName );
48+ this .drawableScreenshot = new DrawableScreenshot (extend , getTransform (), getDrawingConfiguration (), getNameOfToBeValidated (), screenshotName );
49+ }
50+ return drawableScreenshot ;
51+ }
52+
4353 protected void doSnapshot () {
44- File screenshotName = snapshot .takeScreenshot ();
45- Vector extend = driver .getExtend (screenshotName );
46- this .drawableScreenshot = new DrawableScreenshot (extend , getTransform (), getDrawingConfiguration (), getNameOfToBeValidated (), screenshotName );
4754 if (isWithReport ()) {
4855 drawRootElement ();
4956 }
50-
5157 }
5258
5359 public Errors getErrors () {
@@ -139,17 +145,17 @@ private void compileValidationReport() {
139145 int width = (int ) (float ) numE .get (WIDTH );
140146 int height = (int ) (float ) numE .get (HEIGHT );
141147
142- drawableScreenshot .drawRectangle (x , y , width , height );
148+ getDrawableScreenshot () .drawRectangle (x , y , width , height );
143149 }
144150 }
145151 }
146152
147153 if (isWithReport ()) {
148- drawableScreenshot .saveDrawing ();
154+ getDrawableScreenshot () .saveDrawing ();
149155 }
150156
151157 if (isWithReport ()) {
152- writeResults (drawableScreenshot );
158+ writeResults (getDrawableScreenshot () );
153159 }
154160 }
155161
@@ -260,17 +266,17 @@ public DrawingConfiguration getDrawingConfiguration() {
260266
261267 protected void drawHorizontalLine (Vector onLine ) {
262268 if (isWithReport ()) {
263- drawableScreenshot .drawHorizontalLine (onLine .getY ());
269+ getDrawableScreenshot () .drawHorizontalLine (onLine .getY ());
264270 }
265271 }
266272
267273 protected void drawVerticalLine (Vector onLine ) {
268274 if (isWithReport ()) {
269- drawableScreenshot .drawVerticalLine (onLine .getX ());
275+ getDrawableScreenshot () .drawVerticalLine (onLine .getX ());
270276 }
271277 }
272278
273279 protected void drawElement (UIElement element ) {
274- drawableScreenshot .drawRootElement (element );
280+ getDrawableScreenshot () .drawRootElement (element );
275281 }
276282}
0 commit comments