@@ -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 ()));
0 commit comments