|
@@ -4,6 +4,7 @@ import android.app.Activity;
|
4
|
4
|
import android.graphics.Color;
|
5
|
5
|
import android.view.Gravity;
|
6
|
6
|
import android.view.View;
|
|
7
|
+import android.view.ViewGroup.MarginLayoutParams;
|
7
|
8
|
|
8
|
9
|
import com.reactnativenavigation.BaseTest;
|
9
|
10
|
import com.reactnativenavigation.TestUtils;
|
|
@@ -27,6 +28,7 @@ import com.reactnativenavigation.viewcontrollers.ParentController;
|
27
|
28
|
import com.reactnativenavigation.viewcontrollers.ViewController;
|
28
|
29
|
import com.reactnativenavigation.viewcontrollers.stack.StackController;
|
29
|
30
|
import com.reactnativenavigation.views.BottomTabs;
|
|
31
|
+import com.reactnativenavigation.views.bottomtabs.BottomTabsLayout;
|
30
|
32
|
|
31
|
33
|
import org.junit.Test;
|
32
|
34
|
import org.mockito.ArgumentCaptor;
|
|
@@ -84,7 +86,7 @@ public class BottomTabsControllerTest extends BaseTest {
|
84
|
86
|
child1 = spy(new SimpleViewController(activity, childRegistry, "child1", tabOptions));
|
85
|
87
|
child2 = spy(new SimpleViewController(activity, childRegistry, "child2", tabOptions));
|
86
|
88
|
child3 = spy(new SimpleViewController(activity, childRegistry, "child3", tabOptions));
|
87
|
|
- child4 = spy(createStack("someStack"));
|
|
89
|
+ child4 = spy(createStack());
|
88
|
90
|
child5 = spy(new SimpleViewController(activity, childRegistry, "child5", tabOptions));
|
89
|
91
|
when(child5.handleBack(any())).thenReturn(true);
|
90
|
92
|
tabs = createTabs();
|
|
@@ -208,17 +210,34 @@ public class BottomTabsControllerTest extends BaseTest {
|
208
|
210
|
|
209
|
211
|
@Test
|
210
|
212
|
public void mergeOptions_drawBehind() {
|
211
|
|
- assertThat(uut.getBottomInset()).isEqualTo(uut.getBottomTabs().getHeight());
|
|
213
|
+ assertThat(uut.getBottomInset(child1)).isEqualTo(uut.getBottomTabs().getHeight());
|
212
|
214
|
|
213
|
215
|
Options o1 = new Options();
|
214
|
216
|
o1.bottomTabsOptions.drawBehind = new Bool(true);
|
215
|
217
|
child1.mergeOptions(o1);
|
216
|
|
- assertThat(uut.getBottomInset()).isEqualTo(0);
|
|
218
|
+ assertThat(uut.getBottomInset(child1)).isEqualTo(0);
|
217
|
219
|
|
218
|
220
|
Options o2 = new Options();
|
219
|
221
|
o2.topBar.title.text = new Text("Some text");
|
220
|
222
|
child1.mergeOptions(o1);
|
221
|
|
- assertThat(uut.getBottomInset()).isEqualTo(0);
|
|
223
|
+ assertThat(uut.getBottomInset(child1)).isEqualTo(0);
|
|
224
|
+ }
|
|
225
|
+
|
|
226
|
+ @Test
|
|
227
|
+ public void mergeOptions_drawBehind_stack() {
|
|
228
|
+ uut.selectTab(3);
|
|
229
|
+
|
|
230
|
+ SimpleViewController stackChild = new SimpleViewController(activity, childRegistry, "stackChild", new Options());
|
|
231
|
+ disablePushAnimation(stackChild);
|
|
232
|
+ child4.push(stackChild, new CommandListenerAdapter());
|
|
233
|
+
|
|
234
|
+ assertThat(((MarginLayoutParams) stackChild.getView().getLayoutParams()).bottomMargin).isEqualTo(bottomTabs.getHeight());
|
|
235
|
+
|
|
236
|
+ Options o1 = new Options();
|
|
237
|
+ o1.bottomTabsOptions.drawBehind = new Bool(true);
|
|
238
|
+ stackChild.mergeOptions(o1);
|
|
239
|
+
|
|
240
|
+ assertThat(((MarginLayoutParams) stackChild.getView().getLayoutParams()).bottomMargin).isEqualTo(0);
|
222
|
241
|
}
|
223
|
242
|
|
224
|
243
|
@Test
|
|
@@ -369,9 +388,9 @@ public class BottomTabsControllerTest extends BaseTest {
|
369
|
388
|
return Arrays.asList(child1, child2, child3, child4, child5);
|
370
|
389
|
}
|
371
|
390
|
|
372
|
|
- private StackController createStack(String id) {
|
|
391
|
+ private StackController createStack() {
|
373
|
392
|
return TestUtils.newStackController(activity)
|
374
|
|
- .setId(id)
|
|
393
|
+ .setId("someStack")
|
375
|
394
|
.setInitialOptions(tabOptions)
|
376
|
395
|
.build();
|
377
|
396
|
}
|
|
@@ -401,6 +420,14 @@ public class BottomTabsControllerTest extends BaseTest {
|
401
|
420
|
uut.getView().layout(0, 0, 1000, 1000);
|
402
|
421
|
}
|
403
|
422
|
|
|
423
|
+ @NonNull
|
|
424
|
+ @Override
|
|
425
|
+ protected BottomTabsLayout createView() {
|
|
426
|
+ BottomTabsLayout view = super.createView();
|
|
427
|
+ bottomTabs.getLayoutParams().height = 100;
|
|
428
|
+ return view;
|
|
429
|
+ }
|
|
430
|
+
|
404
|
431
|
@NonNull
|
405
|
432
|
@Override
|
406
|
433
|
protected BottomTabs createBottomTabs() {
|