|
@@ -66,9 +66,9 @@ public class StackControllerTest extends BaseTest {
|
66
|
66
|
@Test
|
67
|
67
|
public void holdsAStackOfViewControllers() {
|
68
|
68
|
assertThat(uut.isEmpty()).isTrue();
|
69
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
70
|
|
- uut.animatePush(child2, new CommandListenerAdapter());
|
71
|
|
- uut.animatePush(child3, new CommandListenerAdapter());
|
|
69
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
70
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
71
|
+ uut.push(child3, new CommandListenerAdapter());
|
72
|
72
|
assertThat(uut.peek()).isEqualTo(child3);
|
73
|
73
|
assertContainsOnlyId(child1.getId(), child2.getId(), child3.getId());
|
74
|
74
|
}
|
|
@@ -76,7 +76,7 @@ public class StackControllerTest extends BaseTest {
|
76
|
76
|
@Test
|
77
|
77
|
public void push() {
|
78
|
78
|
assertThat(uut.isEmpty()).isTrue();
|
79
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
79
|
+ uut.push(child1, new CommandListenerAdapter());
|
80
|
80
|
assertContainsOnlyId(child1.getId());
|
81
|
81
|
}
|
82
|
82
|
|
|
@@ -85,7 +85,7 @@ public class StackControllerTest extends BaseTest {
|
85
|
85
|
assertThat(uut.isEmpty()).isTrue();
|
86
|
86
|
uut.push(child1, new CommandListenerAdapter());
|
87
|
87
|
uut.push(child2, new CommandListenerAdapter());
|
88
|
|
- uut.animateSetRoot(child3, new CommandListenerAdapter() {
|
|
88
|
+ uut.setRoot(child3, new CommandListenerAdapter() {
|
89
|
89
|
@Override
|
90
|
90
|
public void onSuccess(String childId) {
|
91
|
91
|
assertContainsOnlyId(child3.getId());
|
|
@@ -108,8 +108,8 @@ public class StackControllerTest extends BaseTest {
|
108
|
108
|
|
109
|
109
|
@Test
|
110
|
110
|
public void pop() {
|
111
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
112
|
|
- uut.animatePush(child2, new CommandListenerAdapter() {
|
|
111
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
112
|
+ uut.push(child2, new CommandListenerAdapter() {
|
113
|
113
|
@Override
|
114
|
114
|
public void onSuccess(String childId) {
|
115
|
115
|
assertContainsOnlyId(child2.getId(), child1.getId());
|
|
@@ -121,8 +121,8 @@ public class StackControllerTest extends BaseTest {
|
121
|
121
|
|
122
|
122
|
@Test
|
123
|
123
|
public void pop_appliesOptionsAfterPop() {
|
124
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
125
|
|
- uut.animatePush(child2, new CommandListenerAdapter() {
|
|
124
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
125
|
+ uut.push(child2, new CommandListenerAdapter() {
|
126
|
126
|
@Override
|
127
|
127
|
public void onSuccess(String childId) {
|
128
|
128
|
uut.pop(new MockPromise());
|
|
@@ -144,7 +144,7 @@ public class StackControllerTest extends BaseTest {
|
144
|
144
|
}
|
145
|
145
|
};
|
146
|
146
|
uut.push(child1, new CommandListenerAdapter());
|
147
|
|
- uut.animatePush(child2, new CommandListenerAdapter() {
|
|
147
|
+ uut.push(child2, new CommandListenerAdapter() {
|
148
|
148
|
@Override
|
149
|
149
|
public void onSuccess(String childId) {
|
150
|
150
|
uut.animatePop(new MockPromise() {
|
|
@@ -163,7 +163,7 @@ public class StackControllerTest extends BaseTest {
|
163
|
163
|
assertThat(uut.peek()).isNull();
|
164
|
164
|
assertThat(uut.size()).isZero();
|
165
|
165
|
assertThat(uut.isEmpty()).isTrue();
|
166
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
166
|
+ uut.push(child1, new CommandListenerAdapter());
|
167
|
167
|
assertThat(uut.peek()).isEqualTo(child1);
|
168
|
168
|
assertThat(uut.size()).isEqualTo(1);
|
169
|
169
|
assertThat(uut.isEmpty()).isFalse();
|
|
@@ -172,11 +172,11 @@ public class StackControllerTest extends BaseTest {
|
172
|
172
|
@Test
|
173
|
173
|
public void pushAssignsRefToSelfOnPushedController() {
|
174
|
174
|
assertThat(child1.getParentController()).isNull();
|
175
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
175
|
+ uut.push(child1, new CommandListenerAdapter());
|
176
|
176
|
assertThat(child1.getParentController()).isEqualTo(uut);
|
177
|
177
|
|
178
|
178
|
StackController anotherNavController = createStackController("another");
|
179
|
|
- anotherNavController.animatePush(child2, new CommandListenerAdapter());
|
|
179
|
+ anotherNavController.push(child2, new CommandListenerAdapter());
|
180
|
180
|
assertThat(child2.getParentController()).isEqualTo(anotherNavController);
|
181
|
181
|
}
|
182
|
182
|
|
|
@@ -185,11 +185,11 @@ public class StackControllerTest extends BaseTest {
|
185
|
185
|
assertThat(uut.isEmpty()).isTrue();
|
186
|
186
|
assertThat(uut.handleBack()).isFalse();
|
187
|
187
|
|
188
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
188
|
+ uut.push(child1, new CommandListenerAdapter());
|
189
|
189
|
assertThat(uut.size()).isEqualTo(1);
|
190
|
190
|
assertThat(uut.handleBack()).isFalse();
|
191
|
191
|
|
192
|
|
- uut.animatePush(child2, new CommandListenerAdapter() {
|
|
192
|
+ uut.push(child2, new CommandListenerAdapter() {
|
193
|
193
|
@Override
|
194
|
194
|
public void onSuccess(String childId) {
|
195
|
195
|
assertThat(uut.size()).isEqualTo(2);
|
|
@@ -207,7 +207,7 @@ public class StackControllerTest extends BaseTest {
|
207
|
207
|
uut.pop(new MockPromise());
|
208
|
208
|
assertThat(uut.isEmpty()).isTrue();
|
209
|
209
|
|
210
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
210
|
+ uut.push(child1, new CommandListenerAdapter());
|
211
|
211
|
uut.pop(new MockPromise());
|
212
|
212
|
assertContainsOnlyId(child1.getId());
|
213
|
213
|
}
|
|
@@ -216,10 +216,10 @@ public class StackControllerTest extends BaseTest {
|
216
|
216
|
public void canPopWhenSizeIsMoreThanOne() {
|
217
|
217
|
assertThat(uut.isEmpty()).isTrue();
|
218
|
218
|
assertThat(uut.canPop()).isFalse();
|
219
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
219
|
+ uut.push(child1, new CommandListenerAdapter());
|
220
|
220
|
assertContainsOnlyId(child1.getId());
|
221
|
221
|
assertThat(uut.canPop()).isFalse();
|
222
|
|
- uut.animatePush(child2, new CommandListenerAdapter());
|
|
222
|
+ uut.push(child2, new CommandListenerAdapter());
|
223
|
223
|
assertContainsOnlyId(child1.getId(), child2.getId());
|
224
|
224
|
assertThat(uut.canPop()).isTrue();
|
225
|
225
|
}
|
|
@@ -227,16 +227,16 @@ public class StackControllerTest extends BaseTest {
|
227
|
227
|
@Test
|
228
|
228
|
public void pushAddsToViewTree() {
|
229
|
229
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
|
230
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
230
|
+ uut.push(child1, new CommandListenerAdapter());
|
231
|
231
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
|
232
|
232
|
}
|
233
|
233
|
|
234
|
234
|
@Test
|
235
|
235
|
public void pushRemovesPreviousFromTree() {
|
236
|
236
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
|
237
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
237
|
+ uut.push(child1, new CommandListenerAdapter());
|
238
|
238
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
|
239
|
|
- uut.animatePush(child2, new CommandListenerAdapter() {
|
|
239
|
+ uut.push(child2, new CommandListenerAdapter() {
|
240
|
240
|
@Override
|
241
|
241
|
public void onSuccess(String childId) {
|
242
|
242
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
|
|
@@ -250,8 +250,8 @@ public class StackControllerTest extends BaseTest {
|
250
|
250
|
final View child2View = child2.getView();
|
251
|
251
|
final View child1View = child1.getView();
|
252
|
252
|
|
253
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
254
|
|
- uut.animatePush(child2, new CommandListenerAdapter() {
|
|
253
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
254
|
+ uut.push(child2, new CommandListenerAdapter() {
|
255
|
255
|
@Override
|
256
|
256
|
public void onSuccess(String childId) {
|
257
|
257
|
assertIsChildById(uut.getView(), child2View);
|
|
@@ -265,8 +265,8 @@ public class StackControllerTest extends BaseTest {
|
265
|
265
|
|
266
|
266
|
@Test
|
267
|
267
|
public void popSpecificWhenTopIsRegularPop() {
|
268
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
269
|
|
- uut.animatePush(child2, new CommandListenerAdapter() {
|
|
268
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
269
|
+ uut.push(child2, new CommandListenerAdapter() {
|
270
|
270
|
@Override
|
271
|
271
|
public void onSuccess(String childId) {
|
272
|
272
|
uut.popSpecific(child2, new MockPromise() {
|
|
@@ -282,8 +282,8 @@ public class StackControllerTest extends BaseTest {
|
282
|
282
|
|
283
|
283
|
@Test
|
284
|
284
|
public void popSpecificDeepInStack() {
|
285
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
286
|
|
- uut.animatePush(child2, new CommandListenerAdapter());
|
|
285
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
286
|
+ uut.push(child2, new CommandListenerAdapter());
|
287
|
287
|
assertIsChildById(uut.getView(), child2.getView());
|
288
|
288
|
uut.popSpecific(child1, new MockPromise());
|
289
|
289
|
assertContainsOnlyId(child2.getId());
|
|
@@ -292,9 +292,9 @@ public class StackControllerTest extends BaseTest {
|
292
|
292
|
|
293
|
293
|
@Test
|
294
|
294
|
public void popTo_PopsTopUntilControllerIsNewTop() {
|
295
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
296
|
|
- uut.animatePush(child2, new CommandListenerAdapter());
|
297
|
|
- uut.animatePush(child3, new CommandListenerAdapter() {
|
|
295
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
296
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
297
|
+ uut.push(child3, new CommandListenerAdapter() {
|
298
|
298
|
@Override
|
299
|
299
|
public void onSuccess(String childId) {
|
300
|
300
|
assertThat(uut.size()).isEqualTo(3);
|
|
@@ -310,8 +310,8 @@ public class StackControllerTest extends BaseTest {
|
310
|
310
|
|
311
|
311
|
@Test
|
312
|
312
|
public void popTo_NotAChildOfThisStack_DoesNothing() {
|
313
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
314
|
|
- uut.animatePush(child3, new CommandListenerAdapter());
|
|
313
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
314
|
+ uut.push(child3, new CommandListenerAdapter());
|
315
|
315
|
assertThat(uut.size()).isEqualTo(2);
|
316
|
316
|
uut.popTo(child2, new MockPromise());
|
317
|
317
|
assertThat(uut.size()).isEqualTo(2);
|
|
@@ -319,9 +319,12 @@ public class StackControllerTest extends BaseTest {
|
319
|
319
|
|
320
|
320
|
@Test
|
321
|
321
|
public void popToRoot_PopsEverythingAboveFirstController() {
|
322
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
323
|
|
- uut.animatePush(child2, new CommandListenerAdapter());
|
324
|
|
- uut.animatePush(child3, new CommandListenerAdapter() {
|
|
322
|
+ child1.options.animated = new Bool(false);
|
|
323
|
+ child2.options.animated = new Bool(false);
|
|
324
|
+
|
|
325
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
326
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
327
|
+ uut.push(child3, new CommandListenerAdapter() {
|
325
|
328
|
@Override
|
326
|
329
|
public void onSuccess(String childId) {
|
327
|
330
|
assertThat(uut.size()).isEqualTo(3);
|
|
@@ -349,15 +352,15 @@ public class StackControllerTest extends BaseTest {
|
349
|
352
|
public void findControllerById_ReturnsSelfOrChildrenById() {
|
350
|
353
|
assertThat(uut.findControllerById("123")).isNull();
|
351
|
354
|
assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
|
352
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
|
355
|
+ uut.push(child1, new CommandListenerAdapter());
|
353
|
356
|
assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
|
354
|
357
|
}
|
355
|
358
|
|
356
|
359
|
@Test
|
357
|
360
|
public void findControllerById_Deeply() {
|
358
|
361
|
StackController stack = createStackController("another");
|
359
|
|
- stack.animatePush(child2, new CommandListenerAdapter());
|
360
|
|
- uut.animatePush(stack, new CommandListenerAdapter());
|
|
362
|
+ stack.push(child2, new CommandListenerAdapter());
|
|
363
|
+ uut.push(stack, new CommandListenerAdapter());
|
361
|
364
|
assertThat(uut.findControllerById(child2.getId())).isEqualTo(child2);
|
362
|
365
|
}
|
363
|
366
|
|
|
@@ -366,9 +369,9 @@ public class StackControllerTest extends BaseTest {
|
366
|
369
|
child1 = spy(child1);
|
367
|
370
|
child2 = spy(child2);
|
368
|
371
|
child3 = spy(child3);
|
369
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
370
|
|
- uut.animatePush(child2, new CommandListenerAdapter());
|
371
|
|
- uut.animatePush(child3, new CommandListenerAdapter() {
|
|
372
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
373
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
374
|
+ uut.push(child3, new CommandListenerAdapter() {
|
372
|
375
|
@Override
|
373
|
376
|
public void onSuccess(String childId) {
|
374
|
377
|
verify(child3, times(0)).destroy();
|
|
@@ -380,6 +383,8 @@ public class StackControllerTest extends BaseTest {
|
380
|
383
|
|
381
|
384
|
@Test
|
382
|
385
|
public void pop_callWillAppearWillDisappear() {
|
|
386
|
+ child1.options.animated = new Bool(false);
|
|
387
|
+ child2.options.animated = new Bool(false);
|
383
|
388
|
child1 = spy(child1);
|
384
|
389
|
child2 = spy(child2);
|
385
|
390
|
uut.push(child1, new CommandListenerAdapter());
|
|
@@ -414,9 +419,9 @@ public class StackControllerTest extends BaseTest {
|
414
|
419
|
child1 = spy(child1);
|
415
|
420
|
child2 = spy(child2);
|
416
|
421
|
child3 = spy(child3);
|
417
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
418
|
|
- uut.animatePush(child2, new CommandListenerAdapter());
|
419
|
|
- uut.animatePush(child3, new CommandListenerAdapter());
|
|
422
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
423
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
424
|
+ uut.push(child3, new CommandListenerAdapter());
|
420
|
425
|
|
421
|
426
|
verify(child2, times(0)).destroy();
|
422
|
427
|
uut.popSpecific(child2, new MockPromise());
|
|
@@ -428,9 +433,9 @@ public class StackControllerTest extends BaseTest {
|
428
|
433
|
child1 = spy(child1);
|
429
|
434
|
child2 = spy(child2);
|
430
|
435
|
child3 = spy(child3);
|
431
|
|
- uut.animatePush(child1, new CommandListenerAdapter());
|
432
|
|
- uut.animatePush(child2, new CommandListenerAdapter());
|
433
|
|
- uut.animatePush(child3, new CommandListenerAdapter() {
|
|
436
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
437
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
438
|
+ uut.push(child3, new CommandListenerAdapter() {
|
434
|
439
|
@Override
|
435
|
440
|
public void onSuccess(String childId) {
|
436
|
441
|
verify(child2, times(0)).destroy();
|