|
@@ -11,8 +11,6 @@ import com.reactnativenavigation.BaseTest;
|
11
|
11
|
import com.reactnativenavigation.TestUtils;
|
12
|
12
|
import com.reactnativenavigation.mocks.ImageLoaderMock;
|
13
|
13
|
import com.reactnativenavigation.mocks.SimpleViewController;
|
14
|
|
-import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
|
15
|
|
-import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
|
16
|
14
|
import com.reactnativenavigation.parse.Options;
|
17
|
15
|
import com.reactnativenavigation.parse.params.Bool;
|
18
|
16
|
import com.reactnativenavigation.parse.params.Colour;
|
|
@@ -21,7 +19,6 @@ import com.reactnativenavigation.parse.params.Text;
|
21
|
19
|
import com.reactnativenavigation.presentation.BottomTabOptionsPresenter;
|
22
|
20
|
import com.reactnativenavigation.presentation.BottomTabsOptionsPresenter;
|
23
|
21
|
import com.reactnativenavigation.presentation.OptionsPresenter;
|
24
|
|
-import com.reactnativenavigation.presentation.StackOptionsPresenter;
|
25
|
22
|
import com.reactnativenavigation.react.EventEmitter;
|
26
|
23
|
import com.reactnativenavigation.utils.CommandListenerAdapter;
|
27
|
24
|
import com.reactnativenavigation.utils.ImageLoader;
|
|
@@ -36,9 +33,12 @@ import org.junit.Test;
|
36
|
33
|
import org.mockito.ArgumentCaptor;
|
37
|
34
|
import org.mockito.Mockito;
|
38
|
35
|
|
|
36
|
+import java.util.ArrayList;
|
39
|
37
|
import java.util.Arrays;
|
40
|
38
|
import java.util.List;
|
41
|
39
|
|
|
40
|
+import edu.emory.mathcs.backport.java.util.Collections;
|
|
41
|
+
|
42
|
42
|
import static com.reactnativenavigation.TestUtils.hideBackButton;
|
43
|
43
|
import static org.assertj.core.api.Java6Assertions.assertThat;
|
44
|
44
|
import static org.mockito.ArgumentMatchers.any;
|
|
@@ -211,6 +211,37 @@ public class BottomTabsControllerTest extends BaseTest {
|
211
|
211
|
assertThat(childLayoutParams(0).bottomMargin).isEqualTo(0);
|
212
|
212
|
}
|
213
|
213
|
|
|
214
|
+ @Test
|
|
215
|
+ public void applyChildOptions_resolvedOptionsAreUsed() {
|
|
216
|
+ Options childOptions = new Options();
|
|
217
|
+ SimpleViewController pushedScreen = new SimpleViewController(activity, childRegistry, "child4.1", childOptions);
|
|
218
|
+ disablePushAnimation(pushedScreen);
|
|
219
|
+ child4 = createStack(pushedScreen);
|
|
220
|
+
|
|
221
|
+ tabs = new ArrayList<>(Collections.singletonList(child4));
|
|
222
|
+
|
|
223
|
+ initialOptions.bottomTabsOptions.currentTabIndex = new Number(3);
|
|
224
|
+ Options resolvedOptions = new Options();
|
|
225
|
+ uut = new BottomTabsController(activity,
|
|
226
|
+ tabs,
|
|
227
|
+ childRegistry,
|
|
228
|
+ eventEmitter,
|
|
229
|
+ imageLoaderMock,
|
|
230
|
+ "uut",
|
|
231
|
+ initialOptions,
|
|
232
|
+ new OptionsPresenter(activity, new Options()),
|
|
233
|
+ presenter,
|
|
234
|
+ new BottomTabOptionsPresenter(activity, tabs, new Options())) {
|
|
235
|
+ @Override
|
|
236
|
+ public Options resolveCurrentOptions() {
|
|
237
|
+ return resolvedOptions;
|
|
238
|
+ }
|
|
239
|
+ };
|
|
240
|
+
|
|
241
|
+ activity.setContentView(uut.getView());
|
|
242
|
+ verify(presenter, times(2)).applyChildOptions(eq(resolvedOptions), any());
|
|
243
|
+ }
|
|
244
|
+
|
214
|
245
|
@Test
|
215
|
246
|
public void child_mergeOptions_currentTabIndex() {
|
216
|
247
|
uut.ensureViewIsCreated();
|
|
@@ -285,7 +316,13 @@ public class BottomTabsControllerTest extends BaseTest {
|
285
|
316
|
return TestUtils.newStackController(activity)
|
286
|
317
|
.setId(id)
|
287
|
318
|
.setInitialOptions(tabOptions)
|
288
|
|
- .setStackPresenter(new StackOptionsPresenter(activity, new TitleBarReactViewCreatorMock(), new TopBarButtonCreatorMock(), new ImageLoader(), new Options()))
|
|
319
|
+ .build();
|
|
320
|
+ }
|
|
321
|
+
|
|
322
|
+ private StackController createStack(ViewController initialChild) {
|
|
323
|
+ return TestUtils.newStackController(activity)
|
|
324
|
+ .setInitialOptions(tabOptions)
|
|
325
|
+ .setChildren(new ArrayList<>(Collections.singleton(initialChild)))
|
289
|
326
|
.build();
|
290
|
327
|
}
|
291
|
328
|
|
|
@@ -293,7 +330,7 @@ public class BottomTabsControllerTest extends BaseTest {
|
293
|
330
|
return (ViewGroup.MarginLayoutParams) tabs.get(index).getView().getLayoutParams();
|
294
|
331
|
}
|
295
|
332
|
|
296
|
|
- public BottomTabsController createBottomTabs() {
|
|
333
|
+ private BottomTabsController createBottomTabs() {
|
297
|
334
|
return new BottomTabsController(activity,
|
298
|
335
|
tabs,
|
299
|
336
|
childRegistry,
|