|
@@ -0,0 +1,53 @@
|
|
1
|
+package com.reactnativenavigation.viewcontrollers;
|
|
2
|
+
|
|
3
|
+import android.content.Context;
|
|
4
|
+import android.support.annotation.NonNull;
|
|
5
|
+
|
|
6
|
+import com.reactnativenavigation.BaseTest;
|
|
7
|
+import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
|
|
8
|
+import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
|
|
9
|
+import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
|
|
10
|
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
|
|
11
|
+import com.reactnativenavigation.views.StackLayout;
|
|
12
|
+import com.reactnativenavigation.views.titlebar.TitleBar;
|
|
13
|
+import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
|
|
14
|
+import com.reactnativenavigation.views.topbar.TopBar;
|
|
15
|
+import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
|
|
16
|
+
|
|
17
|
+import org.junit.Test;
|
|
18
|
+import org.mockito.Mockito;
|
|
19
|
+
|
|
20
|
+import static org.mockito.Mockito.spy;
|
|
21
|
+import static org.mockito.Mockito.times;
|
|
22
|
+import static org.mockito.Mockito.verify;
|
|
23
|
+
|
|
24
|
+public class TopBarControllerTest extends BaseTest {
|
|
25
|
+
|
|
26
|
+ private TopBarController uut;
|
|
27
|
+
|
|
28
|
+ @Override
|
|
29
|
+ public void beforeEach() {
|
|
30
|
+ uut = new TopBarController();
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ @Test
|
|
34
|
+ public void clear() {
|
|
35
|
+ final TitleBar[] titleBar = new TitleBar[1];
|
|
36
|
+ uut = new TopBarController() {
|
|
37
|
+ @NonNull
|
|
38
|
+ @Override
|
|
39
|
+ protected TopBar createTopBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator backgroundViewCreator, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout) {
|
|
40
|
+ return new TopBar(context, buttonCreator, titleBarReactViewCreator, backgroundViewCreator, topBarButtonClickListener, stackLayout) {
|
|
41
|
+ @Override
|
|
42
|
+ protected TitleBar createTitleBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator reactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
|
|
43
|
+ titleBar[0] = spy(super.createTitleBar(context, buttonCreator, reactViewCreator, onClickListener));
|
|
44
|
+ return titleBar[0];
|
|
45
|
+ }
|
|
46
|
+ };
|
|
47
|
+ }
|
|
48
|
+ };
|
|
49
|
+ uut.createView(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), buttonId -> { }, Mockito.mock(StackLayout.class));
|
|
50
|
+ uut.clear();
|
|
51
|
+ verify(titleBar[0], times(1)).clear();
|
|
52
|
+ }
|
|
53
|
+}
|