|
@@ -1,22 +1,34 @@
|
1
|
1
|
package com.reactnativenavigation.viewcontrollers;
|
2
|
2
|
|
3
|
|
-import android.app.*;
|
4
|
|
-import android.support.v7.widget.*;
|
5
|
|
-import android.view.*;
|
6
|
|
-
|
7
|
|
-import com.reactnativenavigation.*;
|
8
|
|
-import com.reactnativenavigation.parse.params.*;
|
9
|
|
-import com.reactnativenavigation.react.*;
|
10
|
|
-import com.reactnativenavigation.utils.*;
|
11
|
|
-import com.reactnativenavigation.views.titlebar.*;
|
12
|
|
-
|
13
|
|
-import org.junit.*;
|
14
|
|
-
|
15
|
|
-import java.util.*;
|
16
|
|
-
|
17
|
|
-import static com.reactnativenavigation.utils.TitleBarHelper.*;
|
18
|
|
-import static org.assertj.core.api.Java6Assertions.*;
|
19
|
|
-import static org.mockito.Mockito.*;
|
|
3
|
+import android.app.Activity;
|
|
4
|
+import android.support.v7.widget.ActionMenuView;
|
|
5
|
+import android.view.View;
|
|
6
|
+import android.widget.TextView;
|
|
7
|
+
|
|
8
|
+import com.reactnativenavigation.BaseTest;
|
|
9
|
+import com.reactnativenavigation.parse.params.Button;
|
|
10
|
+import com.reactnativenavigation.parse.params.Text;
|
|
11
|
+import com.reactnativenavigation.react.Constants;
|
|
12
|
+import com.reactnativenavigation.react.ReactView;
|
|
13
|
+import com.reactnativenavigation.utils.CollectionUtils;
|
|
14
|
+import com.reactnativenavigation.views.titlebar.TitleBar;
|
|
15
|
+
|
|
16
|
+import org.junit.Test;
|
|
17
|
+import org.mockito.Mockito;
|
|
18
|
+
|
|
19
|
+import java.util.ArrayList;
|
|
20
|
+import java.util.Arrays;
|
|
21
|
+import java.util.Collections;
|
|
22
|
+import java.util.List;
|
|
23
|
+
|
|
24
|
+import static com.reactnativenavigation.utils.TitleBarHelper.createButtonController;
|
|
25
|
+import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
26
|
+import static org.mockito.Mockito.any;
|
|
27
|
+import static org.mockito.Mockito.eq;
|
|
28
|
+import static org.mockito.Mockito.mock;
|
|
29
|
+import static org.mockito.Mockito.spy;
|
|
30
|
+import static org.mockito.Mockito.verify;
|
|
31
|
+import static org.mockito.Mockito.when;
|
20
|
32
|
|
21
|
33
|
public class TitleBarTest extends BaseTest {
|
22
|
34
|
|
|
@@ -82,6 +94,18 @@ public class TitleBarTest extends BaseTest {
|
82
|
94
|
assertThat(uut.getNavigationIcon()).isNull();
|
83
|
95
|
}
|
84
|
96
|
|
|
97
|
+ @Test
|
|
98
|
+ public void setLeftButton_titleIsAligned() {
|
|
99
|
+ uut.setTitle("Title");
|
|
100
|
+ TextView title = new TextView(activity);
|
|
101
|
+ uut.addView(title);
|
|
102
|
+ when(uut.findTitleTextView()).thenReturn(title);
|
|
103
|
+
|
|
104
|
+ uut.setLeftButtons(Collections.singletonList(Mockito.mock(TitleBarButtonController.class)));
|
|
105
|
+ dispatchPreDraw(title);
|
|
106
|
+ verify(uut).alignTextView(any(), eq(title));
|
|
107
|
+ }
|
|
108
|
+
|
85
|
109
|
@Test
|
86
|
110
|
public void setRightButtons_buttonsAreAddedInReverseOrderToMatchOrderOnIOs() {
|
87
|
111
|
uut.setLeftButtons(new ArrayList<>());
|