Skip to content

Commit 6a5edb2

Browse files
committed
[1.4.2-minor fixes] - common fixes
1 parent f4df5c9 commit 6a5edb2

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/main/java/util/validator/ResponsiveUIValidator.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -405,15 +405,15 @@ void validateBottomOffsetForElements(WebElement element, String readableName) {
405405

406406
void validateNotOverlappingWithElements(WebElement element, String readableName) {
407407
if (!element.equals(rootElement)) {
408-
if (elementsAreOverlapped(element)) {
408+
if (elementsAreOverlapped(rootElement, element)) {
409409
putJsonDetailsWithElement(String.format("Element '%s' is overlapped with element '%s' but should not", rootElementReadableName, readableName), element);
410410
}
411411
}
412412
}
413413

414414
void validateOverlappingWithElements(WebElement element, String readableName) {
415415
if (!element.equals(rootElement)) {
416-
if (!elementsAreOverlapped(element)) {
416+
if (!elementsAreOverlapped(rootElement, element)) {
417417
putJsonDetailsWithElement(String.format("Element '%s' is not overlapped with element '%s' but should be", rootElementReadableName, readableName), element);
418418
}
419419
}
@@ -840,7 +840,7 @@ private boolean elementsAreOverlappedOnBorder(WebElement rootElement, WebElement
840840
int sqRootElement = widthRoot * heightRoot;
841841
int sqElement = elSize.width * elSize.height;
842842

843-
int sqCommon = 0;
843+
int sqCommon;
844844
if (xRoot < elLoc.x && yRoot == elLoc.y) {
845845
sqCommon = (widthRoot + (elLoc.x - (xRoot + widthRoot) + elSize.width)) * (heightRoot);
846846
} else if (yRoot < elLoc.y && xRoot == elLoc.x) {
@@ -856,22 +856,6 @@ private boolean elementsAreOverlappedOnBorder(WebElement rootElement, WebElement
856856
return sqCommon < sqRootElement + sqElement;
857857
}
858858

859-
private boolean elementsAreOverlapped(WebElement elementOverlapWith) {
860-
Point elLoc = elementOverlapWith.getLocation();
861-
Dimension elSize = elementOverlapWith.getSize();
862-
return ((xRoot >= elLoc.x && yRoot > elLoc.y && xRoot < elLoc.x + elSize.width && yRoot < elLoc.y + elSize.height)
863-
|| (xRoot + widthRoot > elLoc.x && yRoot > elLoc.y && xRoot + widthRoot < elLoc.x + elSize.width && yRoot < elLoc.y + elSize.height)
864-
|| (xRoot > elLoc.x && yRoot + heightRoot > elLoc.y && xRoot < elLoc.x + elSize.width && yRoot + heightRoot < elLoc.y + elSize.height)
865-
|| (xRoot + widthRoot > elLoc.x && yRoot + heightRoot > elLoc.y && xRoot + widthRoot < elLoc.x + elSize.width && yRoot + heightRoot < elLoc.y + elSize.height))
866-
867-
|| ((elLoc.x > xRoot && elLoc.y > yRoot && elLoc.x + elSize.width < xRoot && elLoc.y + elSize.height < yRoot)
868-
|| (elLoc.x > xRoot + widthRoot && elLoc.y > yRoot && elLoc.x + elSize.width < xRoot + widthRoot && elLoc.y + elSize.height < yRoot)
869-
|| (elLoc.x > xRoot && elLoc.y > yRoot + heightRoot && elLoc.x + elSize.width < xRoot && elLoc.y + elSize.height < yRoot + heightRoot)
870-
|| (elLoc.x > xRoot + widthRoot && elLoc.y > yRoot + heightRoot && elLoc.x + elSize.width < xRoot + widthRoot && elLoc.y + elSize.height < yRoot + heightRoot))
871-
872-
|| elementsAreOverlappedOnBorder(rootElement, elementOverlapWith);
873-
}
874-
875859
private boolean elementsAreOverlapped(WebElement rootElement, WebElement elementOverlapWith) {
876860
Point elLoc = elementOverlapWith.getLocation();
877861
Dimension elSize = elementOverlapWith.getSize();

0 commit comments

Comments
 (0)