|
@@ -15,6 +15,7 @@ import com.reactnativenavigation.parse.NestedAnimationsOptions;
|
15
|
15
|
import com.reactnativenavigation.parse.Options;
|
16
|
16
|
import com.reactnativenavigation.parse.params.Bool;
|
17
|
17
|
import com.reactnativenavigation.parse.params.Text;
|
|
18
|
+import com.reactnativenavigation.utils.CommandListenerAdapter;
|
18
|
19
|
import com.reactnativenavigation.utils.ViewHelper;
|
19
|
20
|
import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
|
20
|
21
|
import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
|
|
@@ -65,9 +66,9 @@ public class StackControllerTest extends BaseTest {
|
65
|
66
|
@Test
|
66
|
67
|
public void holdsAStackOfViewControllers() {
|
67
|
68
|
assertThat(uut.isEmpty()).isTrue();
|
68
|
|
- uut.animatePush(child1, new MockPromise());
|
69
|
|
- uut.animatePush(child2, new MockPromise());
|
70
|
|
- uut.animatePush(child3, new MockPromise());
|
|
69
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
70
|
+ uut.animatePush(child2, new CommandListenerAdapter());
|
|
71
|
+ uut.animatePush(child3, new CommandListenerAdapter());
|
71
|
72
|
assertThat(uut.peek()).isEqualTo(child3);
|
72
|
73
|
assertContainsOnlyId(child1.getId(), child2.getId(), child3.getId());
|
73
|
74
|
}
|
|
@@ -75,16 +76,42 @@ public class StackControllerTest extends BaseTest {
|
75
|
76
|
@Test
|
76
|
77
|
public void push() {
|
77
|
78
|
assertThat(uut.isEmpty()).isTrue();
|
78
|
|
- uut.animatePush(child1, new MockPromise());
|
|
79
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
79
|
80
|
assertContainsOnlyId(child1.getId());
|
80
|
81
|
}
|
81
|
82
|
|
|
83
|
+ @Test
|
|
84
|
+ public void animateSetRoot() {
|
|
85
|
+ assertThat(uut.isEmpty()).isTrue();
|
|
86
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
87
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
88
|
+ uut.animateSetRoot(child3, new CommandListenerAdapter() {
|
|
89
|
+ @Override
|
|
90
|
+ public void onSuccess(String childId) {
|
|
91
|
+ assertContainsOnlyId(child3.getId());
|
|
92
|
+ }
|
|
93
|
+ });
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ @Test
|
|
97
|
+ public void setRoot() {
|
|
98
|
+ assertThat(uut.isEmpty()).isTrue();
|
|
99
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
100
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
101
|
+ uut.setRoot(child3, new CommandListenerAdapter() {
|
|
102
|
+ @Override
|
|
103
|
+ public void onSuccess(String childId) {
|
|
104
|
+ assertContainsOnlyId(child3.getId());
|
|
105
|
+ }
|
|
106
|
+ });
|
|
107
|
+ }
|
|
108
|
+
|
82
|
109
|
@Test
|
83
|
110
|
public void pop() {
|
84
|
|
- uut.animatePush(child1, new MockPromise());
|
85
|
|
- uut.animatePush(child2, new MockPromise() {
|
|
111
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
112
|
+ uut.animatePush(child2, new CommandListenerAdapter() {
|
86
|
113
|
@Override
|
87
|
|
- public void resolve(@Nullable Object value) {
|
|
114
|
+ public void onSuccess(String childId) {
|
88
|
115
|
assertContainsOnlyId(child2.getId(), child1.getId());
|
89
|
116
|
uut.pop(new MockPromise());
|
90
|
117
|
assertContainsOnlyId(child1.getId());
|
|
@@ -94,10 +121,10 @@ public class StackControllerTest extends BaseTest {
|
94
|
121
|
|
95
|
122
|
@Test
|
96
|
123
|
public void pop_appliesOptionsAfterPop() {
|
97
|
|
- uut.animatePush(child1, new MockPromise());
|
98
|
|
- uut.animatePush(child2, new MockPromise() {
|
|
124
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
125
|
+ uut.animatePush(child2, new CommandListenerAdapter() {
|
99
|
126
|
@Override
|
100
|
|
- public void resolve(@Nullable Object value) {
|
|
127
|
+ public void onSuccess(String childId) {
|
101
|
128
|
uut.pop(new MockPromise());
|
102
|
129
|
verify(uut, times(1)).applyChildOptions(uut.options, eq((ReactComponent) child1.getView()));
|
103
|
130
|
}
|
|
@@ -107,18 +134,19 @@ public class StackControllerTest extends BaseTest {
|
107
|
134
|
@Test
|
108
|
135
|
public void pop_layoutHandlesChildWillDisappear() {
|
109
|
136
|
final StackLayout[] stackLayout = new StackLayout[1];
|
110
|
|
- uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "uut", new Options()) {
|
111
|
|
- @NonNull
|
112
|
|
- @Override
|
113
|
|
- protected StackLayout createView() {
|
114
|
|
- stackLayout[0] = spy(super.createView());
|
115
|
|
- return stackLayout[0];
|
116
|
|
- }
|
117
|
|
- };
|
118
|
|
- uut.push(child1, new MockPromise());
|
119
|
|
- uut.animatePush(child2, new MockPromise() {
|
|
137
|
+ uut =
|
|
138
|
+ new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "uut", new Options()) {
|
|
139
|
+ @NonNull
|
|
140
|
+ @Override
|
|
141
|
+ protected StackLayout createView() {
|
|
142
|
+ stackLayout[0] = spy(super.createView());
|
|
143
|
+ return stackLayout[0];
|
|
144
|
+ }
|
|
145
|
+ };
|
|
146
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
147
|
+ uut.animatePush(child2, new CommandListenerAdapter() {
|
120
|
148
|
@Override
|
121
|
|
- public void resolve(@Nullable Object value) {
|
|
149
|
+ public void onSuccess(String childId) {
|
122
|
150
|
uut.animatePop(new MockPromise() {
|
123
|
151
|
@Override
|
124
|
152
|
public void resolve(@Nullable Object value) {
|
|
@@ -135,7 +163,7 @@ public class StackControllerTest extends BaseTest {
|
135
|
163
|
assertThat(uut.peek()).isNull();
|
136
|
164
|
assertThat(uut.size()).isZero();
|
137
|
165
|
assertThat(uut.isEmpty()).isTrue();
|
138
|
|
- uut.animatePush(child1, new MockPromise());
|
|
166
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
139
|
167
|
assertThat(uut.peek()).isEqualTo(child1);
|
140
|
168
|
assertThat(uut.size()).isEqualTo(1);
|
141
|
169
|
assertThat(uut.isEmpty()).isFalse();
|
|
@@ -144,11 +172,11 @@ public class StackControllerTest extends BaseTest {
|
144
|
172
|
@Test
|
145
|
173
|
public void pushAssignsRefToSelfOnPushedController() {
|
146
|
174
|
assertThat(child1.getParentController()).isNull();
|
147
|
|
- uut.animatePush(child1, new MockPromise());
|
|
175
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
148
|
176
|
assertThat(child1.getParentController()).isEqualTo(uut);
|
149
|
177
|
|
150
|
178
|
StackController anotherNavController = createStackController("another");
|
151
|
|
- anotherNavController.animatePush(child2, new MockPromise());
|
|
179
|
+ anotherNavController.animatePush(child2, new CommandListenerAdapter());
|
152
|
180
|
assertThat(child2.getParentController()).isEqualTo(anotherNavController);
|
153
|
181
|
}
|
154
|
182
|
|
|
@@ -157,13 +185,13 @@ public class StackControllerTest extends BaseTest {
|
157
|
185
|
assertThat(uut.isEmpty()).isTrue();
|
158
|
186
|
assertThat(uut.handleBack()).isFalse();
|
159
|
187
|
|
160
|
|
- uut.animatePush(child1, new MockPromise());
|
|
188
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
161
|
189
|
assertThat(uut.size()).isEqualTo(1);
|
162
|
190
|
assertThat(uut.handleBack()).isFalse();
|
163
|
191
|
|
164
|
|
- uut.animatePush(child2, new MockPromise() {
|
|
192
|
+ uut.animatePush(child2, new CommandListenerAdapter() {
|
165
|
193
|
@Override
|
166
|
|
- public void resolve(@Nullable Object value) {
|
|
194
|
+ public void onSuccess(String childId) {
|
167
|
195
|
assertThat(uut.size()).isEqualTo(2);
|
168
|
196
|
assertThat(uut.handleBack()).isTrue();
|
169
|
197
|
|
|
@@ -179,7 +207,7 @@ public class StackControllerTest extends BaseTest {
|
179
|
207
|
uut.pop(new MockPromise());
|
180
|
208
|
assertThat(uut.isEmpty()).isTrue();
|
181
|
209
|
|
182
|
|
- uut.animatePush(child1, new MockPromise());
|
|
210
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
183
|
211
|
uut.pop(new MockPromise());
|
184
|
212
|
assertContainsOnlyId(child1.getId());
|
185
|
213
|
}
|
|
@@ -188,10 +216,10 @@ public class StackControllerTest extends BaseTest {
|
188
|
216
|
public void canPopWhenSizeIsMoreThanOne() {
|
189
|
217
|
assertThat(uut.isEmpty()).isTrue();
|
190
|
218
|
assertThat(uut.canPop()).isFalse();
|
191
|
|
- uut.animatePush(child1, new MockPromise());
|
|
219
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
192
|
220
|
assertContainsOnlyId(child1.getId());
|
193
|
221
|
assertThat(uut.canPop()).isFalse();
|
194
|
|
- uut.animatePush(child2, new MockPromise());
|
|
222
|
+ uut.animatePush(child2, new CommandListenerAdapter());
|
195
|
223
|
assertContainsOnlyId(child1.getId(), child2.getId());
|
196
|
224
|
assertThat(uut.canPop()).isTrue();
|
197
|
225
|
}
|
|
@@ -199,18 +227,18 @@ public class StackControllerTest extends BaseTest {
|
199
|
227
|
@Test
|
200
|
228
|
public void pushAddsToViewTree() {
|
201
|
229
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
|
202
|
|
- uut.animatePush(child1, new MockPromise());
|
|
230
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
203
|
231
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
|
204
|
232
|
}
|
205
|
233
|
|
206
|
234
|
@Test
|
207
|
235
|
public void pushRemovesPreviousFromTree() {
|
208
|
236
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
|
209
|
|
- uut.animatePush(child1, new MockPromise());
|
|
237
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
210
|
238
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
|
211
|
|
- uut.animatePush(child2, new MockPromise() {
|
|
239
|
+ uut.animatePush(child2, new CommandListenerAdapter() {
|
212
|
240
|
@Override
|
213
|
|
- public void resolve(@Nullable Object value) {
|
|
241
|
+ public void onSuccess(String childId) {
|
214
|
242
|
assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
|
215
|
243
|
assertThat(uut.getView().findViewById(child2.getView().getId())).isNotNull();
|
216
|
244
|
}
|
|
@@ -222,10 +250,10 @@ public class StackControllerTest extends BaseTest {
|
222
|
250
|
final View child2View = child2.getView();
|
223
|
251
|
final View child1View = child1.getView();
|
224
|
252
|
|
225
|
|
- uut.animatePush(child1, new MockPromise());
|
226
|
|
- uut.animatePush(child2, new MockPromise() {
|
|
253
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
254
|
+ uut.animatePush(child2, new CommandListenerAdapter() {
|
227
|
255
|
@Override
|
228
|
|
- public void resolve(@Nullable Object value) {
|
|
256
|
+ public void onSuccess(String childId) {
|
229
|
257
|
assertIsChildById(uut.getView(), child2View);
|
230
|
258
|
assertNotChildOf(uut.getView(), child1View);
|
231
|
259
|
uut.pop(new MockPromise());
|
|
@@ -237,10 +265,10 @@ public class StackControllerTest extends BaseTest {
|
237
|
265
|
|
238
|
266
|
@Test
|
239
|
267
|
public void popSpecificWhenTopIsRegularPop() {
|
240
|
|
- uut.animatePush(child1, new MockPromise());
|
241
|
|
- uut.animatePush(child2, new MockPromise() {
|
|
268
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
269
|
+ uut.animatePush(child2, new CommandListenerAdapter() {
|
242
|
270
|
@Override
|
243
|
|
- public void resolve(@Nullable Object value) {
|
|
271
|
+ public void onSuccess(String childId) {
|
244
|
272
|
uut.popSpecific(child2, new MockPromise() {
|
245
|
273
|
@Override
|
246
|
274
|
public void resolve(@Nullable Object value) {
|
|
@@ -254,8 +282,8 @@ public class StackControllerTest extends BaseTest {
|
254
|
282
|
|
255
|
283
|
@Test
|
256
|
284
|
public void popSpecificDeepInStack() {
|
257
|
|
- uut.animatePush(child1, new MockPromise());
|
258
|
|
- uut.animatePush(child2, new MockPromise());
|
|
285
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
286
|
+ uut.animatePush(child2, new CommandListenerAdapter());
|
259
|
287
|
assertIsChildById(uut.getView(), child2.getView());
|
260
|
288
|
uut.popSpecific(child1, new MockPromise());
|
261
|
289
|
assertContainsOnlyId(child2.getId());
|
|
@@ -264,11 +292,11 @@ public class StackControllerTest extends BaseTest {
|
264
|
292
|
|
265
|
293
|
@Test
|
266
|
294
|
public void popTo_PopsTopUntilControllerIsNewTop() {
|
267
|
|
- uut.animatePush(child1, new MockPromise());
|
268
|
|
- uut.animatePush(child2, new MockPromise());
|
269
|
|
- uut.animatePush(child3, new MockPromise() {
|
|
295
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
296
|
+ uut.animatePush(child2, new CommandListenerAdapter());
|
|
297
|
+ uut.animatePush(child3, new CommandListenerAdapter() {
|
270
|
298
|
@Override
|
271
|
|
- public void resolve(@Nullable Object value) {
|
|
299
|
+ public void onSuccess(String childId) {
|
272
|
300
|
assertThat(uut.size()).isEqualTo(3);
|
273
|
301
|
assertThat(uut.peek()).isEqualTo(child3);
|
274
|
302
|
|
|
@@ -282,8 +310,8 @@ public class StackControllerTest extends BaseTest {
|
282
|
310
|
|
283
|
311
|
@Test
|
284
|
312
|
public void popTo_NotAChildOfThisStack_DoesNothing() {
|
285
|
|
- uut.animatePush(child1, new MockPromise());
|
286
|
|
- uut.animatePush(child3, new MockPromise());
|
|
313
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
314
|
+ uut.animatePush(child3, new CommandListenerAdapter());
|
287
|
315
|
assertThat(uut.size()).isEqualTo(2);
|
288
|
316
|
uut.popTo(child2, new MockPromise());
|
289
|
317
|
assertThat(uut.size()).isEqualTo(2);
|
|
@@ -291,11 +319,11 @@ public class StackControllerTest extends BaseTest {
|
291
|
319
|
|
292
|
320
|
@Test
|
293
|
321
|
public void popToRoot_PopsEverythingAboveFirstController() {
|
294
|
|
- uut.animatePush(child1, new MockPromise());
|
295
|
|
- uut.animatePush(child2, new MockPromise());
|
296
|
|
- uut.animatePush(child3, new MockPromise() {
|
|
322
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
323
|
+ uut.animatePush(child2, new CommandListenerAdapter());
|
|
324
|
+ uut.animatePush(child3, new CommandListenerAdapter() {
|
297
|
325
|
@Override
|
298
|
|
- public void resolve(@Nullable Object value) {
|
|
326
|
+ public void onSuccess(String childId) {
|
299
|
327
|
assertThat(uut.size()).isEqualTo(3);
|
300
|
328
|
assertThat(uut.peek()).isEqualTo(child3);
|
301
|
329
|
|
|
@@ -321,15 +349,15 @@ public class StackControllerTest extends BaseTest {
|
321
|
349
|
public void findControllerById_ReturnsSelfOrChildrenById() {
|
322
|
350
|
assertThat(uut.findControllerById("123")).isNull();
|
323
|
351
|
assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
|
324
|
|
- uut.animatePush(child1, new MockPromise());
|
|
352
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
325
|
353
|
assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
|
326
|
354
|
}
|
327
|
355
|
|
328
|
356
|
@Test
|
329
|
357
|
public void findControllerById_Deeply() {
|
330
|
358
|
StackController stack = createStackController("another");
|
331
|
|
- stack.animatePush(child2, new MockPromise());
|
332
|
|
- uut.animatePush(stack, new MockPromise());
|
|
359
|
+ stack.animatePush(child2, new CommandListenerAdapter());
|
|
360
|
+ uut.animatePush(stack, new CommandListenerAdapter());
|
333
|
361
|
assertThat(uut.findControllerById(child2.getId())).isEqualTo(child2);
|
334
|
362
|
}
|
335
|
363
|
|
|
@@ -338,11 +366,11 @@ public class StackControllerTest extends BaseTest {
|
338
|
366
|
child1 = spy(child1);
|
339
|
367
|
child2 = spy(child2);
|
340
|
368
|
child3 = spy(child3);
|
341
|
|
- uut.animatePush(child1, new MockPromise());
|
342
|
|
- uut.animatePush(child2, new MockPromise());
|
343
|
|
- uut.animatePush(child3, new MockPromise() {
|
|
369
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
370
|
+ uut.animatePush(child2, new CommandListenerAdapter());
|
|
371
|
+ uut.animatePush(child3, new CommandListenerAdapter() {
|
344
|
372
|
@Override
|
345
|
|
- public void resolve(@Nullable Object value) {
|
|
373
|
+ public void onSuccess(String childId) {
|
346
|
374
|
verify(child3, times(0)).destroy();
|
347
|
375
|
uut.pop(new MockPromise());
|
348
|
376
|
verify(child3, times(1)).destroy();
|
|
@@ -354,8 +382,8 @@ public class StackControllerTest extends BaseTest {
|
354
|
382
|
public void pop_callWillAppearWillDisappear() {
|
355
|
383
|
child1 = spy(child1);
|
356
|
384
|
child2 = spy(child2);
|
357
|
|
- uut.push(child1, new MockPromise());
|
358
|
|
- uut.push(child2, new MockPromise());
|
|
385
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
386
|
+ uut.push(child2, new CommandListenerAdapter());
|
359
|
387
|
uut.pop(new MockPromise());
|
360
|
388
|
verify(child1, times(1)).onViewWillAppear();
|
361
|
389
|
verify(child2, times(1)).onViewWillDisappear();
|
|
@@ -368,11 +396,11 @@ public class StackControllerTest extends BaseTest {
|
368
|
396
|
child1.options.topBarOptions.visible = new Bool(false);
|
369
|
397
|
child1.options.topBarOptions.animate = new Bool(false);
|
370
|
398
|
child2.options.topBarOptions.visible = new Bool(true);
|
371
|
|
- uut.push(child1, new MockPromise());
|
|
399
|
+ uut.push(child1, new CommandListenerAdapter());
|
372
|
400
|
child1.onViewAppeared();
|
373
|
401
|
|
374
|
402
|
assertThat(uut.getTopBar().getVisibility()).isEqualTo(View.GONE);
|
375
|
|
- uut.push(child2, new MockPromise());
|
|
403
|
+ uut.push(child2, new CommandListenerAdapter());
|
376
|
404
|
uut.animatePop(new MockPromise() {
|
377
|
405
|
@Override
|
378
|
406
|
public void resolve(@Nullable Object value) {
|
|
@@ -386,9 +414,9 @@ public class StackControllerTest extends BaseTest {
|
386
|
414
|
child1 = spy(child1);
|
387
|
415
|
child2 = spy(child2);
|
388
|
416
|
child3 = spy(child3);
|
389
|
|
- uut.animatePush(child1, new MockPromise());
|
390
|
|
- uut.animatePush(child2, new MockPromise());
|
391
|
|
- uut.animatePush(child3, new MockPromise());
|
|
417
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
418
|
+ uut.animatePush(child2, new CommandListenerAdapter());
|
|
419
|
+ uut.animatePush(child3, new CommandListenerAdapter());
|
392
|
420
|
|
393
|
421
|
verify(child2, times(0)).destroy();
|
394
|
422
|
uut.popSpecific(child2, new MockPromise());
|
|
@@ -400,11 +428,11 @@ public class StackControllerTest extends BaseTest {
|
400
|
428
|
child1 = spy(child1);
|
401
|
429
|
child2 = spy(child2);
|
402
|
430
|
child3 = spy(child3);
|
403
|
|
- uut.animatePush(child1, new MockPromise());
|
404
|
|
- uut.animatePush(child2, new MockPromise());
|
405
|
|
- uut.animatePush(child3, new MockPromise() {
|
|
431
|
+ uut.animatePush(child1, new CommandListenerAdapter());
|
|
432
|
+ uut.animatePush(child2, new CommandListenerAdapter());
|
|
433
|
+ uut.animatePush(child3, new CommandListenerAdapter() {
|
406
|
434
|
@Override
|
407
|
|
- public void resolve(@Nullable Object value) {
|
|
435
|
+ public void onSuccess(String childId) {
|
408
|
436
|
verify(child2, times(0)).destroy();
|
409
|
437
|
verify(child3, times(0)).destroy();
|
410
|
438
|
|
|
@@ -423,7 +451,7 @@ public class StackControllerTest extends BaseTest {
|
423
|
451
|
public void stackCanBePushed() {
|
424
|
452
|
StackController parent = createStackController("someStack");
|
425
|
453
|
parent.ensureViewIsCreated();
|
426
|
|
- parent.push(uut, new MockPromise());
|
|
454
|
+ parent.push(uut, new CommandListenerAdapter());
|
427
|
455
|
uut.onViewAppeared();
|
428
|
456
|
assertThat(parent.getView().getChildAt(1)).isEqualTo(uut.getView());
|
429
|
457
|
}
|
|
@@ -432,12 +460,12 @@ public class StackControllerTest extends BaseTest {
|
432
|
460
|
public void applyOptions_applyOnlyOnFirstStack() {
|
433
|
461
|
StackController parent = spy(createStackController("someStack"));
|
434
|
462
|
parent.ensureViewIsCreated();
|
435
|
|
- parent.push(uut, new MockPromise());
|
|
463
|
+ parent.push(uut, new CommandListenerAdapter());
|
436
|
464
|
|
437
|
465
|
Options childOptions = new Options();
|
438
|
466
|
childOptions.topBarOptions.title.text = new Text("Something");
|
439
|
467
|
child1.options = childOptions;
|
440
|
|
- uut.push(child1, new MockPromise());
|
|
468
|
+ uut.push(child1, new CommandListenerAdapter());
|
441
|
469
|
child1.ensureViewIsCreated();
|
442
|
470
|
child1.onViewAppeared();
|
443
|
471
|
|
|
@@ -450,7 +478,7 @@ public class StackControllerTest extends BaseTest {
|
450
|
478
|
@Test
|
451
|
479
|
public void applyOptions_topTabsAreNotVisibleIfNoTabsAreDefined() {
|
452
|
480
|
uut.ensureViewIsCreated();
|
453
|
|
- uut.push(child1, new MockPromise());
|
|
481
|
+ uut.push(child1, new CommandListenerAdapter());
|
454
|
482
|
child1.ensureViewIsCreated();
|
455
|
483
|
child1.onViewAppeared();
|
456
|
484
|
assertThat(ViewHelper.isVisible(uut.getTopBar().getTopTabs())).isFalse();
|
|
@@ -459,7 +487,7 @@ public class StackControllerTest extends BaseTest {
|
459
|
487
|
@Test
|
460
|
488
|
public void buttonPressInvokedOnCurrentStack() {
|
461
|
489
|
uut.ensureViewIsCreated();
|
462
|
|
- uut.push(child1, new MockPromise());
|
|
490
|
+ uut.push(child1, new CommandListenerAdapter());
|
463
|
491
|
uut.sendOnNavigationButtonPressed("btn1");
|
464
|
492
|
verify(child1, times(1)).sendOnNavigationButtonPressed("btn1");
|
465
|
493
|
}
|
|
@@ -467,14 +495,15 @@ public class StackControllerTest extends BaseTest {
|
467
|
495
|
@Test
|
468
|
496
|
public void mergeChildOptions_updatesViewWithNewOptions() {
|
469
|
497
|
final StackLayout[] stackLayout = new StackLayout[1];
|
470
|
|
- StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options()) {
|
471
|
|
- @NonNull
|
472
|
|
- @Override
|
473
|
|
- protected StackLayout createView() {
|
474
|
|
- stackLayout[0] = spy(super.createView());
|
475
|
|
- return stackLayout[0];
|
476
|
|
- }
|
477
|
|
- };
|
|
498
|
+ StackController uut =
|
|
499
|
+ new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options()) {
|
|
500
|
+ @NonNull
|
|
501
|
+ @Override
|
|
502
|
+ protected StackLayout createView() {
|
|
503
|
+ stackLayout[0] = spy(super.createView());
|
|
504
|
+ return stackLayout[0];
|
|
505
|
+ }
|
|
506
|
+ };
|
478
|
507
|
Options optionsToMerge = new Options();
|
479
|
508
|
Component component = mock(Component.class);
|
480
|
509
|
uut.mergeChildOptions(optionsToMerge, component);
|
|
@@ -484,14 +513,15 @@ public class StackControllerTest extends BaseTest {
|
484
|
513
|
@Test
|
485
|
514
|
public void mergeChildOptions_updatesParentControllerWithNewOptions() {
|
486
|
515
|
final StackLayout[] stackLayout = new StackLayout[1];
|
487
|
|
- StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options()) {
|
488
|
|
- @NonNull
|
489
|
|
- @Override
|
490
|
|
- protected StackLayout createView() {
|
491
|
|
- stackLayout[0] = spy(super.createView());
|
492
|
|
- return stackLayout[0];
|
493
|
|
- }
|
494
|
|
- };
|
|
516
|
+ StackController uut =
|
|
517
|
+ new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options()) {
|
|
518
|
+ @NonNull
|
|
519
|
+ @Override
|
|
520
|
+ protected StackLayout createView() {
|
|
521
|
+ stackLayout[0] = spy(super.createView());
|
|
522
|
+ return stackLayout[0];
|
|
523
|
+ }
|
|
524
|
+ };
|
495
|
525
|
ParentController parentController = Mockito.mock(ParentController.class);
|
496
|
526
|
uut.setParentController(parentController);
|
497
|
527
|
Options optionsToMerge = new Options();
|