-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathExtendTest.java
More file actions
180 lines (150 loc) · 7.68 KB
/
Copy pathExtendTest.java
File metadata and controls
180 lines (150 loc) · 7.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package rectangles;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static rectangles.DummyWebElement.createRootElement;
import static rectangles.RectangleFixture.*;
import static rectangles.TestAssumptions.*;
public class ExtendTest {
private WebElement root;
@Before
public void setUp() {
root = createRootElement();
}
@Test
public void hasSameWidthAsATranslatedElement() {
WebElement other = DummyWebElement.createElement(originX+10, originY+5, cornerX+10, cornerY+5);
assertThat(hasEqualWidthAs(root, other)).isTrue();
assertThat(hasEqualWidthAs(root, singletonList(other))).isTrue();
assertThat(haveEqualWidth(asList(root, other))).isTrue();
assertThat(haveDifferentWidths(asList(root, other))).isFalse();
}
@Test
public void hasSameWidthAsAVerticallyStretchedElement() {
WebElement other = DummyWebElement.createElement(originX, originY, cornerX, cornerY+100);
assertThat(hasEqualWidthAs(root, other)).isTrue();
assertThat(hasEqualWidthAs(root, singletonList(other))).isTrue();
assertThat(haveEqualWidth(asList(root, other))).isTrue();
assertThat(haveDifferentWidths(asList(root, other))).isFalse();
}
@Test
public void doesNotHaveSameWidthAsAHorizontallyStretchedElement() {
WebElement other = DummyWebElement.createElement(originX, originY, cornerX+100, cornerY);
assertThat(hasEqualWidthAs(root, other)).isFalse();
assertThat(hasEqualWidthAs(root, singletonList(other))).isFalse();
assertThat(haveEqualWidth(asList(root, other))).isFalse();
assertThat(haveDifferentWidths(asList(root, other))).isTrue();
assertThat(haveDifferentWidths(asList(root, other, root))).isFalse();
}
@Test
public void hasSameHeightAsATranslatedElement() {
WebElement other = DummyWebElement.createElement(originX+10, originY+5, cornerX+10, cornerY+5);
assertThat(hasEqualHeightAs(root, other)).isTrue();
assertThat(hasEqualHeightAs(root, singletonList(other))).isTrue();
assertThat(haveEqualHeight(asList(root, other))).isTrue();
assertThat(haveDifferentHeights(asList(root, other))).isFalse();
}
@Test
public void hasSameHeightAsAHorizontallyStretchedElement() {
WebElement other = DummyWebElement.createElement(originX, originY, cornerX+100, cornerY);
assertThat(hasEqualHeightAs(root, other)).isTrue();
assertThat(hasEqualHeightAs(root, singletonList(other))).isTrue();
assertThat(haveEqualHeight(asList(root, other))).isTrue();
assertThat(haveDifferentHeights(asList(root, other))).isFalse();
}
@Test
public void doesNotHaveSameHeightAsAVerticallyStretchedElement() {
WebElement other = DummyWebElement.createElement(originX, originY, cornerX, cornerY+100);
assertThat(hasEqualHeightAs(root, other)).isFalse();
assertThat(hasEqualHeightAs(root, singletonList(other))).isFalse();
assertThat(haveEqualHeight(asList(root, other))).isFalse();
assertThat(haveDifferentHeights(asList(root, other))).isTrue();
assertThat(haveDifferentHeights(asList(root, other, root))).isFalse();
}
@Test
public void hasSameSizeAsATranslatedElement() {
WebElement other = DummyWebElement.createElement(originX+10, originY+5, cornerX+10, cornerY+5);
assertThat(hasEqualSizeAs(root, other)).isTrue();
assertThat(hasEqualSizeAs(root, singletonList(other))).isTrue();
assertThat(haveEqualSize(asList(root, other))).isTrue();
assertThat(hasDifferentSizeAs(root, other)).isFalse();
assertThat(hasDifferentSizeAs(root, singletonList(other))).isFalse();
assertThat(haveDifferentSizes(asList(root, other))).isFalse();
}
@Test
public void hasSameSizeAsItSelf() {
WebElement other = root;
assertThat(hasEqualSizeAs(root, other)).isTrue();
assertThat(hasEqualSizeAs(root, singletonList(other))).isTrue();
assertThat(haveEqualSize(asList(root, other))).isTrue();
assertThat(hasDifferentSizeAs(root, other)).isFalse();
assertThat(hasDifferentSizeAs(root, singletonList(other))).isFalse();
assertThat(haveDifferentSizes(asList(root, other))).isFalse();
}
@Test
public void doesNotHaveSameSizeAsAHorinzotallyStretchedElement() {
WebElement other = DummyWebElement.createElement(originX, originY, cornerX, cornerY+100);
assertThat(hasEqualSizeAs(root, other)).isFalse();
assertThat(hasEqualSizeAs(root, singletonList(other))).isFalse();
assertThat(haveEqualSize(asList(root, other))).isFalse();
assertThat(hasDifferentSizeAs(root, other)).isTrue();
assertThat(hasDifferentSizeAs(root, singletonList(other))).isTrue();
assertThat(haveDifferentSizes(asList(root, other))).isTrue();
assertThat(haveDifferentSizes(asList(root, other, root))).isFalse();
}
@Test
public void doesNotHaveSameSizeAsAVerticallyStretchedElement() {
WebElement other = DummyWebElement.createElement(originX, originY, cornerX, cornerY+100);
assertThat(hasEqualSizeAs(root, other)).isFalse();
assertThat(hasEqualSizeAs(root, singletonList(other))).isFalse();
assertThat(haveEqualSize(asList(root, other))).isFalse();
assertThat(hasDifferentSizeAs(root, other)).isTrue();
assertThat(hasDifferentSizeAs(root, singletonList(other))).isTrue();
assertThat(haveDifferentSizes(asList(root, other))).isTrue();
}
@Test
public void hasHeightBetweenWorks() {
assertThat(hasHeightBetween(root, height-10-1, height-1)).isFalse();
assertThat(hasHeightBetween(root, height-10, height)).isTrue();
assertThat(hasHeightBetween(root, height-10+1, height+1)).isTrue();
assertThat(hasHeightBetween(root, height-1, height+10-1)).isTrue();
assertThat(hasHeightBetween(root, height, height+10)).isTrue();
assertThat(hasHeightBetween(root, height+1, height+10+1)).isFalse();
}
@Test
public void hasWidthBetweenWorks() {
assertThat(hasWidthBetween(root, width-10-1, width-1)).isFalse();
assertThat(hasWidthBetween(root, width-10, width)).isTrue();
assertThat(hasWidthBetween(root, width-10+1, width+1)).isTrue();
assertThat(hasWidthBetween(root, width-1, width+10-1)).isTrue();
assertThat(hasWidthBetween(root, width, width+10)).isTrue();
assertThat(hasWidthBetween(root, width+1, width+10+1)).isFalse();
}
@Test
public void hasWidthGreaterOrEqualToWork() {
assertThat(hasWidthGreaterOrEqualTo(root, width-1)).isTrue();
assertThat(hasWidthGreaterOrEqualTo(root, width)).isTrue();
assertThat(hasWidthGreaterOrEqualTo(root, width+1)).isFalse();
}
@Test
public void hasWidthLessOrEqualToWorks() {
assertThat(hasWidthLessOrEqualTo(root, width-1)).isFalse();
assertThat(hasWidthLessOrEqualTo(root, width)).isTrue();
assertThat(hasWidthLessOrEqualTo(root, width+1)).isTrue();
}
@Test
public void hasHeightGreaterOrEqualToWorks() {
assertThat(hasHeightGreaterOrEqualTo(root, height-1)).isTrue();
assertThat(hasHeightGreaterOrEqualTo(root, height)).isTrue();
assertThat(hasHeightGreaterOrEqualTo(root, height+1)).isFalse();
}
@Test
public void hasHeightLessOrEqualToWorks() {
assertThat(hasHeightLessOrEqualTo(root, height-1)).isFalse();
assertThat(hasHeightLessOrEqualTo(root, height)).isTrue();
assertThat(hasHeightLessOrEqualTo(root, height+1)).isTrue();
}
}