|
@@ -36,26 +36,28 @@ public class StackControllerTest extends BaseTest {
|
36
|
36
|
|
37
|
37
|
@Test
|
38
|
38
|
public void holdsAStackOfViewControllers() throws Exception {
|
39
|
|
- assertThat(uut.getChildControllers()).isEmpty();
|
40
|
|
- uut.setChildControllers(child1, child2, child3);
|
41
|
|
- assertThat(uut.getChildControllers()).containsOnly(child3, child2, child1);
|
|
39
|
+ assertThat(uut.getStack()).isEmpty();
|
|
40
|
+ uut.push(child1);
|
|
41
|
+ uut.push(child2);
|
|
42
|
+ uut.push(child3);
|
|
43
|
+ assertThat(uut.getStack()).containsOnly(child3, child2, child1);
|
42
|
44
|
assertThat(uut.peek()).isEqualTo(child3);
|
43
|
45
|
}
|
44
|
46
|
|
45
|
47
|
@Test
|
46
|
48
|
public void push() throws Exception {
|
47
|
|
- assertThat(uut.getChildControllers()).isEmpty();
|
|
49
|
+ assertThat(uut.getStack()).isEmpty();
|
48
|
50
|
uut.push(child1);
|
49
|
|
- assertThat(uut.getChildControllers()).containsOnly(child1);
|
|
51
|
+ assertThat(uut.getStack()).containsOnly(child1);
|
50
|
52
|
}
|
51
|
53
|
|
52
|
54
|
@Test
|
53
|
55
|
public void pop() throws Exception {
|
54
|
56
|
uut.push(child1);
|
55
|
57
|
uut.push(child2);
|
56
|
|
- assertThat(uut.getChildControllers()).containsOnly(child2, child1);
|
|
58
|
+ assertThat(uut.getStack()).containsOnly(child2, child1);
|
57
|
59
|
uut.pop();
|
58
|
|
- assertThat(uut.getChildControllers()).containsOnly(child1);
|
|
60
|
+ assertThat(uut.getStack()).containsOnly(child1);
|
59
|
61
|
}
|
60
|
62
|
|
61
|
63
|
@Test
|
|
@@ -71,13 +73,13 @@ public class StackControllerTest extends BaseTest {
|
71
|
73
|
|
72
|
74
|
@Test
|
73
|
75
|
public void pushAssignsRefToSelfOnPushedController() throws Exception {
|
74
|
|
- assertThat(child1.getParentStackController()).isNull();
|
|
76
|
+ assertThat(child1.getStackController()).isNull();
|
75
|
77
|
uut.push(child1);
|
76
|
|
- assertThat(child1.getParentStackController()).isEqualTo(uut);
|
|
78
|
+ assertThat(child1.getStackController()).isEqualTo(uut);
|
77
|
79
|
|
78
|
80
|
StackController anotherNavController = new StackController(activity);
|
79
|
|
- anotherNavController.setChildControllers(child2);
|
80
|
|
- assertThat(child2.getParentStackController()).isEqualTo(anotherNavController);
|
|
81
|
+ anotherNavController.push(child2);
|
|
82
|
+ assertThat(child2.getStackController()).isEqualTo(anotherNavController);
|
81
|
83
|
}
|
82
|
84
|
|
83
|
85
|
@Test
|
|
@@ -98,24 +100,24 @@ public class StackControllerTest extends BaseTest {
|
98
|
100
|
|
99
|
101
|
@Test
|
100
|
102
|
public void popDoesNothingWhenZeroOrOneChild() throws Exception {
|
101
|
|
- assertThat(uut.getChildControllers()).isEmpty();
|
|
103
|
+ assertThat(uut.getStack()).isEmpty();
|
102
|
104
|
uut.pop();
|
103
|
|
- assertThat(uut.getChildControllers()).isEmpty();
|
|
105
|
+ assertThat(uut.getStack()).isEmpty();
|
104
|
106
|
|
105
|
107
|
uut.push(child1);
|
106
|
108
|
uut.pop();
|
107
|
|
- assertThat(uut.getChildControllers()).containsOnly(child1);
|
|
109
|
+ assertThat(uut.getStack()).containsOnly(child1);
|
108
|
110
|
}
|
109
|
111
|
|
110
|
112
|
@Test
|
111
|
113
|
public void canPopWhenSizeIsMoreThanOne() throws Exception {
|
112
|
|
- assertThat(uut.getChildControllers()).isEmpty();
|
|
114
|
+ assertThat(uut.getStack()).isEmpty();
|
113
|
115
|
assertThat(uut.canPop()).isFalse();
|
114
|
116
|
uut.push(child1);
|
115
|
|
- assertThat(uut.getChildControllers()).containsOnly(child1);
|
|
117
|
+ assertThat(uut.getStack()).containsOnly(child1);
|
116
|
118
|
assertThat(uut.canPop()).isFalse();
|
117
|
119
|
uut.push(child2);
|
118
|
|
- assertThat(uut.getChildControllers()).containsOnly(child1, child2);
|
|
120
|
+ assertThat(uut.getStack()).containsOnly(child1, child2);
|
119
|
121
|
assertThat(uut.canPop()).isTrue();
|
120
|
122
|
}
|
121
|
123
|
|
|
@@ -157,7 +159,7 @@ public class StackControllerTest extends BaseTest {
|
157
|
159
|
uut.push(child1);
|
158
|
160
|
uut.push(child2);
|
159
|
161
|
uut.pop(child2);
|
160
|
|
- assertThat(uut.getChildControllers()).containsOnly(child1);
|
|
162
|
+ assertThat(uut.getStack()).containsOnly(child1);
|
161
|
163
|
assertHasSingleChildViewOfController(child1);
|
162
|
164
|
}
|
163
|
165
|
|
|
@@ -168,10 +170,15 @@ public class StackControllerTest extends BaseTest {
|
168
|
170
|
assertHasSingleChildViewOfController(child2);
|
169
|
171
|
|
170
|
172
|
uut.pop(child1);
|
171
|
|
- assertThat(uut.getChildControllers()).containsOnly(child2);
|
|
173
|
+ assertThat(uut.getStack()).containsOnly(child2);
|
172
|
174
|
assertHasSingleChildViewOfController(child2);
|
173
|
175
|
}
|
174
|
176
|
|
|
177
|
+ @Test
|
|
178
|
+ public void getStackControllerReturnsSelf() throws Exception {
|
|
179
|
+ assertThat(uut.getStackController()).isEqualTo(uut);
|
|
180
|
+ }
|
|
181
|
+
|
175
|
182
|
private void assertHasSingleChildViewOfController(ViewController childController) {
|
176
|
183
|
assertThat(uut.getView().getChildCount()).isEqualTo(1);
|
177
|
184
|
assertThat(uut.getView().getChildAt(0)).isEqualTo(childController.getView());
|