Skip to content

Commit 3eeca4a

Browse files
committed
[responsive-validator] - implemented HTML reporting. Adaptation for Retina display
1 parent f0b039f commit 3eeca4a

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/main/java/util/validator/ResponsiveValidator.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public class ResponsiveValidator implements Validator {
8787
private int topMaxMargin;
8888
private int bottomMinMargin;
8989
private int bottomMaxMargin;
90+
private boolean drawOffsetLine = false;
9091

9192
public ResponsiveValidator(WebDriver driver) {
9293
this.driver = driver;
@@ -185,24 +186,28 @@ public ResponsiveValidator notOverlapWith(WebElement element, String readableNam
185186
@Override
186187
public ResponsiveValidator sameOffsetLeftAs(WebElement element, String readableName) {
187188
offsetLeftElements.put(element, readableName);
189+
drawOffsetLine = true;
188190
return this;
189191
}
190192

191193
@Override
192194
public ResponsiveValidator sameOffsetRightAs(WebElement element, String readableName) {
193195
offsetRightElements.put(element, readableName);
196+
drawOffsetLine = true;
194197
return this;
195198
}
196199

197200
@Override
198201
public ResponsiveValidator sameOffsetTopAs(WebElement element, String readableName) {
199202
offsetTopElements.put(element, readableName);
203+
drawOffsetLine = true;
200204
return this;
201205
}
202206

203207
@Override
204208
public ResponsiveValidator sameOffsetBottomAs(WebElement element, String readableName) {
205209
offsetBottomElements.put(element, readableName);
210+
drawOffsetLine = true;
206211
return this;
207212
}
208213

@@ -664,18 +669,21 @@ private void drawRoot(Color color) {
664669
} else {
665670
g.drawRect(xRoot, yRoot, widthRoot, heightRoot);
666671
}
667-
g.setStroke(new BasicStroke(1));
668-
g.setColor(Color.ORANGE);
669-
if (SystemHelper.isRetinaDisplay(g) && isChrome()) {
670-
g.drawLine(0, 2 * yRoot, 2 * pageWidth, 2 * yRoot);
671-
g.drawLine(0, 2 * (yRoot + heightRoot), 2 * pageWidth, 2 * (yRoot + heightRoot));
672-
g.drawLine(2 * xRoot, 0, 2 * xRoot, 2 * pageHeight);
673-
g.drawLine(2 * (xRoot + widthRoot), 0, 2 * (xRoot + widthRoot), 2 * pageHeight);
674-
} else {
675-
g.drawLine(0, yRoot, pageWidth, yRoot);
676-
g.drawLine(0, yRoot + heightRoot, pageWidth, yRoot + heightRoot);
677-
g.drawLine(xRoot, 0, xRoot, pageHeight);
678-
g.drawLine(xRoot + widthRoot, 0, xRoot + widthRoot, pageHeight);
672+
673+
if (drawOffsetLine) {
674+
g.setStroke(new BasicStroke(1));
675+
g.setColor(Color.ORANGE);
676+
if (SystemHelper.isRetinaDisplay(g) && isChrome()) {
677+
g.drawLine(0, 2 * yRoot, 2 * pageWidth, 2 * yRoot);
678+
g.drawLine(0, 2 * (yRoot + heightRoot), 2 * pageWidth, 2 * (yRoot + heightRoot));
679+
g.drawLine(2 * xRoot, 0, 2 * xRoot, 2 * pageHeight);
680+
g.drawLine(2 * (xRoot + widthRoot), 0, 2 * (xRoot + widthRoot), 2 * pageHeight);
681+
} else {
682+
g.drawLine(0, yRoot, pageWidth, yRoot);
683+
g.drawLine(0, yRoot + heightRoot, pageWidth, yRoot + heightRoot);
684+
g.drawLine(xRoot, 0, xRoot, pageHeight);
685+
g.drawLine(xRoot + widthRoot, 0, xRoot + widthRoot, pageHeight);
686+
}
679687
}
680688
}
681689

0 commit comments

Comments
 (0)