Skip to content

Commit f47b3df

Browse files
authored
Merge pull request #85 from ITArray/SynchronousReports
tolerance tests and fix
2 parents 639218c + 53a3e6b commit f47b3df

File tree

6 files changed

+210
-73
lines changed

6 files changed

+210
-73
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private void validateElementsAreNotOverlapped(List<UIElement> elements) {
281281
UIElement first = elements.get(firstIndex);
282282
for (int secondIndex = firstIndex+1; secondIndex < elements.size(); secondIndex++) {
283283
UIElement second = elements.get(secondIndex);
284-
if (first.overlaps(second, context)) {
284+
if (!first.notOverlaps(second, context)) {
285285
context.add("Elements are overlapped");
286286
context.draw(first);
287287
break;

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ public boolean overlaps(UIElement other, Context context) {
172172
Condition.lessThan(getBottom()).isSatisfiedOn(other.getTop(), context, DOWN);
173173
}
174174

175+
public boolean notOverlaps(UIElement other, Context context) {
176+
return Condition.greaterOrEqualTo(other.getRight()).isSatisfiedOn(getLeft(), context, RIGHT) ||
177+
Condition.greaterOrEqualTo(getRight()).isSatisfiedOn(other.getLeft(), context, RIGHT) ||
178+
Condition.greaterOrEqualTo(other.getBottom()).isSatisfiedOn(getTop(), context, DOWN) ||
179+
Condition.greaterOrEqualTo(getBottom()).isSatisfiedOn(other.getTop(), context, DOWN);
180+
}
181+
175182
private Scalar getOffset(Direction direction, UIElement page) {
176183
return direction.signedDistance(getEnd(direction), page.getEnd(direction));
177184
}
@@ -347,7 +354,7 @@ public void validateOverlappingWithElement(UIElement element, Context context) {
347354
}
348355

349356
public void validateNotOverlappingWithElement(UIElement element, Context context) {
350-
if (overlaps(element, context)) {
357+
if (!notOverlaps(element, context)) {
351358
context.add(String.format("Element %s is overlapped with element %s but should not",
352359
getQuotedName(),
353360
element.getQuotedName()));

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ protected ResponsiveUIValidator(net.itarray.automotion.validation.ResponsiveUIVa
3232
responsiveUIValidator.dontDrawMap();
3333
}
3434

35+
public ResponsiveUIValidator withTolerance(int tolerance) {
36+
responsiveUIValidator.withTolerance(tolerance);
37+
return this;
38+
}
39+
3540
public boolean isWithReport() {
3641
return responsiveUIValidator.isWithReport();
3742
}

src/test/java/rectangles/IntersectionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void shouldNotOverlap() {
5959

6060
@Test
6161
public void areNotOverlapped() {
62-
assertThat(areNotOverlappedWithEachOther(Arrays.asList(root, other)))
62+
assertThat(doNotOverlap(Arrays.asList(root, other)))
6363
.withFailMessage(failMessage(intersectionExpectation()))
6464
.isEqualTo(!intersects);
6565
}

0 commit comments

Comments
 (0)