-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathAlignmentTest.java
More file actions
145 lines (108 loc) · 5.17 KB
/
Copy pathAlignmentTest.java
File metadata and controls
145 lines (108 loc) · 5.17 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
package rectangles;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static rectangles.DummyWebElement.createElement;
import static rectangles.DummyWebElement.createRootElement;
import static rectangles.RectangleFixture.down;
import static rectangles.RectangleFixture.up;
import static rectangles.TestAssumptions.*;
public class AlignmentTest {
private int originX;
private int originY;
private int cornerX;
private int cornerY;
private WebElement root;
@Before
public void setUp() {
originX = RectangleFixture.originX;
originY = RectangleFixture.originY;
cornerX = RectangleFixture.cornerX;
cornerY = RectangleFixture.cornerY;
root = createRootElement();
}
@Test
public void isLeftAlignedWithElementsWithEqualOriginX() {
WebElement other = createElement(originX, up(originY), up(cornerX), down(cornerY));
assertThat(isLeftAlignedWith(root, other)).isTrue();
assertThat(isLeftAlignedWith(root, asList(other))).isTrue();
assertThat(areLeftAligned(asList(root, other))).isTrue();
}
@Test
public void isNotLeftAlignedWithElementsWithSmallerOriginX() {
WebElement other = createElement(down(originX), up(originY), down(cornerX), down(cornerY));
assertThat(isLeftAlignedWith(root, other)).isFalse();
assertThat(areLeftAligned(asList(root, other))).isFalse();
}
@Test
public void isNotLeftAlignedWithElementsWithGreaterOriginX() {
WebElement other = createElement(up(originX), down(originY), down(cornerX), up(cornerY));
assertThat(isLeftAlignedWith(root, other)).isFalse();
assertThat(areLeftAligned(asList(root, other))).isFalse();
}
@Test
public void isTopAlignedWithElementsWithEqualOriginY() {
WebElement other = createElement(up(originX), originY, up(cornerX), down(cornerY));
assertThat(isTopAlignedWith(root, other)).isTrue();
assertThat(isTopAlignedWith(root, asList(other))).isTrue();
assertThat(areTopAligned(asList(root, other))).isTrue();
}
@Test
public void isNotTopAlignedWithElementsWithSmallerOriginY() {
WebElement other = createElement(up(originX), down(originY), down(cornerX), down(cornerY));
assertThat(isTopAlignedWith(root, other)).isFalse();
assertThat(isTopAlignedWith(root, asList(other))).isFalse();
assertThat(areTopAligned(asList(root, other))).isFalse();
}
@Test
public void isNotTopAlignedWithElementsWithGreaterOriginY() {
WebElement other = createElement(down(originX), up(originY), down(cornerX), up(cornerY));
assertThat(isTopAlignedWith(root, other)).isFalse();
assertThat(isTopAlignedWith(root, asList(other))).isFalse();
assertThat(areTopAligned(asList(root, other))).isFalse();
}
@Test
public void isRightAlignedWithElementsWithEqualCornerX() {
WebElement other = createElement(up(originX), up(originY), cornerX, down(cornerY));
assertThat(isRightAlignedWith(root, asList(other))).isTrue();
assertThat(isRightAlignedWith(root, other)).isTrue();
assertThat(areRightAligned(asList(root, other))).isTrue();
}
@Test
public void isNotRightAlignedWithElementsWithLesserCornerX() {
WebElement other = createElement(up(originX), up(originY), down(cornerX), down(cornerY));
assertThat(isRightAlignedWith(root, other)).isFalse();
assertThat(isRightAlignedWith(root, asList(other))).isFalse();
assertThat(areRightAligned(asList(root, other))).isFalse();
}
@Test
public void isNotRightAlignedWithElementsWithGreaterCornerX() {
WebElement other = createElement(up(originX), up(originY), up(cornerX), down(cornerY));
assertThat(isRightAlignedWith(root, other)).isFalse();
assertThat(isRightAlignedWith(root, asList(other))).isFalse();
assertThat(areRightAligned(asList(root, other))).isFalse();
}
@Test
public void isBottomAlignedWithElementsWithEqualCornerY() {
WebElement other = createElement(up(originX), up(originY), down(cornerX), cornerY);
assertThat(isBottomAlignedWith(root, other)).isTrue();
assertThat(isBottomAlignedWith(root, asList(other))).isTrue();
assertThat(areBottomAligned(asList(root, other))).isTrue();
}
@Test
public void isNotBottomAlignedWithElementsWithLesserCornerY() {
WebElement other = createElement(up(originX), up(originY), down(cornerX), down(cornerY));
assertThat(isBottomAlignedWith(root, other)).isFalse();
assertThat(isBottomAlignedWith(root, asList(other))).isFalse();
assertThat(areBottomAligned(asList(root, other))).isFalse();
}
@Test
public void isNotBottomAlignedWithElementsWithGreaterCornerY() {
WebElement other = createElement(up(originX), up(originY), down(cornerX), up(cornerY));
assertThat(isBottomAlignedWith(root, other)).isFalse();
assertThat(isBottomAlignedWith(root, asList(other))).isFalse();
assertThat(areBottomAligned(asList(root, other))).isFalse();
}
}