@@ -146,7 +146,7 @@ public boolean hasSameHeightAs(UIElement other, Context context) {
146146 }
147147
148148 public boolean hasSameSizeAs (UIElement other , Context context ) {
149- return hasEqualExtendAs (other , Rectangle . ORIGIN_CORNER , context );
149+ return hasEqualExtendAs (other , ORIGIN_CORNER , context );
150150 }
151151
152152 public Scalar getLeft () {
@@ -221,8 +221,12 @@ private static String getShortenedText(String text) {
221221 return text .substring (0 , maxLength -postfix .length ()) + postfix ;
222222 }
223223
224- public boolean contains (UIElement other ) {
225- return rectangle .contains (other .rectangle );
224+ public boolean contains (UIElement other , Context context ) {
225+ return
226+ Condition .lessOrEqualTo (other .getLeft ()).isSatisfiedOn (getLeft (), context , RIGHT ) &&
227+ Condition .lessOrEqualTo (getRight ()).isSatisfiedOn (other .getRight (), context , RIGHT ) &&
228+ Condition .lessOrEqualTo (other .getTop ()).isSatisfiedOn (getTop (), context , DOWN ) &&
229+ Condition .lessOrEqualTo (getBottom ()).isSatisfiedOn (other .getBottom (), context , DOWN );
226230 }
227231
228232 public void validateLeftAlignedWith (UIElement element , Context context , Errors errors ) {
@@ -454,16 +458,16 @@ public void validateHasCssValue(String cssProperty, String[] args, Errors errors
454458 }
455459 }
456460
457- public void validateInsideOfContainer (UIElement containerElement , Errors errors ) {
458- if (!containerElement .contains (this )) {
461+ public void validateInsideOfContainer (UIElement containerElement , Context context , Errors errors ) {
462+ if (!containerElement .contains (this , context )) {
459463 errors .add (String .format ("Element '%s' is not inside of '%s'" ,
460464 getName (),
461465 containerElement .getName ()));
462466 errors .draw (containerElement );
463467 }
464468 }
465469
466- public void validateInsideOfContainer (UIElement element , Errors errors , Scalar top , Scalar left , Scalar right , Scalar bottom ) {
470+ public void validateInsideOfContainer (UIElement element , Errors errors , Context context , Scalar top , Scalar left , Scalar right , Scalar bottom ) {
467471 Vector originPadding = new Vector (left , top );
468472 Vector cornerPadding = new Vector (right , bottom );
469473
@@ -475,7 +479,7 @@ public void validateInsideOfContainer(UIElement element, Errors errors, Scalar t
475479 Vector originOffset = getOrigin ().minus (element .getOrigin ());
476480 Vector cornerOffset = getCorner ().minus (element .getCorner ());
477481
478- if (!element .contains (paddedRoot )) {
482+ if (!element .contains (paddedRoot , context )) {
479483 errors .add (String .format ("Padding of element %s is incorrect. Expected padding: top[%s], right[%s], bottom[%s], left[%s]. Actual padding: top[%s], right[%s], bottom[%s], left[%s]" ,
480484 getQuotedName (),
481485 originPadding .getY (),
0 commit comments