|
1 | 1 | package rectangles; |
2 | 2 |
|
3 | | -import com.google.common.collect.Lists; |
4 | 3 | import org.assertj.core.api.AbstractBooleanAssert; |
5 | 4 | import org.junit.Before; |
6 | 5 | import org.junit.Test; |
7 | 6 | import org.openqa.selenium.WebElement; |
8 | 7 |
|
9 | 8 | import static java.util.Arrays.asList; |
10 | 9 | import static org.assertj.core.api.Assertions.assertThat; |
11 | | -import static rectangles.TestAssumptions.doNotOverlap; |
12 | | -import static rectangles.TestAssumptions.isNotOverlapping; |
| 10 | +import static rectangles.TestAssumptions.*; |
13 | 11 |
|
14 | 12 | public class ToleranceOnNegativeAssumptionsTest { |
15 | 13 |
|
@@ -44,10 +42,31 @@ public void isNotOverlappingWithTolerance() { |
44 | 42 | assertThatNotOverlappingWithTolerance(x, y-height+2).isFalse(); |
45 | 43 | } |
46 | 44 |
|
| 45 | + @Test |
| 46 | + public void hasDifferentSizeAsWithTolerance() { |
| 47 | + assertThatHasDifferentSizeWithTolerance(-2, 0).isTrue(); |
| 48 | + assertThatHasDifferentSizeWithTolerance(-1, 0).isFalse(); |
| 49 | + assertThatHasDifferentSizeWithTolerance( 0, 0).isFalse(); |
| 50 | + assertThatHasDifferentSizeWithTolerance(+1, 0).isFalse(); |
| 51 | + assertThatHasDifferentSizeWithTolerance(0, +2).isTrue(); |
| 52 | + assertThatHasDifferentSizeWithTolerance(0, -2).isTrue(); |
| 53 | + assertThatHasDifferentSizeWithTolerance(0, -1).isFalse(); |
| 54 | + assertThatHasDifferentSizeWithTolerance(0, +1).isFalse(); |
| 55 | + assertThatHasDifferentSizeWithTolerance(0, +2).isTrue(); |
| 56 | + } |
| 57 | + |
| 58 | + public AbstractBooleanAssert<?> assertThatHasDifferentSizeWithTolerance(int deltaWidth, int deltaHeight) { |
| 59 | + WebElement element = DummyWebElement.createElement(x, y, x + width + deltaWidth, y + height + deltaHeight); |
| 60 | + return assertThat(hasDifferentSizeAs(root, element, 1) && |
| 61 | + hasDifferentSizeAs(root, asList(element), 1) && |
| 62 | + haveDifferentSizes(asList(root, element), 1)); |
| 63 | + } |
| 64 | + |
47 | 65 | private AbstractBooleanAssert<?> assertThatNotOverlappingWithTolerance(int x, int y) { |
48 | | - return assertThat(isNotOverlapping(root, createElement(x, y), 1) && |
49 | | - doNotOverlap(asList(root, createElement(x, y)), 1) && |
50 | | - isNotOverlapping(root, asList(createElement(x,y)), 1)); |
| 66 | + WebElement element = createElement(x, y); |
| 67 | + return assertThat(isNotOverlapping(root, element, 1) && |
| 68 | + doNotOverlap(asList(root, element), 1) && |
| 69 | + isNotOverlapping(root, asList(element), 1)); |
51 | 70 | } |
52 | 71 |
|
53 | 72 |
|
|
0 commit comments