Skip to content

Commit 0fabb9d

Browse files
committed
make tolerance configurable on th ResponsiveUIValidator
1 parent cae1e26 commit 0fabb9d

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected ResponsiveUIValidatorBase(UISnapshot snapshot) {
3838
Dimension dimension = this.driver.retrievePageSize();
3939
this.page = UIElement.asElement(new net.itarray.automotion.internal.geometry.Rectangle(0, 0, dimension.getWidth(), dimension.getHeight()), "page");
4040
this.startTime = System.currentTimeMillis();
41-
tolerance = scalar(0);
41+
tolerance = snapshot.getResponsiveUIValidator().getTolerance();
4242
}
4343

4444

src/main/java/net/itarray/automotion/validation/ResponsiveUIValidator.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.itarray.automotion.internal.HtmlReportBuilder;
66
import net.itarray.automotion.internal.ResolutionImpl;
77
import net.itarray.automotion.internal.ZoomUnknown;
8+
import net.itarray.automotion.internal.geometry.Scalar;
89
import net.itarray.automotion.validation.properties.Resolution;
910
import net.itarray.automotion.validation.properties.Zoom;
1011
import org.openqa.selenium.WebDriver;
@@ -13,6 +14,8 @@
1314
import java.util.ArrayList;
1415
import java.util.List;
1516

17+
import static net.itarray.automotion.internal.geometry.Scalar.scalar;
18+
1619
public class ResponsiveUIValidator {
1720

1821
protected final DriverFacade driver;
@@ -25,6 +28,7 @@ public class ResponsiveUIValidator {
2528
private double mobileTopBarOffset = 20;
2629
private final DrawingConfiguration drawingConfiguration = new DrawingConfiguration();
2730
private double scaleFactor = 1;
31+
private Scalar tolerance = scalar(0);
2832

2933
public ResponsiveUIValidator(WebDriver driver) {
3034
this(new DriverFacade(driver));
@@ -205,6 +209,21 @@ public void setLinesColor(Color color) {
205209
drawingConfiguration.setLinesColor(color);
206210
}
207211

212+
/**
213+
* Set the tolerance (in pixels) to be used in all verifications.
214+
*
215+
* @param tolerance the tolerance (in pixels) to be used in all verifications
216+
* @return
217+
*/
218+
public ResponsiveUIValidator withTolerance(int tolerance) {
219+
this.tolerance = scalar(tolerance);
220+
return this;
221+
}
222+
223+
public Scalar getTolerance() {
224+
return tolerance;
225+
}
226+
208227
public DrawingConfiguration getDrawingConfiguration() {
209228
return drawingConfiguration;
210229
}

src/main/java/net/itarray/automotion/validation/UISnapshot.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,4 @@ public File takeScreenshot() {
6767
}
6868
return screenshotName;
6969
}
70-
71-
7270
}

0 commit comments

Comments
 (0)