@@ -35,7 +35,6 @@ public class ResponsiveUIValidator implements Validator {
3535 private static final int MIN_OFFSET = -10000 ;
3636 private static boolean withReport = false ;
3737 private static long startTime ;
38- private static JSONObject jsonResults ;
3938 private static String scenarioName = "Default" ;
4039 private WebDriver driver ;
4140 private String rootElementReadableName = "Root Element" ;
@@ -410,7 +409,7 @@ public ResponsiveUIValidator drawMap() {
410409
411410 @ Override
412411 public boolean validate () {
413- jsonResults = new JSONObject ();
412+ JSONObject jsonResults = new JSONObject ();
414413 jsonResults .put (ERROR_KEY , false );
415414
416415 if (rootElement != null ) {
@@ -571,34 +570,7 @@ private void validateGridAlignment(int columns, int rows) {
571570 }
572571 }
573572 }
574- // else {
575- // if (map.size() == rootElements.size()) {
576- // putJsonDetailsWithoutElement("Elements are not aligned in a grid.");
577- // }
578- // }
579- }
580-
581- // List<WebElement> row = new ArrayList<>();
582- // for (int i = 0; i < rootElements.size(); i++) {
583- // while (columns % i != 0) {
584- // row.add(rootElements.get(i));
585- // if (columns % i == 0) {
586- // row.add(rootElements.get(i));
587- // if (!PageValidator.elementsAreAlignedHorizontally(row)) {
588- // putJsonDetailsWithElement("Elements are not aligned properly in grid", rootElements.get(i));
589- // break;
590- // }
591- // if (i + 1 <= rootElements.size()) {
592- // row.add(rootElements.get(i + 1));
593- // if (!PageValidator.elementsAreAlignedHorizontally(row)) {
594- // putJsonDetailsWithElement("Elements are not aligned properly in grid", rootElements.get(i));
595- // break;
596- // }
597- // }
598- // row.clear();
599- // }
600- // }
601- // }
573+ }
602574 }
603575
604576 private void validateRightOffsetForElements (WebElement element , String readableName ) {
@@ -732,7 +704,7 @@ private void validateSameSize(WebElement element, String readableName) {
732704 }
733705
734706 private void validateSameSize (List <WebElement > elements ) {
735- for (int i = 0 ; i < elements .size () - 1 ; i ++){
707+ for (int i = 0 ; i < elements .size () - 1 ; i ++) {
736708 int h1 = elements .get (i ).getSize ().getHeight ();
737709 int w1 = elements .get (i ).getSize ().getWidth ();
738710 int h2 = elements .get (i + 1 ).getSize ().getHeight ();
@@ -753,8 +725,8 @@ private void validateInsideOfContainer(WebElement element, String readableContai
753725 if (xRoot < xContainer || yRoot < yContainer || (xRoot + widthRoot ) > (xContainer + widthContainer ) || (yRoot + heightRoot ) > (yContainer + heightContainer )) {
754726 putJsonDetailsWithElement (String .format ("Element '%s' is not inside of '%s'" , rootElementReadableName , readableContainerName ), element );
755727 }
756- }else {
757- for (WebElement el : rootElements ){
728+ } else {
729+ for (WebElement el : rootElements ) {
758730 float xRoot = el .getLocation ().x ;
759731 float yRoot = el .getLocation ().y ;
760732 float widthRoot = el .getSize ().width ;
@@ -902,35 +874,35 @@ private void drawRoot(Color color) {
902874 g .drawRect (xRoot , yRoot , widthRoot , heightRoot );
903875 }
904876
905- Stroke dashed = new BasicStroke (2 , BasicStroke .CAP_BUTT , BasicStroke .JOIN_BEVEL , 0 , new float []{9 }, 0 );
877+ Stroke dashed = new BasicStroke (1 , BasicStroke .CAP_BUTT , BasicStroke .JOIN_BEVEL , 0 , new float []{9 }, 0 );
906878 g .setStroke (dashed );
907879 g .setColor (Color .ORANGE );
908880 if (drawLeftOffsetLine ) {
909881 if (SystemHelper .isRetinaDisplay (g ) && isChrome ()) {
910- g .drawLine (2 * xRoot , 0 , 2 * xRoot , 2 * pageHeight );
882+ g .drawLine (2 * xRoot , 0 , 2 * xRoot , 2 * img . getHeight () );
911883 } else {
912- g .drawLine (xRoot , 0 , xRoot , pageHeight );
884+ g .drawLine (xRoot , 0 , xRoot , img . getHeight () );
913885 }
914886 }
915887 if (drawRightOffsetLine ) {
916888 if (SystemHelper .isRetinaDisplay (g ) && isChrome ()) {
917- g .drawLine (2 * (xRoot + widthRoot ), 0 , 2 * (xRoot + widthRoot ), 2 * pageHeight );
889+ g .drawLine (2 * (xRoot + widthRoot ), 0 , 2 * (xRoot + widthRoot ), 2 * img . getHeight () );
918890 } else {
919- g .drawLine (xRoot + widthRoot , 0 , xRoot + widthRoot , pageHeight );
891+ g .drawLine (xRoot + widthRoot , 0 , xRoot + widthRoot , img . getHeight () );
920892 }
921893 }
922894 if (drawTopOffsetLine ) {
923895 if (SystemHelper .isRetinaDisplay (g ) && isChrome ()) {
924- g .drawLine (0 , 2 * yRoot , 2 * pageWidth , 2 * yRoot );
896+ g .drawLine (0 , 2 * yRoot , 2 * img . getWidth () , 2 * yRoot );
925897 } else {
926- g .drawLine (0 , yRoot , pageWidth , yRoot );
898+ g .drawLine (0 , yRoot , img . getWidth () , yRoot );
927899 }
928900 }
929901 if (drawBottomOffsetLine ) {
930902 if (SystemHelper .isRetinaDisplay (g ) && isChrome ()) {
931- g .drawLine (0 , 2 * (yRoot + heightRoot ), 2 * pageWidth , 2 * (yRoot + heightRoot ));
903+ g .drawLine (0 , 2 * (yRoot + heightRoot ), 2 * img . getWidth () , 2 * (yRoot + heightRoot ));
932904 } else {
933- g .drawLine (0 , yRoot + heightRoot , pageWidth , yRoot + heightRoot );
905+ g .drawLine (0 , yRoot + heightRoot , img . getWidth () , yRoot + heightRoot );
934906 }
935907 }
936908 }
0 commit comments