|
@@ -8,40 +8,59 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
|
8
|
8
|
|
9
|
9
|
public class NavigationControllerTest extends BaseTest {
|
10
|
10
|
|
|
11
|
+ private NavigationController uut;
|
|
12
|
+ private ViewController child1;
|
|
13
|
+ private ViewController child2;
|
|
14
|
+ private ViewController child3;
|
|
15
|
+
|
|
16
|
+ @Override
|
|
17
|
+ public void beforeEach() {
|
|
18
|
+ super.beforeEach();
|
|
19
|
+ uut = new NavigationController();
|
|
20
|
+ child1 = new ViewController();
|
|
21
|
+ child2 = new ViewController();
|
|
22
|
+ child3 = new ViewController();
|
|
23
|
+ }
|
|
24
|
+
|
11
|
25
|
@Test
|
12
|
26
|
public void isAViewController() throws Exception {
|
13
|
|
- assertThat(new NavigationController()).isInstanceOf(ViewController.class);
|
|
27
|
+ assertThat(uut).isInstanceOf(ViewController.class);
|
14
|
28
|
}
|
15
|
29
|
|
16
|
30
|
@Test
|
17
|
31
|
public void holdsAStackOfViewControllers() throws Exception {
|
18
|
|
- assertThat(new NavigationController().getChildControllers()).isEmpty();
|
19
|
|
- ViewController c1 = new ViewController();
|
20
|
|
- ViewController c2 = new ViewController();
|
21
|
|
- ViewController c3 = new ViewController();
|
22
|
|
- assertThat(new NavigationController(c1, c2, c3).getChildControllers()).containsExactly(c3, c2, c1);
|
|
32
|
+ assertThat(uut.getChildControllers()).isEmpty();
|
|
33
|
+ assertThat(new NavigationController(child1, child2, child3).getChildControllers()).containsExactly(child3, child2, child1);
|
|
34
|
+ assertThat(new NavigationController(child1, child2, child3).getChildControllers().peek()).isEqualTo(child3);
|
23
|
35
|
}
|
24
|
36
|
|
25
|
37
|
@Test
|
26
|
38
|
public void push() throws Exception {
|
27
|
|
- NavigationController uut = new NavigationController();
|
28
|
|
- ViewController c1 = new ViewController();
|
29
|
39
|
assertThat(uut.getChildControllers()).isEmpty();
|
30
|
|
- uut.push(c1);
|
31
|
|
- assertThat(uut.getChildControllers()).containsExactly(c1);
|
|
40
|
+ uut.push(child1);
|
|
41
|
+ assertThat(uut.getChildControllers()).containsExactly(child1);
|
32
|
42
|
}
|
33
|
43
|
|
34
|
44
|
@Test
|
35
|
45
|
public void pop() throws Exception {
|
36
|
|
- NavigationController uut = new NavigationController();
|
37
|
|
- ViewController c1 = new ViewController();
|
38
|
|
- ViewController c2 = new ViewController();
|
39
|
|
- uut.push(c1);
|
40
|
|
- uut.push(c2);
|
41
|
|
- assertThat(uut.getChildControllers()).containsExactly(c2, c1);
|
|
46
|
+ uut.push(child1);
|
|
47
|
+ uut.push(child2);
|
|
48
|
+ assertThat(uut.getChildControllers()).containsExactly(child2, child1);
|
42
|
49
|
uut.pop();
|
43
|
|
- assertThat(uut.getChildControllers()).containsExactly(c1);
|
|
50
|
+ assertThat(uut.getChildControllers()).containsExactly(child1);
|
44
|
51
|
uut.pop();
|
45
|
52
|
assertThat(uut.getChildControllers()).isEmpty();
|
46
|
53
|
}
|
|
54
|
+
|
|
55
|
+ @Test
|
|
56
|
+ public void stackOperations() throws Exception {
|
|
57
|
+ assertThat(uut.peek()).isNull();
|
|
58
|
+ assertThat(uut.size()).isZero();
|
|
59
|
+ assertThat(uut.isEmpty()).isTrue();
|
|
60
|
+ uut.push(child1);
|
|
61
|
+ assertThat(uut.peek()).isEqualTo(child1);
|
|
62
|
+ assertThat(uut.size()).isEqualTo(1);
|
|
63
|
+ assertThat(uut.isEmpty()).isFalse();
|
|
64
|
+ }
|
|
65
|
+
|
47
|
66
|
}
|