|
@@ -22,6 +22,7 @@ import com.reactnativenavigation.views.StackLayout;
|
22
|
22
|
|
23
|
23
|
import org.assertj.core.api.iterable.Extractor;
|
24
|
24
|
import org.json.JSONObject;
|
|
25
|
+import org.junit.Ignore;
|
25
|
26
|
import org.junit.Test;
|
26
|
27
|
import org.mockito.ArgumentCaptor;
|
27
|
28
|
import org.mockito.Mockito;
|
|
@@ -55,12 +56,12 @@ public class StackControllerTest extends BaseTest {
|
55
|
56
|
}
|
56
|
57
|
|
57
|
58
|
@Test
|
58
|
|
- public void isAViewController() throws Exception {
|
|
59
|
+ public void isAViewController() {
|
59
|
60
|
assertThat(uut).isInstanceOf(ViewController.class);
|
60
|
61
|
}
|
61
|
62
|
|
62
|
63
|
@Test
|
63
|
|
- public void holdsAStackOfViewControllers() throws Exception {
|
|
64
|
+ public void holdsAStackOfViewControllers() {
|
64
|
65
|
assertThat(uut.isEmpty()).isTrue();
|
65
|
66
|
uut.animatePush(child1, new MockPromise());
|
66
|
67
|
uut.animatePush(child2, new MockPromise());
|
|
@@ -70,14 +71,14 @@ public class StackControllerTest extends BaseTest {
|
70
|
71
|
}
|
71
|
72
|
|
72
|
73
|
@Test
|
73
|
|
- public void push() throws Exception {
|
|
74
|
+ public void push() {
|
74
|
75
|
assertThat(uut.isEmpty()).isTrue();
|
75
|
76
|
uut.animatePush(child1, new MockPromise());
|
76
|
77
|
assertContainsOnlyId(child1.getId());
|
77
|
78
|
}
|
78
|
79
|
|
79
|
80
|
@Test
|
80
|
|
- public void pop() throws Exception {
|
|
81
|
+ public void pop() {
|
81
|
82
|
uut.animatePush(child1, new MockPromise());
|
82
|
83
|
uut.animatePush(child2, new MockPromise() {
|
83
|
84
|
@Override
|
|
@@ -90,7 +91,7 @@ public class StackControllerTest extends BaseTest {
|
90
|
91
|
}
|
91
|
92
|
|
92
|
93
|
@Test
|
93
|
|
- public void pop_appliesOptionsAfterPop() throws Exception {
|
|
94
|
+ public void pop_appliesOptionsAfterPop() {
|
94
|
95
|
uut.animatePush(child1, new MockPromise());
|
95
|
96
|
uut.animatePush(child2, new MockPromise() {
|
96
|
97
|
@Override
|
|
@@ -102,7 +103,7 @@ public class StackControllerTest extends BaseTest {
|
102
|
103
|
}
|
103
|
104
|
|
104
|
105
|
@Test
|
105
|
|
- public void pop_layoutHandlesChildWillDisappear() throws Exception {
|
|
106
|
+ public void pop_layoutHandlesChildWillDisappear() {
|
106
|
107
|
final StackLayout[] stackLayout = new StackLayout[1];
|
107
|
108
|
uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "uut", new Options()) {
|
108
|
109
|
@NonNull
|
|
@@ -128,7 +129,7 @@ public class StackControllerTest extends BaseTest {
|
128
|
129
|
}
|
129
|
130
|
|
130
|
131
|
@Test
|
131
|
|
- public void stackOperations() throws Exception {
|
|
132
|
+ public void stackOperations() {
|
132
|
133
|
assertThat(uut.peek()).isNull();
|
133
|
134
|
assertThat(uut.size()).isZero();
|
134
|
135
|
assertThat(uut.isEmpty()).isTrue();
|
|
@@ -139,7 +140,7 @@ public class StackControllerTest extends BaseTest {
|
139
|
140
|
}
|
140
|
141
|
|
141
|
142
|
@Test
|
142
|
|
- public void pushAssignsRefToSelfOnPushedController() throws Exception {
|
|
143
|
+ public void pushAssignsRefToSelfOnPushedController() {
|
143
|
144
|
assertThat(child1.getParentController()).isNull();
|
144
|
145
|
uut.animatePush(child1, new MockPromise());
|
145
|
146
|
assertThat(child1.getParentController()).isEqualTo(uut);
|
|
@@ -150,7 +151,7 @@ public class StackControllerTest extends BaseTest {
|
150
|
151
|
}
|
151
|
152
|
|
152
|
153
|
@Test
|
153
|
|
- public void handleBack_PopsUnlessSingleChild() throws Exception {
|
|
154
|
+ public void handleBack_PopsUnlessSingleChild() {
|
154
|
155
|
assertThat(uut.isEmpty()).isTrue();
|
155
|
156
|
assertThat(uut.handleBack()).isFalse();
|
156
|
157
|
|
|
@@ -171,7 +172,7 @@ public class StackControllerTest extends BaseTest {
|
171
|
172
|
}
|
172
|
173
|
|
173
|
174
|
@Test
|
174
|
|
- public void popDoesNothingWhenZeroOrOneChild() throws Exception {
|
|
175
|
+ public void popDoesNothingWhenZeroOrOneChild() {
|
175
|
176
|
assertThat(uut.isEmpty()).isTrue();
|
176
|
177
|
uut.pop(new MockPromise());
|
177
|
178
|
assertThat(uut.isEmpty()).isTrue();
|
|
@@ -182,7 +183,7 @@ public class StackControllerTest extends BaseTest {
|
182
|
183
|
}
|
183
|
184
|
|
184
|
185
|
@Test
|
185
|
|
- public void canPopWhenSizeIsMoreThanOne() throws Exception {
|
|
186
|
+ public void canPopWhenSizeIsMoreThanOne() {
|
186
|
187
|
assertThat(uut.isEmpty()).isTrue();
|
187
|
188
|
assertThat(uut.canPop()).isFalse();
|
188
|
189
|
uut.animatePush(child1, new MockPromise());
|
|
@@ -194,14 +195,14 @@ public class StackControllerTest extends BaseTest {
|
194
|
195
|
}
|
195
|
196
|
|
196
|
197
|
@Test
|
197
|
|
- public void pushAddsToViewTree() throws Exception {
|
|
198
|
+ public void pushAddsToViewTree() {
|
198
|
199
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
|
199
|
200
|
uut.animatePush(child1, new MockPromise());
|
200
|
201
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
|
201
|
202
|
}
|
202
|
203
|
|
203
|
204
|
@Test
|
204
|
|
- public void pushRemovesPreviousFromTree() throws Exception {
|
|
205
|
+ public void pushRemovesPreviousFromTree() {
|
205
|
206
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
|
206
|
207
|
uut.animatePush(child1, new MockPromise());
|
207
|
208
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
|
|
@@ -215,7 +216,7 @@ public class StackControllerTest extends BaseTest {
|
215
|
216
|
}
|
216
|
217
|
|
217
|
218
|
@Test
|
218
|
|
- public void popReplacesViewWithPrevious() throws Exception {
|
|
219
|
+ public void popReplacesViewWithPrevious() {
|
219
|
220
|
final View child2View = child2.getView();
|
220
|
221
|
final View child1View = child1.getView();
|
221
|
222
|
|
|
@@ -233,7 +234,7 @@ public class StackControllerTest extends BaseTest {
|
233
|
234
|
}
|
234
|
235
|
|
235
|
236
|
@Test
|
236
|
|
- public void popSpecificWhenTopIsRegularPop() throws Exception {
|
|
237
|
+ public void popSpecificWhenTopIsRegularPop() {
|
237
|
238
|
uut.animatePush(child1, new MockPromise());
|
238
|
239
|
uut.animatePush(child2, new MockPromise() {
|
239
|
240
|
@Override
|
|
@@ -250,7 +251,7 @@ public class StackControllerTest extends BaseTest {
|
250
|
251
|
}
|
251
|
252
|
|
252
|
253
|
@Test
|
253
|
|
- public void popSpecificDeepInStack() throws Exception {
|
|
254
|
+ public void popSpecificDeepInStack() {
|
254
|
255
|
uut.animatePush(child1, new MockPromise());
|
255
|
256
|
uut.animatePush(child2, new MockPromise());
|
256
|
257
|
assertIsChildById(uut.getView(), child2.getView());
|
|
@@ -260,7 +261,7 @@ public class StackControllerTest extends BaseTest {
|
260
|
261
|
}
|
261
|
262
|
|
262
|
263
|
@Test
|
263
|
|
- public void popTo_PopsTopUntilControllerIsNewTop() throws Exception {
|
|
264
|
+ public void popTo_PopsTopUntilControllerIsNewTop() {
|
264
|
265
|
uut.animatePush(child1, new MockPromise());
|
265
|
266
|
uut.animatePush(child2, new MockPromise());
|
266
|
267
|
uut.animatePush(child3, new MockPromise() {
|
|
@@ -278,7 +279,7 @@ public class StackControllerTest extends BaseTest {
|
278
|
279
|
}
|
279
|
280
|
|
280
|
281
|
@Test
|
281
|
|
- public void popTo_NotAChildOfThisStack_DoesNothing() throws Exception {
|
|
282
|
+ public void popTo_NotAChildOfThisStack_DoesNothing() {
|
282
|
283
|
uut.animatePush(child1, new MockPromise());
|
283
|
284
|
uut.animatePush(child3, new MockPromise());
|
284
|
285
|
assertThat(uut.size()).isEqualTo(2);
|
|
@@ -287,7 +288,7 @@ public class StackControllerTest extends BaseTest {
|
287
|
288
|
}
|
288
|
289
|
|
289
|
290
|
@Test
|
290
|
|
- public void popToRoot_PopsEverythingAboveFirstController() throws Exception {
|
|
291
|
+ public void popToRoot_PopsEverythingAboveFirstController() {
|
291
|
292
|
uut.animatePush(child1, new MockPromise());
|
292
|
293
|
uut.animatePush(child2, new MockPromise());
|
293
|
294
|
uut.animatePush(child3, new MockPromise() {
|
|
@@ -308,14 +309,14 @@ public class StackControllerTest extends BaseTest {
|
308
|
309
|
}
|
309
|
310
|
|
310
|
311
|
@Test
|
311
|
|
- public void popToRoot_EmptyStackDoesNothing() throws Exception {
|
|
312
|
+ public void popToRoot_EmptyStackDoesNothing() {
|
312
|
313
|
assertThat(uut.isEmpty()).isTrue();
|
313
|
314
|
uut.popToRoot(new MockPromise());
|
314
|
315
|
assertThat(uut.isEmpty()).isTrue();
|
315
|
316
|
}
|
316
|
317
|
|
317
|
318
|
@Test
|
318
|
|
- public void findControllerById_ReturnsSelfOrChildrenById() throws Exception {
|
|
319
|
+ public void findControllerById_ReturnsSelfOrChildrenById() {
|
319
|
320
|
assertThat(uut.findControllerById("123")).isNull();
|
320
|
321
|
assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
|
321
|
322
|
uut.animatePush(child1, new MockPromise());
|
|
@@ -323,7 +324,7 @@ public class StackControllerTest extends BaseTest {
|
323
|
324
|
}
|
324
|
325
|
|
325
|
326
|
@Test
|
326
|
|
- public void findControllerById_Deeply() throws Exception {
|
|
327
|
+ public void findControllerById_Deeply() {
|
327
|
328
|
StackController stack = createStackController("another");
|
328
|
329
|
stack.animatePush(child2, new MockPromise());
|
329
|
330
|
uut.animatePush(stack, new MockPromise());
|
|
@@ -331,7 +332,7 @@ public class StackControllerTest extends BaseTest {
|
331
|
332
|
}
|
332
|
333
|
|
333
|
334
|
@Test
|
334
|
|
- public void pop_CallsDestroyOnPoppedChild() throws Exception {
|
|
335
|
+ public void pop_CallsDestroyOnPoppedChild() {
|
335
|
336
|
child1 = spy(child1);
|
336
|
337
|
child2 = spy(child2);
|
337
|
338
|
child3 = spy(child3);
|
|
@@ -348,7 +349,7 @@ public class StackControllerTest extends BaseTest {
|
348
|
349
|
}
|
349
|
350
|
|
350
|
351
|
@Test
|
351
|
|
- public void pop_callWillAppearWillDisappear() throws Exception {
|
|
352
|
+ public void pop_callWillAppearWillDisappear() {
|
352
|
353
|
child1 = spy(child1);
|
353
|
354
|
child2 = spy(child2);
|
354
|
355
|
uut.push(child1, new MockPromise());
|
|
@@ -359,7 +360,7 @@ public class StackControllerTest extends BaseTest {
|
359
|
360
|
}
|
360
|
361
|
|
361
|
362
|
@Test
|
362
|
|
- public void pop_animatesTopBarIfNeeded() throws Exception {
|
|
363
|
+ public void pop_animatesTopBarIfNeeded() {
|
363
|
364
|
uut.ensureViewIsCreated();
|
364
|
365
|
|
365
|
366
|
child1.options.topBarOptions.visible = new Bool(false);
|
|
@@ -379,7 +380,7 @@ public class StackControllerTest extends BaseTest {
|
379
|
380
|
}
|
380
|
381
|
|
381
|
382
|
@Test
|
382
|
|
- public void popSpecific_CallsDestroyOnPoppedChild() throws Exception {
|
|
383
|
+ public void popSpecific_CallsDestroyOnPoppedChild() {
|
383
|
384
|
child1 = spy(child1);
|
384
|
385
|
child2 = spy(child2);
|
385
|
386
|
child3 = spy(child3);
|
|
@@ -393,7 +394,7 @@ public class StackControllerTest extends BaseTest {
|
393
|
394
|
}
|
394
|
395
|
|
395
|
396
|
@Test
|
396
|
|
- public void popTo_CallsDestroyOnPoppedChild() throws Exception {
|
|
397
|
+ public void popTo_CallsDestroyOnPoppedChild() {
|
397
|
398
|
child1 = spy(child1);
|
398
|
399
|
child2 = spy(child2);
|
399
|
400
|
child3 = spy(child3);
|
|
@@ -417,7 +418,7 @@ public class StackControllerTest extends BaseTest {
|
417
|
418
|
}
|
418
|
419
|
|
419
|
420
|
@Test
|
420
|
|
- public void stackCanBePushed() throws Exception {
|
|
421
|
+ public void stackCanBePushed() {
|
421
|
422
|
StackController parent = createStackController("someStack");
|
422
|
423
|
parent.ensureViewIsCreated();
|
423
|
424
|
parent.push(uut, new MockPromise());
|
|
@@ -426,7 +427,7 @@ public class StackControllerTest extends BaseTest {
|
426
|
427
|
}
|
427
|
428
|
|
428
|
429
|
@Test
|
429
|
|
- public void applyOptions_applyOnlyOnFirstStack() throws Exception {
|
|
430
|
+ public void applyOptions_applyOnlyOnFirstStack() {
|
430
|
431
|
StackController parent = spy(createStackController("someStack"));
|
431
|
432
|
parent.ensureViewIsCreated();
|
432
|
433
|
parent.push(uut, new MockPromise());
|
|
@@ -445,7 +446,7 @@ public class StackControllerTest extends BaseTest {
|
445
|
446
|
}
|
446
|
447
|
|
447
|
448
|
@Test
|
448
|
|
- public void applyOptions_topTabsAreNotVisibleIfNoTabsAreDefined() throws Exception {
|
|
449
|
+ public void applyOptions_topTabsAreNotVisibleIfNoTabsAreDefined() {
|
449
|
450
|
uut.ensureViewIsCreated();
|
450
|
451
|
uut.push(child1, new MockPromise());
|
451
|
452
|
child1.ensureViewIsCreated();
|
|
@@ -454,7 +455,7 @@ public class StackControllerTest extends BaseTest {
|
454
|
455
|
}
|
455
|
456
|
|
456
|
457
|
@Test
|
457
|
|
- public void buttonPressInvokedOnCurrentStack() throws Exception {
|
|
458
|
+ public void buttonPressInvokedOnCurrentStack() {
|
458
|
459
|
uut.ensureViewIsCreated();
|
459
|
460
|
uut.push(child1, new MockPromise());
|
460
|
461
|
uut.sendOnNavigationButtonPressed("btn1");
|
|
@@ -462,7 +463,7 @@ public class StackControllerTest extends BaseTest {
|
462
|
463
|
}
|
463
|
464
|
|
464
|
465
|
@Test
|
465
|
|
- public void mergeChildOptions_updatesViewWithNewOptions() throws Exception {
|
|
466
|
+ public void mergeChildOptions_updatesViewWithNewOptions() {
|
466
|
467
|
final StackLayout[] stackLayout = new StackLayout[1];
|
467
|
468
|
StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack", new Options()) {
|
468
|
469
|
@NonNull
|
|
@@ -479,7 +480,7 @@ public class StackControllerTest extends BaseTest {
|
479
|
480
|
}
|
480
|
481
|
|
481
|
482
|
@Test
|
482
|
|
- public void mergeChildOptions_updatesParentControllerWithNewOptions() throws Exception {
|
|
483
|
+ public void mergeChildOptions_updatesParentControllerWithNewOptions() {
|
483
|
484
|
final StackLayout[] stackLayout = new StackLayout[1];
|
484
|
485
|
StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack", new Options()) {
|
485
|
486
|
@NonNull
|
|
@@ -504,7 +505,7 @@ public class StackControllerTest extends BaseTest {
|
504
|
505
|
}
|
505
|
506
|
|
506
|
507
|
@Test
|
507
|
|
- public void mergeChildOptions_mergeAnimationOptions() throws Exception {
|
|
508
|
+ public void mergeChildOptions_mergeAnimationOptions() {
|
508
|
509
|
Options options = new Options();
|
509
|
510
|
Component component = mock(Component.class);
|
510
|
511
|
|
|
@@ -514,7 +515,7 @@ public class StackControllerTest extends BaseTest {
|
514
|
515
|
}
|
515
|
516
|
|
516
|
517
|
@Test
|
517
|
|
- public void mergeChildOptions_StackRelatedOptionsAreCleared() throws Exception {
|
|
518
|
+ public void mergeChildOptions_StackRelatedOptionsAreCleared() {
|
518
|
519
|
ParentController parentController = Mockito.mock(ParentController.class);
|
519
|
520
|
uut.setParentController(parentController);
|
520
|
521
|
Options options = new Options();
|