|
@@ -2,6 +2,7 @@ package com.reactnativenavigation.viewcontrollers;
|
2
|
2
|
|
3
|
3
|
import android.app.Activity;
|
4
|
4
|
import android.support.annotation.NonNull;
|
|
5
|
+import android.view.ViewGroup;
|
5
|
6
|
import android.widget.RelativeLayout;
|
6
|
7
|
|
7
|
8
|
import com.reactnativenavigation.BaseTest;
|
|
@@ -11,8 +12,10 @@ import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
|
11
|
12
|
import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
|
12
|
13
|
import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
|
13
|
14
|
import com.reactnativenavigation.parse.Options;
|
|
15
|
+import com.reactnativenavigation.parse.params.Bool;
|
14
|
16
|
import com.reactnativenavigation.parse.params.Color;
|
15
|
17
|
import com.reactnativenavigation.parse.params.Number;
|
|
18
|
+import com.reactnativenavigation.parse.params.Text;
|
16
|
19
|
import com.reactnativenavigation.react.EventEmitter;
|
17
|
20
|
import com.reactnativenavigation.utils.CommandListenerAdapter;
|
18
|
21
|
import com.reactnativenavigation.utils.ImageLoader;
|
|
@@ -51,18 +54,27 @@ public class BottomTabsControllerTest extends BaseTest {
|
51
|
54
|
private ImageLoader imageLoaderMock = ImageLoaderMock.mock();
|
52
|
55
|
private EventEmitter eventEmitter;
|
53
|
56
|
private ChildControllersRegistry childRegistry;
|
|
57
|
+ private List<ViewController> tabs;
|
54
|
58
|
|
55
|
59
|
@Override
|
56
|
60
|
public void beforeEach() {
|
57
|
61
|
activity = newActivity();
|
58
|
62
|
childRegistry = new ChildControllersRegistry();
|
59
|
63
|
eventEmitter = Mockito.mock(EventEmitter.class);
|
60
|
|
- uut = spy(new BottomTabsController(activity, childRegistry, eventEmitter, imageLoaderMock, "uut", new Options()));
|
|
64
|
+ uut = spy(new BottomTabsController(activity, childRegistry, eventEmitter, imageLoaderMock, "uut", new Options()) {
|
|
65
|
+ @Override
|
|
66
|
+ public void ensureViewIsCreated() {
|
|
67
|
+ super.ensureViewIsCreated();
|
|
68
|
+ uut.getView().layout(0, 0, 1000, 1000);
|
|
69
|
+ uut.getBottomTabs().layout(0, 0, 1000, 100);
|
|
70
|
+ }
|
|
71
|
+ });
|
61
|
72
|
child1 = spy(new SimpleViewController(activity, childRegistry, "child1", tabOptions));
|
62
|
73
|
child2 = spy(new SimpleViewController(activity, childRegistry, "child2", tabOptions));
|
63
|
74
|
child3 = spy(new SimpleViewController(activity, childRegistry, "child3", tabOptions));
|
64
|
75
|
child4 = spy(new SimpleViewController(activity, childRegistry, "child4", tabOptions));
|
65
|
76
|
child5 = spy(new SimpleViewController(activity, childRegistry, "child5", tabOptions));
|
|
77
|
+ tabs = createTabs();
|
66
|
78
|
}
|
67
|
79
|
|
68
|
80
|
@Test
|
|
@@ -169,7 +181,6 @@ public class BottomTabsControllerTest extends BaseTest {
|
169
|
181
|
|
170
|
182
|
@Test
|
171
|
183
|
public void mergeOptions_currentTabIndex() {
|
172
|
|
- List<ViewController> tabs = createTabs();
|
173
|
184
|
uut.setTabs(tabs);
|
174
|
185
|
uut.ensureViewIsCreated();
|
175
|
186
|
|
|
@@ -180,6 +191,27 @@ public class BottomTabsControllerTest extends BaseTest {
|
180
|
191
|
verify(eventEmitter, times(0)).emitBottomTabSelected(any(Integer.class), any(Integer.class));
|
181
|
192
|
}
|
182
|
193
|
|
|
194
|
+ @Test
|
|
195
|
+ public void mergeOptions_drawBehind() {
|
|
196
|
+ List<ViewController> tabs = createTabs();
|
|
197
|
+ uut.setTabs(tabs);
|
|
198
|
+ uut.ensureViewIsCreated();
|
|
199
|
+ child1.onViewAppeared();
|
|
200
|
+ uut.selectTab(0);
|
|
201
|
+
|
|
202
|
+ assertThat(childLayoutParams(0).bottomMargin).isEqualTo(uut.getBottomTabs().getHeight());
|
|
203
|
+
|
|
204
|
+ Options o1 = new Options();
|
|
205
|
+ o1.bottomTabsOptions.drawBehind = new Bool(true);
|
|
206
|
+ child1.mergeOptions(o1);
|
|
207
|
+ assertThat(childLayoutParams(0).bottomMargin).isEqualTo(0);
|
|
208
|
+
|
|
209
|
+ Options o2 = new Options();
|
|
210
|
+ o2.topBar.title.text = new Text("Some text");
|
|
211
|
+ child1.mergeOptions(o1);
|
|
212
|
+ assertThat(childLayoutParams(0).bottomMargin).isEqualTo(0);
|
|
213
|
+ }
|
|
214
|
+
|
183
|
215
|
@Test
|
184
|
216
|
public void child_mergeOptions_currentTabIndex() {
|
185
|
217
|
List<ViewController> tabs = createTabs();
|
|
@@ -220,4 +252,8 @@ public class BottomTabsControllerTest extends BaseTest {
|
220
|
252
|
.setInitialOptions(tabOptions)
|
221
|
253
|
.createStackController();
|
222
|
254
|
}
|
|
255
|
+
|
|
256
|
+ private ViewGroup.MarginLayoutParams childLayoutParams(int index) {
|
|
257
|
+ return (ViewGroup.MarginLayoutParams) tabs.get(index).getView().getLayoutParams();
|
|
258
|
+ }
|
223
|
259
|
}
|