|
@@ -1,6 +1,8 @@
|
1
|
1
|
package com.reactnativenavigation.viewcontrollers;
|
2
|
2
|
|
3
|
3
|
import android.app.Activity;
|
|
4
|
+import android.support.v7.widget.Toolbar;
|
|
5
|
+import android.view.Gravity;
|
4
|
6
|
import android.view.ViewGroup;
|
5
|
7
|
|
6
|
8
|
import com.reactnativenavigation.BaseTest;
|
|
@@ -14,6 +16,7 @@ import com.reactnativenavigation.views.titlebar.TitleBar;
|
14
|
16
|
import com.reactnativenavigation.views.titlebar.TitleBarReactView;
|
15
|
17
|
|
16
|
18
|
import org.junit.Test;
|
|
19
|
+import org.mockito.ArgumentCaptor;
|
17
|
20
|
|
18
|
21
|
import java.util.ArrayList;
|
19
|
22
|
import java.util.Arrays;
|
|
@@ -24,7 +27,6 @@ import java.util.Map;
|
24
|
27
|
|
25
|
28
|
import static org.assertj.core.api.Java6Assertions.assertThat;
|
26
|
29
|
import static org.mockito.ArgumentMatchers.any;
|
27
|
|
-import static org.mockito.ArgumentMatchers.eq;
|
28
|
30
|
import static org.mockito.Mockito.spy;
|
29
|
31
|
import static org.mockito.Mockito.times;
|
30
|
32
|
import static org.mockito.Mockito.verify;
|
|
@@ -128,10 +130,28 @@ public class TitleBarTest extends BaseTest {
|
128
|
130
|
}
|
129
|
131
|
|
130
|
132
|
@Test
|
131
|
|
- public void setComponent_addsComponentToTitleBar() {
|
|
133
|
+ public void setComponent_addsComponentToTitleBar() throws Exception {
|
132
|
134
|
uut.setComponent("com.rnn.CustomView", TitleOptions.Alignment.Center);
|
133
|
|
- final int height = uut.getHeight();
|
134
|
|
- verify(uut, times(1)).addView(any(TitleBarReactView.class), eq(ViewGroup.LayoutParams.WRAP_CONTENT), eq(height));
|
|
135
|
+ verify(uut, times(1)).addView(any(TitleBarReactView.class));
|
|
136
|
+ }
|
|
137
|
+
|
|
138
|
+ @Test
|
|
139
|
+ public void setComponent_alignFill() throws Exception {
|
|
140
|
+ uut.setComponent("com.rnn.CustomView", TitleOptions.Alignment.Fill);
|
|
141
|
+ verify(uut, times(1)).getComponentLayoutParams(TitleOptions.Alignment.Fill);
|
|
142
|
+ ArgumentCaptor<Toolbar.LayoutParams> lpCaptor = ArgumentCaptor.forClass(Toolbar.LayoutParams.class);
|
|
143
|
+ verify(uut, times(1)).addView(any(TitleBarReactView.class), lpCaptor.capture());
|
|
144
|
+ assertThat(lpCaptor.getValue().width == ViewGroup.LayoutParams.MATCH_PARENT);
|
|
145
|
+ }
|
|
146
|
+
|
|
147
|
+ @Test
|
|
148
|
+ public void setComponent_alignCenter() throws Exception {
|
|
149
|
+ uut.setComponent("com.rnn.CustomView", TitleOptions.Alignment.Center);
|
|
150
|
+ verify(uut, times(1)).getComponentLayoutParams(TitleOptions.Alignment.Center);
|
|
151
|
+ ArgumentCaptor<Toolbar.LayoutParams> lpCaptor = ArgumentCaptor.forClass(Toolbar.LayoutParams.class);
|
|
152
|
+ verify(uut, times(1)).addView(any(TitleBarReactView.class), lpCaptor.capture());
|
|
153
|
+ assertThat(lpCaptor.getValue().width == ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
154
|
+ assertThat(lpCaptor.getValue().gravity == Gravity.CENTER);
|
135
|
155
|
}
|
136
|
156
|
|
137
|
157
|
private List<Button> leftButton(Button leftButton) {
|