Browse Source

Initial TopBar refactor

Guy Carmeli 6 years ago
parent
commit
6d25438628
17 changed files with 203 additions and 132 deletions
  1. 4
    2
      lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java
  2. 12
    3
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java
  3. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java
  4. 42
    0
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/topbar/TopBarController.java
  5. 9
    14
      lib/android/app/src/main/java/com/reactnativenavigation/views/StackLayout.java
  6. 12
    11
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java
  7. 7
    6
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ComponentViewControllerTest.java
  8. 7
    6
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/FloatingActionButtonTest.java
  9. 24
    22
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java
  10. 12
    11
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java
  11. 11
    10
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java
  12. 16
    5
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java
  13. 4
    3
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopBarButtonControllerTest.java
  14. 12
    11
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java
  15. 18
    17
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java
  16. 5
    4
      lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarBackgroundComponentTest.java
  17. 6
    5
      lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java

+ 4
- 2
lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java View File

13
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
13
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
14
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentCreator;
14
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentCreator;
15
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController;
15
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController;
16
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
16
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
17
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
17
 import com.reactnativenavigation.views.ComponentViewCreator;
18
 import com.reactnativenavigation.views.ComponentViewCreator;
18
-import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
19
 import com.reactnativenavigation.views.titlebar.TitleBarButtonCreator;
19
 import com.reactnativenavigation.views.titlebar.TitleBarButtonCreator;
20
-import com.reactnativenavigation.views.toptabs.TopTabsLayoutCreator;
20
+import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
21
 import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
21
 import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
22
+import com.reactnativenavigation.views.toptabs.TopTabsLayoutCreator;
22
 
23
 
23
 import java.util.ArrayList;
24
 import java.util.ArrayList;
24
 import java.util.List;
25
 import java.util.List;
124
                 new TitleBarButtonCreator(reactInstanceManager),
125
                 new TitleBarButtonCreator(reactInstanceManager),
125
                 new TitleBarReactViewCreator(reactInstanceManager),
126
                 new TitleBarReactViewCreator(reactInstanceManager),
126
                 new TopBarBackgroundViewCreator(reactInstanceManager),
127
                 new TopBarBackgroundViewCreator(reactInstanceManager),
128
+                new TopBarController(),
127
                 node.id,
129
                 node.id,
128
                 getOptions(node)
130
                 getOptions(node)
129
         );
131
         );

+ 12
- 3
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java View File

10
 import com.reactnativenavigation.anim.NavigationAnimator;
10
 import com.reactnativenavigation.anim.NavigationAnimator;
11
 import com.reactnativenavigation.parse.Options;
11
 import com.reactnativenavigation.parse.Options;
12
 import com.reactnativenavigation.utils.NoOpPromise;
12
 import com.reactnativenavigation.utils.NoOpPromise;
13
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
13
 import com.reactnativenavigation.views.Component;
14
 import com.reactnativenavigation.views.Component;
14
 import com.reactnativenavigation.views.ReactComponent;
15
 import com.reactnativenavigation.views.ReactComponent;
15
 import com.reactnativenavigation.views.StackLayout;
16
 import com.reactnativenavigation.views.StackLayout;
30
     private final ReactViewCreator topBarButtonCreator;
31
     private final ReactViewCreator topBarButtonCreator;
31
     private final TitleBarReactViewCreator titleBarReactViewCreator;
32
     private final TitleBarReactViewCreator titleBarReactViewCreator;
32
     private TopBarBackgroundViewCreator topBarBackgroundViewCreator;
33
     private TopBarBackgroundViewCreator topBarBackgroundViewCreator;
34
+    private TopBarController topBarController;
33
 
35
 
34
-    public StackController(final Activity activity, ReactViewCreator topBarButtonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator topBarBackgroundViewCreator, String id, Options initialOptions) {
36
+    public StackController(final Activity activity, ReactViewCreator topBarButtonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator topBarBackgroundViewCreator, TopBarController topBarController, String id, Options initialOptions) {
35
         super(activity, id, initialOptions);
37
         super(activity, id, initialOptions);
38
+        this.topBarController = topBarController;
36
         animator = createAnimator();
39
         animator = createAnimator();
37
         this.topBarButtonCreator = topBarButtonCreator;
40
         this.topBarButtonCreator = topBarButtonCreator;
38
         this.titleBarReactViewCreator = titleBarReactViewCreator;
41
         this.titleBarReactViewCreator = titleBarReactViewCreator;
76
         );
79
         );
77
     }
80
     }
78
 
81
 
82
+    @Override
83
+    public void destroy() {
84
+        topBarController.clear();
85
+        super.destroy();
86
+    }
87
+
79
     @Override
88
     @Override
80
     void clearOptions() {
89
     void clearOptions() {
81
         super.clearOptions();
90
         super.clearOptions();
82
-        getView().clearOptions();
91
+        topBarController.clear();
83
     }
92
     }
84
 
93
 
85
     public void push(ViewController child, final Promise promise) {
94
     public void push(ViewController child, final Promise promise) {
229
     @NonNull
238
     @NonNull
230
     @Override
239
     @Override
231
     protected StackLayout createView() {
240
     protected StackLayout createView() {
232
-        return new StackLayout(getActivity(), topBarButtonCreator, titleBarReactViewCreator, topBarBackgroundViewCreator, this::sendOnNavigationButtonPressed, getId());
241
+        return new StackLayout(getActivity(), topBarButtonCreator, titleBarReactViewCreator, topBarBackgroundViewCreator, topBarController, this::sendOnNavigationButtonPressed, getId());
233
     }
242
     }
234
 
243
 
235
     @NonNull
244
     @NonNull

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java View File

112
                 throw new RuntimeException("Tried to create view after it has already been destroyed");
112
                 throw new RuntimeException("Tried to create view after it has already been destroyed");
113
             }
113
             }
114
             view = createView();
114
             view = createView();
115
-            if (view.getId() < 0) {
115
+            if (view.getId() != 0) {
116
                 view.setId(CompatUtils.generateViewId());
116
                 view.setId(CompatUtils.generateViewId());
117
             }
117
             }
118
             view.getViewTreeObserver().addOnGlobalLayoutListener(this);
118
             view.getViewTreeObserver().addOnGlobalLayoutListener(this);
200
         }
200
         }
201
     }
201
     }
202
 
202
 
203
-    public void runOnPreDraw(Task<T> task) {
203
+    void runOnPreDraw(Task<T> task) {
204
         UiUtils.runOnPreDrawOnce(getView(), () -> task.run(getView()));
204
         UiUtils.runOnPreDrawOnce(getView(), () -> task.run(getView()));
205
     }
205
     }
206
 
206
 

+ 42
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/topbar/TopBarController.java View File

1
+package com.reactnativenavigation.viewcontrollers.topbar;
2
+
3
+import android.content.Context;
4
+import android.support.v4.view.ViewPager;
5
+import android.view.View;
6
+
7
+import com.reactnativenavigation.utils.CompatUtils;
8
+import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
9
+import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
10
+import com.reactnativenavigation.views.StackLayout;
11
+import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
12
+import com.reactnativenavigation.views.topbar.TopBar;
13
+import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
14
+
15
+
16
+public class TopBarController {
17
+    private TopBar topBar;
18
+
19
+    public View createTopBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator backgroundViewCreator, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout) {
20
+        if (topBar == null) {
21
+            topBar = new TopBar(context, buttonCreator, titleBarReactViewCreator, backgroundViewCreator, topBarButtonClickListener, stackLayout);
22
+            topBar.setId(CompatUtils.generateViewId());
23
+        }
24
+        return topBar;
25
+    }
26
+
27
+    public void clear() {
28
+        topBar.clear();
29
+    }
30
+
31
+    public TopBar getTopBar() {
32
+        return topBar;
33
+    }
34
+
35
+    public void initTopTabs(ViewPager viewPager) {
36
+        topBar.initTopTabs(viewPager);
37
+    }
38
+
39
+    public void clearTopTabs() {
40
+        topBar.clearTopTabs();
41
+    }
42
+}

+ 9
- 14
lib/android/app/src/main/java/com/reactnativenavigation/views/StackLayout.java View File

9
 import com.reactnativenavigation.interfaces.ChildDisappearListener;
9
 import com.reactnativenavigation.interfaces.ChildDisappearListener;
10
 import com.reactnativenavigation.parse.Options;
10
 import com.reactnativenavigation.parse.Options;
11
 import com.reactnativenavigation.presentation.OptionsPresenter;
11
 import com.reactnativenavigation.presentation.OptionsPresenter;
12
-import com.reactnativenavigation.utils.CompatUtils;
13
 import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
12
 import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
14
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
13
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
14
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
15
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
15
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
16
 import com.reactnativenavigation.views.topbar.TopBar;
16
 import com.reactnativenavigation.views.topbar.TopBar;
17
 import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
17
 import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
21
 
21
 
22
 @SuppressLint("ViewConstructor")
22
 @SuppressLint("ViewConstructor")
23
 public class StackLayout extends RelativeLayout {
23
 public class StackLayout extends RelativeLayout {
24
-    private TopBar topBar;
24
+    private TopBarController topBarController;
25
     private String stackId;
25
     private String stackId;
26
     private final OptionsPresenter optionsPresenter;
26
     private final OptionsPresenter optionsPresenter;
27
 
27
 
28
-    public StackLayout(Context context, ReactViewCreator topBarButtonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator topBarBackgroundViewCreator, TopBarButtonController.OnClickListener topBarButtonClickListener, String stackId) {
28
+    public StackLayout(Context context, ReactViewCreator topBarButtonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator topBarBackgroundViewCreator, TopBarController topBarController, TopBarButtonController.OnClickListener topBarButtonClickListener, String stackId) {
29
         super(context);
29
         super(context);
30
+        this.topBarController = topBarController;
30
         this.stackId = stackId;
31
         this.stackId = stackId;
31
         createLayout(topBarButtonCreator, titleBarReactViewCreator, topBarBackgroundViewCreator, topBarButtonClickListener);
32
         createLayout(topBarButtonCreator, titleBarReactViewCreator, topBarBackgroundViewCreator, topBarButtonClickListener);
32
-        optionsPresenter = new OptionsPresenter(topBar);
33
+        optionsPresenter = new OptionsPresenter(topBarController.getTopBar());
33
         setContentDescription("StackLayout");
34
         setContentDescription("StackLayout");
34
     }
35
     }
35
 
36
 
36
     private void createLayout(ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator BackgroundViewCreator, TopBarButtonController.OnClickListener topBarButtonClickListener) {
37
     private void createLayout(ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator BackgroundViewCreator, TopBarButtonController.OnClickListener topBarButtonClickListener) {
37
-        topBar = new TopBar(getContext(), buttonCreator, titleBarReactViewCreator, BackgroundViewCreator, topBarButtonClickListener, this);
38
-        topBar.setId(CompatUtils.generateViewId());
39
-        addView(topBar, MATCH_PARENT, WRAP_CONTENT);
38
+        addView(topBarController.createTopBar(getContext(), buttonCreator, titleBarReactViewCreator, BackgroundViewCreator, topBarButtonClickListener, this), MATCH_PARENT, WRAP_CONTENT);
40
     }
39
     }
41
 
40
 
42
     public void applyChildOptions(Options options) {
41
     public void applyChildOptions(Options options) {
51
         optionsPresenter.onChildWillDisappear(disappearing, appearing, childDisappearListener);
50
         optionsPresenter.onChildWillDisappear(disappearing, appearing, childDisappearListener);
52
     }
51
     }
53
 
52
 
54
-    public void clearOptions() {
55
-        topBar.clear();
56
-    }
57
-
58
     public void initTopTabs(ViewPager viewPager) {
53
     public void initTopTabs(ViewPager viewPager) {
59
-        topBar.initTopTabs(viewPager);
54
+        topBarController.initTopTabs(viewPager);
60
     }
55
     }
61
 
56
 
62
     public void clearTopTabs() {
57
     public void clearTopTabs() {
63
-        topBar.clearTopTabs();
58
+        topBarController.clearTopTabs();
64
     }
59
     }
65
 
60
 
66
     @RestrictTo(RestrictTo.Scope.TESTS)
61
     @RestrictTo(RestrictTo.Scope.TESTS)
67
     public TopBar getTopBar() {
62
     public TopBar getTopBar() {
68
-        return topBar;
63
+        return topBarController.getTopBar();
69
     }
64
     }
70
 
65
 
71
     public void mergeChildOptions(Options options, Component child) {
66
     public void mergeChildOptions(Options options, Component child) {

+ 12
- 11
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java View File

17
 import com.reactnativenavigation.utils.ImageLoader;
17
 import com.reactnativenavigation.utils.ImageLoader;
18
 import com.reactnativenavigation.utils.OptionHelper;
18
 import com.reactnativenavigation.utils.OptionHelper;
19
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
19
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
20
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
20
 import com.reactnativenavigation.views.BottomTabs;
21
 import com.reactnativenavigation.views.BottomTabs;
21
 import com.reactnativenavigation.views.ReactComponent;
22
 import com.reactnativenavigation.views.ReactComponent;
22
 
23
 
58
     }
59
     }
59
 
60
 
60
     @Test
61
     @Test
61
-    public void containsRelativeLayoutView() throws Exception {
62
+    public void containsRelativeLayoutView() {
62
         assertThat(uut.getView()).isInstanceOf(RelativeLayout.class);
63
         assertThat(uut.getView()).isInstanceOf(RelativeLayout.class);
63
         assertThat(uut.getView().getChildAt(0)).isInstanceOf(BottomTabs.class);
64
         assertThat(uut.getView().getChildAt(0)).isInstanceOf(BottomTabs.class);
64
     }
65
     }
65
 
66
 
66
     @Test(expected = RuntimeException.class)
67
     @Test(expected = RuntimeException.class)
67
-    public void setTabs_ThrowWhenMoreThan5() throws Exception {
68
+    public void setTabs_ThrowWhenMoreThan5() {
68
         List<ViewController> tabs = createTabs();
69
         List<ViewController> tabs = createTabs();
69
         tabs.add(new SimpleViewController(activity, "6", tabOptions));
70
         tabs.add(new SimpleViewController(activity, "6", tabOptions));
70
         uut.setTabs(tabs);
71
         uut.setTabs(tabs);
71
     }
72
     }
72
 
73
 
73
     @Test
74
     @Test
74
-    public void setTab_controllerIsSetAsParent() throws Exception {
75
+    public void setTab_controllerIsSetAsParent() {
75
         List<ViewController> tabs = createTabs();
76
         List<ViewController> tabs = createTabs();
76
         uut.setTabs(tabs);
77
         uut.setTabs(tabs);
77
         for (ViewController tab : tabs) {
78
         for (ViewController tab : tabs) {
80
     }
81
     }
81
 
82
 
82
     @Test
83
     @Test
83
-    public void setTabs_AddAllViews() throws Exception {
84
+    public void setTabs_AddAllViews() {
84
         List<ViewController> tabs = createTabs();
85
         List<ViewController> tabs = createTabs();
85
         uut.setTabs(tabs);
86
         uut.setTabs(tabs);
86
         assertThat(uut.getView().getChildCount()).isEqualTo(2);
87
         assertThat(uut.getView().getChildCount()).isEqualTo(2);
88
     }
89
     }
89
 
90
 
90
     @Test
91
     @Test
91
-    public void selectTabAtIndex() throws Exception {
92
+    public void selectTabAtIndex() {
92
         uut.setTabs(createTabs());
93
         uut.setTabs(createTabs());
93
         assertThat(uut.getSelectedIndex()).isZero();
94
         assertThat(uut.getSelectedIndex()).isZero();
94
 
95
 
99
     }
100
     }
100
 
101
 
101
     @Test
102
     @Test
102
-    public void findControllerById_ReturnsSelfOrChildren() throws Exception {
103
+    public void findControllerById_ReturnsSelfOrChildren() {
103
         assertThat(uut.findControllerById("123")).isNull();
104
         assertThat(uut.findControllerById("123")).isNull();
104
         assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
105
         assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
105
         StackController inner = createStack("inner");
106
         StackController inner = createStack("inner");
110
     }
111
     }
111
 
112
 
112
     @Test
113
     @Test
113
-    public void handleBack_DelegatesToSelectedChild() throws Exception {
114
+    public void handleBack_DelegatesToSelectedChild() {
114
         assertThat(uut.handleBack()).isFalse();
115
         assertThat(uut.handleBack()).isFalse();
115
 
116
 
116
         List<ViewController> tabs = createTabs();
117
         List<ViewController> tabs = createTabs();
127
     }
128
     }
128
 
129
 
129
     @Test
130
     @Test
130
-    public void applyOptions_bottomTabsOptionsAreClearedAfterApply() throws Exception {
131
+    public void applyOptions_bottomTabsOptionsAreClearedAfterApply() {
131
         List<ViewController> tabs = createTabs();
132
         List<ViewController> tabs = createTabs();
132
         child1.options.bottomTabsOptions.tabColor = new Color(android.graphics.Color.RED);
133
         child1.options.bottomTabsOptions.tabColor = new Color(android.graphics.Color.RED);
133
         uut.setTabs(tabs);
134
         uut.setTabs(tabs);
146
     }
147
     }
147
 
148
 
148
     @Test
149
     @Test
149
-    public void mergeOptions_currentTabIndex() throws Exception {
150
+    public void mergeOptions_currentTabIndex() {
150
         List<ViewController> tabs = createTabs();
151
         List<ViewController> tabs = createTabs();
151
         uut.setTabs(tabs);
152
         uut.setTabs(tabs);
152
         uut.ensureViewIsCreated();
153
         uut.ensureViewIsCreated();
158
     }
159
     }
159
 
160
 
160
     @Test
161
     @Test
161
-    public void buttonPressInvokedOnCurrentTab() throws Exception {
162
+    public void buttonPressInvokedOnCurrentTab() {
162
         uut.setTabs(createTabs());
163
         uut.setTabs(createTabs());
163
         uut.ensureViewIsCreated();
164
         uut.ensureViewIsCreated();
164
         uut.selectTabAtIndex(1);
165
         uut.selectTabAtIndex(1);
173
     }
174
     }
174
 
175
 
175
     private StackController createStack(String id) {
176
     private StackController createStack(String id) {
176
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), id, tabOptions);
177
+        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), id, tabOptions);
177
     }
178
     }
178
 }
179
 }

+ 7
- 6
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ComponentViewControllerTest.java View File

9
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
9
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
10
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
10
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
11
 import com.reactnativenavigation.parse.Options;
11
 import com.reactnativenavigation.parse.Options;
12
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
12
 import com.reactnativenavigation.views.StackLayout;
13
 import com.reactnativenavigation.views.StackLayout;
13
 
14
 
14
 import org.junit.Test;
15
 import org.junit.Test;
28
         super.beforeEach();
29
         super.beforeEach();
29
         Activity activity = newActivity();
30
         Activity activity = newActivity();
30
         view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
31
         view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
31
-        ParentController<StackLayout> parentController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack", new Options());
32
+        ParentController<StackLayout> parentController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options());
32
         uut = new ComponentViewController(activity, "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options());
33
         uut = new ComponentViewController(activity, "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options());
33
         uut.setParentController(parentController);
34
         uut.setParentController(parentController);
34
         parentController.ensureViewIsCreated();
35
         parentController.ensureViewIsCreated();
35
     }
36
     }
36
 
37
 
37
     @Test
38
     @Test
38
-    public void createsViewFromComponentViewCreator() throws Exception {
39
+    public void createsViewFromComponentViewCreator() {
39
         assertThat(uut.getView()).isSameAs(view);
40
         assertThat(uut.getView()).isSameAs(view);
40
     }
41
     }
41
 
42
 
42
     @Test
43
     @Test
43
-    public void componentViewDestroyedOnDestroy() throws Exception {
44
+    public void componentViewDestroyedOnDestroy() {
44
         uut.ensureViewIsCreated();
45
         uut.ensureViewIsCreated();
45
         verify(view, times(0)).destroy();
46
         verify(view, times(0)).destroy();
46
         uut.onViewAppeared();
47
         uut.onViewAppeared();
49
     }
50
     }
50
 
51
 
51
     @Test
52
     @Test
52
-    public void lifecycleMethodsSentToComponentView() throws Exception {
53
+    public void lifecycleMethodsSentToComponentView() {
53
         uut.ensureViewIsCreated();
54
         uut.ensureViewIsCreated();
54
         verify(view, times(0)).sendComponentStart();
55
         verify(view, times(0)).sendComponentStart();
55
         verify(view, times(0)).sendComponentStop();
56
         verify(view, times(0)).sendComponentStop();
62
     }
63
     }
63
 
64
 
64
     @Test
65
     @Test
65
-    public void isViewShownOnlyIfComponentViewIsReady() throws Exception {
66
+    public void isViewShownOnlyIfComponentViewIsReady() {
66
         assertThat(uut.isViewShown()).isFalse();
67
         assertThat(uut.isViewShown()).isFalse();
67
         uut.ensureViewIsCreated();
68
         uut.ensureViewIsCreated();
68
         when(view.asView().isShown()).thenReturn(true);
69
         when(view.asView().isShown()).thenReturn(true);
72
     }
73
     }
73
 
74
 
74
     @Test
75
     @Test
75
-    public void onNavigationButtonPressInvokedOnReactComponent() throws Exception {
76
+    public void onNavigationButtonPressInvokedOnReactComponent() {
76
         uut.ensureViewIsCreated();
77
         uut.ensureViewIsCreated();
77
         uut.sendOnNavigationButtonPressed("btn1");
78
         uut.sendOnNavigationButtonPressed("btn1");
78
         verify(view, times(1)).sendOnNavigationButtonPressed("btn1");
79
         verify(view, times(1)).sendOnNavigationButtonPressed("btn1");

+ 7
- 6
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/FloatingActionButtonTest.java View File

14
 import com.reactnativenavigation.parse.FabOptions;
14
 import com.reactnativenavigation.parse.FabOptions;
15
 import com.reactnativenavigation.parse.Options;
15
 import com.reactnativenavigation.parse.Options;
16
 import com.reactnativenavigation.parse.params.Text;
16
 import com.reactnativenavigation.parse.params.Text;
17
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 import com.reactnativenavigation.views.Fab;
18
 import com.reactnativenavigation.views.Fab;
18
 import com.reactnativenavigation.views.FabMenu;
19
 import com.reactnativenavigation.views.FabMenu;
19
 import com.reactnativenavigation.views.StackLayout;
20
 import com.reactnativenavigation.views.StackLayout;
35
     public void beforeEach() {
36
     public void beforeEach() {
36
         super.beforeEach();
37
         super.beforeEach();
37
         activity = newActivity();
38
         activity = newActivity();
38
-        stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(),"stackController", new Options());
39
+        stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stackController", new Options());
39
         Options options = getOptionsWithFab();
40
         Options options = getOptionsWithFab();
40
         childFab = new SimpleViewController(activity, "child1", options);
41
         childFab = new SimpleViewController(activity, "child1", options);
41
         childNoFab = new SimpleViewController(activity, "child2", new Options());
42
         childNoFab = new SimpleViewController(activity, "child2", new Options());
78
     }
79
     }
79
 
80
 
80
     @Test
81
     @Test
81
-    public void showOnPush() throws Exception {
82
+    public void showOnPush() {
82
         stackController.push(childFab, new MockPromise());
83
         stackController.push(childFab, new MockPromise());
83
         childFab.onViewAppeared();
84
         childFab.onViewAppeared();
84
         assertThat(hasFab()).isTrue();
85
         assertThat(hasFab()).isTrue();
85
     }
86
     }
86
 
87
 
87
     @Test
88
     @Test
88
-    public void hideOnPush() throws Exception {
89
+    public void hideOnPush() {
89
         stackController.push(childFab, new MockPromise());
90
         stackController.push(childFab, new MockPromise());
90
         childFab.onViewAppeared();
91
         childFab.onViewAppeared();
91
         assertThat(hasFab()).isTrue();
92
         assertThat(hasFab()).isTrue();
95
     }
96
     }
96
 
97
 
97
     @Test
98
     @Test
98
-    public void hideOnPop() throws Exception {
99
+    public void hideOnPop() {
99
         stackController.push(childNoFab, new MockPromise());
100
         stackController.push(childNoFab, new MockPromise());
100
         stackController.push(childFab, new MockPromise());
101
         stackController.push(childFab, new MockPromise());
101
         childFab.onViewAppeared();
102
         childFab.onViewAppeared();
106
     }
107
     }
107
 
108
 
108
     @Test
109
     @Test
109
-    public void showOnPop() throws Exception {
110
+    public void showOnPop() {
110
         stackController.push(childFab, new MockPromise());
111
         stackController.push(childFab, new MockPromise());
111
         stackController.push(childNoFab, new MockPromise());
112
         stackController.push(childNoFab, new MockPromise());
112
         childNoFab.onViewAppeared();
113
         childNoFab.onViewAppeared();
117
     }
118
     }
118
 
119
 
119
     @Test
120
     @Test
120
-    public void hasChildren() throws Exception {
121
+    public void hasChildren() {
121
         childFab = new SimpleViewController(activity, "child1", getOptionsWithFabActions());
122
         childFab = new SimpleViewController(activity, "child1", getOptionsWithFabActions());
122
         stackController.push(childFab, new MockPromise());
123
         stackController.push(childFab, new MockPromise());
123
         childFab.onViewAppeared();
124
         childFab.onViewAppeared();

+ 24
- 22
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java View File

17
 import com.reactnativenavigation.utils.ImageLoader;
17
 import com.reactnativenavigation.utils.ImageLoader;
18
 import com.reactnativenavigation.utils.OptionHelper;
18
 import com.reactnativenavigation.utils.OptionHelper;
19
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
19
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
20
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
20
 
21
 
21
 import org.junit.Test;
22
 import org.junit.Test;
22
 
23
 
58
     }
59
     }
59
 
60
 
60
     @Test
61
     @Test
61
-    public void setRoot_AddsChildControllerView() throws Exception {
62
+    public void setRoot_AddsChildControllerView() {
62
         assertThat(uut.getView().getChildCount()).isZero();
63
         assertThat(uut.getView().getChildCount()).isZero();
63
         uut.setRoot(child1, new MockPromise());
64
         uut.setRoot(child1, new MockPromise());
64
         assertIsChildById(uut.getView(), child1.getView());
65
         assertIsChildById(uut.getView(), child1.getView());
65
     }
66
     }
66
 
67
 
67
     @Test
68
     @Test
68
-    public void setRoot_ReplacesExistingChildControllerViews() throws Exception {
69
+    public void setRoot_ReplacesExistingChildControllerViews() {
69
         uut.setRoot(child1, new MockPromise());
70
         uut.setRoot(child1, new MockPromise());
70
         uut.setRoot(child2, new MockPromise());
71
         uut.setRoot(child2, new MockPromise());
71
         assertIsChildById(uut.getView(), child2.getView());
72
         assertIsChildById(uut.getView(), child2.getView());
72
     }
73
     }
73
 
74
 
74
     @Test
75
     @Test
75
-    public void hasUniqueId() throws Exception {
76
+    public void hasUniqueId() {
76
         assertThat(uut.getId()).startsWith("navigator");
77
         assertThat(uut.getId()).startsWith("navigator");
77
         assertThat(new Navigator(activity).getId()).isNotEqualTo(uut.getId());
78
         assertThat(new Navigator(activity).getId()).isNotEqualTo(uut.getId());
78
     }
79
     }
79
 
80
 
80
     @Test
81
     @Test
81
-    public void push() throws Exception {
82
+    public void push() {
82
         StackController stackController = newStack();
83
         StackController stackController = newStack();
83
         stackController.animatePush(child1, new MockPromise());
84
         stackController.animatePush(child1, new MockPromise());
84
         uut.setRoot(stackController, new MockPromise());
85
         uut.setRoot(stackController, new MockPromise());
93
     }
94
     }
94
 
95
 
95
     @Test
96
     @Test
96
-    public void push_InvalidPushWithoutAStack_DoesNothing() throws Exception {
97
+    public void push_InvalidPushWithoutAStack_DoesNothing() {
97
         uut.setRoot(child1, new MockPromise());
98
         uut.setRoot(child1, new MockPromise());
98
         uut.push(child1.getId(), child2, new MockPromise());
99
         uut.push(child1.getId(), child2, new MockPromise());
99
         assertIsChildById(uut.getView(), child1.getView());
100
         assertIsChildById(uut.getView(), child1.getView());
100
     }
101
     }
101
 
102
 
102
     @Test
103
     @Test
103
-    public void push_OnCorrectStackByFindingChildId() throws Exception {
104
+    public void push_OnCorrectStackByFindingChildId() {
104
         BottomTabsController bottomTabsController = newTabs();
105
         BottomTabsController bottomTabsController = newTabs();
105
         StackController stack1 = newStack();
106
         StackController stack1 = newStack();
106
         StackController stack2 = newStack();
107
         StackController stack2 = newStack();
117
     }
118
     }
118
 
119
 
119
     @Test
120
     @Test
120
-    public void pop_InvalidDoesNothing() throws Exception {
121
+    public void pop_InvalidDoesNothing() {
121
         uut.pop("123", new MockPromise());
122
         uut.pop("123", new MockPromise());
122
         uut.setRoot(child1, new MockPromise());
123
         uut.setRoot(child1, new MockPromise());
123
         uut.pop(child1.getId(), new MockPromise());
124
         uut.pop(child1.getId(), new MockPromise());
125
     }
126
     }
126
 
127
 
127
     @Test
128
     @Test
128
-    public void pop_FromCorrectStackByFindingChildId() throws Exception {
129
+    public void pop_FromCorrectStackByFindingChildId() {
129
         BottomTabsController bottomTabsController = newTabs();
130
         BottomTabsController bottomTabsController = newTabs();
130
         StackController stack1 = newStack();
131
         StackController stack1 = newStack();
131
         StackController stack2 = newStack();
132
         StackController stack2 = newStack();
148
     }
149
     }
149
 
150
 
150
     @Test
151
     @Test
151
-    public void popSpecific() throws Exception {
152
+    public void popSpecific() {
152
         BottomTabsController bottomTabsController = newTabs();
153
         BottomTabsController bottomTabsController = newTabs();
153
         StackController stack1 = newStack();
154
         StackController stack1 = newStack();
154
         StackController stack2 = newStack();
155
         StackController stack2 = newStack();
165
     }
166
     }
166
 
167
 
167
     @Test
168
     @Test
168
-    public void popTo_FromCorrectStackUpToChild() throws Exception {
169
+    public void popTo_FromCorrectStackUpToChild() {
169
         BottomTabsController bottomTabsController = newTabs();
170
         BottomTabsController bottomTabsController = newTabs();
170
         StackController stack1 = newStack();
171
         StackController stack1 = newStack();
171
         StackController stack2 = newStack();
172
         StackController stack2 = newStack();
186
     }
187
     }
187
 
188
 
188
     @Test
189
     @Test
189
-    public void popToRoot() throws Exception {
190
+    public void popToRoot() {
190
         BottomTabsController bottomTabsController = newTabs();
191
         BottomTabsController bottomTabsController = newTabs();
191
         StackController stack1 = newStack();
192
         StackController stack1 = newStack();
192
         StackController stack2 = newStack();
193
         StackController stack2 = newStack();
208
     }
209
     }
209
 
210
 
210
     @Test
211
     @Test
211
-    public void handleBack_DelegatesToRoot() throws Exception {
212
+    public void handleBack_DelegatesToRoot() {
212
         ViewController root = spy(child1);
213
         ViewController root = spy(child1);
213
         uut.setRoot(root, new MockPromise());
214
         uut.setRoot(root, new MockPromise());
214
         when(root.handleBack()).thenReturn(true);
215
         when(root.handleBack()).thenReturn(true);
217
     }
218
     }
218
 
219
 
219
     @Test
220
     @Test
220
-    public void handleBack_modalTakePrecedenceOverRoot() throws Exception {
221
+    public void handleBack_modalTakePrecedenceOverRoot() {
221
         ViewController root = spy(child1);
222
         ViewController root = spy(child1);
222
         uut.setRoot(root, new MockPromise());
223
         uut.setRoot(root, new MockPromise());
223
         uut.showModal(child2, new MockPromise());
224
         uut.showModal(child2, new MockPromise());
250
 
251
 
251
     @NonNull
252
     @NonNull
252
     private StackController newStack() {
253
     private StackController newStack() {
253
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack" + CompatUtils.generateViewId(), tabOptions);
254
+        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(),
255
+                "stack" + CompatUtils.generateViewId(), tabOptions);
254
     }
256
     }
255
 
257
 
256
     @Test
258
     @Test
257
-    public void push_Promise() throws Exception {
259
+    public void push_Promise() {
258
         final StackController stackController = newStack();
260
         final StackController stackController = newStack();
259
         stackController.animatePush(child1, new MockPromise());
261
         stackController.animatePush(child1, new MockPromise());
260
         uut.setRoot(stackController, new MockPromise());
262
         uut.setRoot(stackController, new MockPromise());
272
     }
274
     }
273
 
275
 
274
     @Test
276
     @Test
275
-    public void push_InvalidPushWithoutAStack_DoesNothing_Promise() throws Exception {
277
+    public void push_InvalidPushWithoutAStack_DoesNothing_Promise() {
276
         uut.setRoot(child1, new MockPromise());
278
         uut.setRoot(child1, new MockPromise());
277
         uut.push(child1.getId(), child2, new MockPromise() {
279
         uut.push(child1.getId(), child2, new MockPromise() {
278
             @Override
280
             @Override
284
     }
286
     }
285
 
287
 
286
     @Test
288
     @Test
287
-    public void pop_InvalidDoesNothing_Promise() throws Exception {
289
+    public void pop_InvalidDoesNothing_Promise() {
288
         uut.pop("123", new MockPromise());
290
         uut.pop("123", new MockPromise());
289
         uut.setRoot(child1, new MockPromise());
291
         uut.setRoot(child1, new MockPromise());
290
         uut.pop(child1.getId(), new MockPromise() {
292
         uut.pop(child1.getId(), new MockPromise() {
296
     }
298
     }
297
 
299
 
298
     @Test
300
     @Test
299
-    public void pop_FromCorrectStackByFindingChildId_Promise() throws Exception {
301
+    public void pop_FromCorrectStackByFindingChildId_Promise() {
300
         BottomTabsController bottomTabsController = newTabs();
302
         BottomTabsController bottomTabsController = newTabs();
301
         StackController stack1 = newStack();
303
         StackController stack1 = newStack();
302
         final StackController stack2 = newStack();
304
         final StackController stack2 = newStack();
316
     }
318
     }
317
 
319
 
318
     @Test
320
     @Test
319
-    public void pushIntoModal() throws Exception {
321
+    public void pushIntoModal() {
320
         uut.setRoot(parentController, new MockPromise());
322
         uut.setRoot(parentController, new MockPromise());
321
         StackController stackController = newStack();
323
         StackController stackController = newStack();
322
         stackController.push(child1, new MockPromise());
324
         stackController.push(child1, new MockPromise());
326
     }
328
     }
327
 
329
 
328
     @Test
330
     @Test
329
-    public void pushedStackCanBePopped() throws Exception {
331
+    public void pushedStackCanBePopped() {
330
         StackController parent = newStack();
332
         StackController parent = newStack();
331
         parent.ensureViewIsCreated();
333
         parent.ensureViewIsCreated();
332
         uut.setRoot(parent, new MockPromise());
334
         uut.setRoot(parent, new MockPromise());
349
     }
351
     }
350
 
352
 
351
     @Test
353
     @Test
352
-    public void showModal_onViewDisappearIsInvokedOnRoot() throws Exception {
354
+    public void showModal_onViewDisappearIsInvokedOnRoot() {
353
         uut.setRoot(parentController, new MockPromise());
355
         uut.setRoot(parentController, new MockPromise());
354
         uut.showModal(child1, new MockPromise() {
356
         uut.showModal(child1, new MockPromise() {
355
             @Override
357
             @Override
360
     }
362
     }
361
 
363
 
362
     @Test
364
     @Test
363
-    public void dismissModal_onViewAppearedInvokedOnRoot() throws Exception {
365
+    public void dismissModal_onViewAppearedInvokedOnRoot() {
364
         uut.setRoot(parentController, new MockPromise());
366
         uut.setRoot(parentController, new MockPromise());
365
         uut.showModal(child1, new MockPromise() {
367
         uut.showModal(child1, new MockPromise() {
366
             @Override
368
             @Override

+ 12
- 11
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java View File

19
 import com.reactnativenavigation.parse.params.Fraction;
19
 import com.reactnativenavigation.parse.params.Fraction;
20
 import com.reactnativenavigation.parse.params.Text;
20
 import com.reactnativenavigation.parse.params.Text;
21
 import com.reactnativenavigation.utils.ViewUtils;
21
 import com.reactnativenavigation.utils.ViewUtils;
22
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
22
 import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
23
 import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
23
 
24
 
24
 import org.json.JSONObject;
25
 import org.json.JSONObject;
51
                 (activity1, componentId, componentName) -> view,
52
                 (activity1, componentId, componentName) -> view,
52
                 initialNavigationOptions
53
                 initialNavigationOptions
53
         );
54
         );
54
-        stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack", new Options());
55
+        stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options());
55
         stackController.ensureViewIsCreated();
56
         stackController.ensureViewIsCreated();
56
         uut.setParentController(stackController);
57
         uut.setParentController(stackController);
57
     }
58
     }
58
 
59
 
59
     @Test
60
     @Test
60
-    public void applyNavigationOptionsHandlesNoParentStack() throws Exception {
61
+    public void applyNavigationOptionsHandlesNoParentStack() {
61
         uut.setParentController(null);
62
         uut.setParentController(null);
62
         assertThat(uut.getParentController()).isNull();
63
         assertThat(uut.getParentController()).isNull();
63
         uut.ensureViewIsCreated();
64
         uut.ensureViewIsCreated();
66
     }
67
     }
67
 
68
 
68
     @Test
69
     @Test
69
-    public void initialOptionsAppliedOnAppear() throws Exception {
70
+    public void initialOptionsAppliedOnAppear() {
70
         uut.options.topBarOptions.title.text = new Text("the title");
71
         uut.options.topBarOptions.title.text = new Text("the title");
71
-        StackController stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stackId", new Options());
72
+        StackController stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stackId", new Options());
72
         stackController.animatePush(uut, new MockPromise() {});
73
         stackController.animatePush(uut, new MockPromise() {});
73
         assertThat(stackController.getTopBar().getTitle()).isEmpty();
74
         assertThat(stackController.getTopBar().getTitle()).isEmpty();
74
 
75
 
77
     }
78
     }
78
 
79
 
79
     @Test
80
     @Test
80
-    public void mergeNavigationOptionsUpdatesCurrentOptions() throws Exception {
81
+    public void mergeNavigationOptionsUpdatesCurrentOptions() {
81
         uut.ensureViewIsCreated();
82
         uut.ensureViewIsCreated();
82
         assertThat(uut.options.topBarOptions.title.text.get("")).isEmpty();
83
         assertThat(uut.options.topBarOptions.title.text.get("")).isEmpty();
83
         Options options = new Options();
84
         Options options = new Options();
87
     }
88
     }
88
 
89
 
89
     @Test
90
     @Test
90
-    public void reappliesOptionsOnMerge() throws Exception {
91
+    public void reappliesOptionsOnMerge() {
91
         uut.ensureViewIsCreated();
92
         uut.ensureViewIsCreated();
92
         uut.onViewAppeared();
93
         uut.onViewAppeared();
93
         assertThat(stackController.getTopBar().getTitle()).isEmpty();
94
         assertThat(stackController.getTopBar().getTitle()).isEmpty();
100
     }
101
     }
101
 
102
 
102
     @Test
103
     @Test
103
-    public void appliesTopBackBackgroundColor() throws Exception {
104
+    public void appliesTopBackBackgroundColor() {
104
         uut.ensureViewIsCreated();
105
         uut.ensureViewIsCreated();
105
         uut.onViewAppeared();
106
         uut.onViewAppeared();
106
 
107
 
112
     }
113
     }
113
 
114
 
114
     @Test
115
     @Test
115
-    public void appliesTopBarTextColor() throws Exception {
116
+    public void appliesTopBarTextColor() {
116
         assertThat(uut.initialOptions).isSameAs(initialNavigationOptions);
117
         assertThat(uut.initialOptions).isSameAs(initialNavigationOptions);
117
         stackController.animatePush(uut, new MockPromise() {
118
         stackController.animatePush(uut, new MockPromise() {
118
             @Override
119
             @Override
129
     }
130
     }
130
 
131
 
131
     @Test
132
     @Test
132
-    public void appliesTopBarTextSize() throws Exception {
133
+    public void appliesTopBarTextSize() {
133
         assertThat(uut.initialOptions).isSameAs(initialNavigationOptions);
134
         assertThat(uut.initialOptions).isSameAs(initialNavigationOptions);
134
         initialNavigationOptions.topBarOptions.title.text = new Text("the title");
135
         initialNavigationOptions.topBarOptions.title.text = new Text("the title");
135
         uut.ensureViewIsCreated();
136
         uut.ensureViewIsCreated();
145
     }
146
     }
146
 
147
 
147
     @Test
148
     @Test
148
-    public void appliesTopBarVisible() throws Exception {
149
+    public void appliesTopBarVisible() {
149
         assertThat(uut.initialOptions).isSameAs(initialNavigationOptions);
150
         assertThat(uut.initialOptions).isSameAs(initialNavigationOptions);
150
         initialNavigationOptions.topBarOptions.title.text = new Text("the title");
151
         initialNavigationOptions.topBarOptions.title.text = new Text("the title");
151
         uut.ensureViewIsCreated();
152
         uut.ensureViewIsCreated();
161
     }
162
     }
162
 
163
 
163
     @Test
164
     @Test
164
-    public void appliesDrawUnder() throws Exception {
165
+    public void appliesDrawUnder() {
165
         uut.options.topBarOptions.title.text = new Text("the title");
166
         uut.options.topBarOptions.title.text = new Text("the title");
166
         uut.options.topBarOptions.drawBehind = new Bool(false);
167
         uut.options.topBarOptions.drawBehind = new Bool(false);
167
         uut.ensureViewIsCreated();
168
         uut.ensureViewIsCreated();

+ 11
- 10
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java View File

13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
14
 import com.reactnativenavigation.parse.Options;
14
 import com.reactnativenavigation.parse.Options;
15
 import com.reactnativenavigation.parse.params.Text;
15
 import com.reactnativenavigation.parse.params.Text;
16
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
16
 import com.reactnativenavigation.views.ReactComponent;
17
 import com.reactnativenavigation.views.ReactComponent;
17
 
18
 
18
 import org.junit.Test;
19
 import org.junit.Test;
29
 
30
 
30
 public class ParentControllerTest extends BaseTest {
31
 public class ParentControllerTest extends BaseTest {
31
 
32
 
32
-    public static final String INITIAL_TITLE = "initial title";
33
+    private static final String INITIAL_TITLE = "initial title";
33
     private Activity activity;
34
     private Activity activity;
34
     private List<ViewController> children;
35
     private List<ViewController> children;
35
     private ParentController uut;
36
     private ParentController uut;
68
     }
69
     }
69
 
70
 
70
     @Test
71
     @Test
71
-    public void holdsViewGroup() throws Exception {
72
+    public void holdsViewGroup() {
72
         assertThat(uut.getView()).isInstanceOf(ViewGroup.class);
73
         assertThat(uut.getView()).isInstanceOf(ViewGroup.class);
73
     }
74
     }
74
 
75
 
75
     @Test
76
     @Test
76
-    public void mustHaveChildControllers() throws Exception {
77
+    public void mustHaveChildControllers() {
77
         assertThat(uut.getChildControllers()).isNotNull();
78
         assertThat(uut.getChildControllers()).isNotNull();
78
     }
79
     }
79
 
80
 
80
     @Test
81
     @Test
81
-    public void findControllerById_ChildById() throws Exception {
82
+    public void findControllerById_ChildById() {
82
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
83
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
83
         SimpleViewController child2 = new SimpleViewController(activity, "child2", new Options());
84
         SimpleViewController child2 = new SimpleViewController(activity, "child2", new Options());
84
         children.add(child1);
85
         children.add(child1);
89
     }
90
     }
90
 
91
 
91
     @Test
92
     @Test
92
-    public void findControllerById_Recursive() throws Exception {
93
+    public void findControllerById_Recursive() {
93
         StackController stackController = createStack();
94
         StackController stackController = createStack();
94
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
95
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
95
         SimpleViewController child2 = new SimpleViewController(activity, "child2", new Options());
96
         SimpleViewController child2 = new SimpleViewController(activity, "child2", new Options());
101
     }
102
     }
102
 
103
 
103
     @Test
104
     @Test
104
-    public void destroy_DestroysChildren() throws Exception {
105
+    public void destroy_DestroysChildren() {
105
         ViewController child1 = spy(new SimpleViewController(activity, "child1", new Options()));
106
         ViewController child1 = spy(new SimpleViewController(activity, "child1", new Options()));
106
         children.add(child1);
107
         children.add(child1);
107
 
108
 
111
     }
112
     }
112
 
113
 
113
     @Test
114
     @Test
114
-    public void optionsAreClearedWhenChildIsAppeared() throws Exception {
115
+    public void optionsAreClearedWhenChildIsAppeared() {
115
         StackController stackController = spy(createStack());
116
         StackController stackController = spy(createStack());
116
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
117
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
117
         stackController.animatePush(child1, new MockPromise());
118
         stackController.animatePush(child1, new MockPromise());
121
     }
122
     }
122
 
123
 
123
     @Test
124
     @Test
124
-    public void mergeOptions_optionsAreMergedWhenChildAppears() throws Exception {
125
+    public void mergeOptions_optionsAreMergedWhenChildAppears() {
125
         Options options = new Options();
126
         Options options = new Options();
126
         options.topBarOptions.title.text = new Text("new title");
127
         options.topBarOptions.title.text = new Text("new title");
127
         ViewController child1 = spy(new SimpleViewController(activity, "child1", options));
128
         ViewController child1 = spy(new SimpleViewController(activity, "child1", options));
139
     }
140
     }
140
 
141
 
141
     @Test
142
     @Test
142
-    public void mergeOptions_initialParentOptionsAreNotMutatedWhenChildAppears() throws Exception {
143
+    public void mergeOptions_initialParentOptionsAreNotMutatedWhenChildAppears() {
143
         Options options = new Options();
144
         Options options = new Options();
144
         options.topBarOptions.title.text = new Text("new title");
145
         options.topBarOptions.title.text = new Text("new title");
145
         ViewController child1 = spy(new SimpleViewController(activity, "child1", options));
146
         ViewController child1 = spy(new SimpleViewController(activity, "child1", options));
153
     }
154
     }
154
 
155
 
155
     private StackController createStack() {
156
     private StackController createStack() {
156
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(),"stack", new Options());
157
+        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options());
157
     }
158
     }
158
 }
159
 }

+ 16
- 5
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java View File

16
 import com.reactnativenavigation.parse.params.Bool;
16
 import com.reactnativenavigation.parse.params.Bool;
17
 import com.reactnativenavigation.parse.params.Text;
17
 import com.reactnativenavigation.parse.params.Text;
18
 import com.reactnativenavigation.utils.ViewHelper;
18
 import com.reactnativenavigation.utils.ViewHelper;
19
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
19
 import com.reactnativenavigation.views.Component;
20
 import com.reactnativenavigation.views.Component;
20
 import com.reactnativenavigation.views.ReactComponent;
21
 import com.reactnativenavigation.views.ReactComponent;
21
 import com.reactnativenavigation.views.StackLayout;
22
 import com.reactnativenavigation.views.StackLayout;
22
 
23
 
23
 import org.assertj.core.api.iterable.Extractor;
24
 import org.assertj.core.api.iterable.Extractor;
24
 import org.json.JSONObject;
25
 import org.json.JSONObject;
25
-import org.junit.Ignore;
26
 import org.junit.Test;
26
 import org.junit.Test;
27
 import org.mockito.ArgumentCaptor;
27
 import org.mockito.ArgumentCaptor;
28
 import org.mockito.Mockito;
28
 import org.mockito.Mockito;
44
     private ViewController child2;
44
     private ViewController child2;
45
     private ViewController child3;
45
     private ViewController child3;
46
     private NavigationAnimator animator;
46
     private NavigationAnimator animator;
47
+    private TopBarController topBarController;
47
 
48
 
48
     @Override
49
     @Override
49
     public void beforeEach() {
50
     public void beforeEach() {
105
     @Test
106
     @Test
106
     public void pop_layoutHandlesChildWillDisappear() {
107
     public void pop_layoutHandlesChildWillDisappear() {
107
         final StackLayout[] stackLayout = new StackLayout[1];
108
         final StackLayout[] stackLayout = new StackLayout[1];
108
-        uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "uut", new Options()) {
109
+        uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "uut", new Options()) {
109
             @NonNull
110
             @NonNull
110
             @Override
111
             @Override
111
             protected StackLayout createView() {
112
             protected StackLayout createView() {
465
     @Test
466
     @Test
466
     public void mergeChildOptions_updatesViewWithNewOptions() {
467
     public void mergeChildOptions_updatesViewWithNewOptions() {
467
         final StackLayout[] stackLayout = new StackLayout[1];
468
         final StackLayout[] stackLayout = new StackLayout[1];
468
-        StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack", new Options()) {
469
+        StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options()) {
469
             @NonNull
470
             @NonNull
470
             @Override
471
             @Override
471
             protected StackLayout createView() {
472
             protected StackLayout createView() {
482
     @Test
483
     @Test
483
     public void mergeChildOptions_updatesParentControllerWithNewOptions() {
484
     public void mergeChildOptions_updatesParentControllerWithNewOptions() {
484
         final StackLayout[] stackLayout = new StackLayout[1];
485
         final StackLayout[] stackLayout = new StackLayout[1];
485
-        StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack", new Options()) {
486
+        StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options()) {
486
             @NonNull
487
             @NonNull
487
             @Override
488
             @Override
488
             protected StackLayout createView() {
489
             protected StackLayout createView() {
533
         assertThat(captor.getValue().fabOptions.hasValue()).isFalse();
534
         assertThat(captor.getValue().fabOptions.hasValue()).isFalse();
534
     }
535
     }
535
 
536
 
537
+    @Test
538
+    public void destroy() {
539
+        uut.ensureViewIsCreated();
540
+        uut.destroy();
541
+        verify(topBarController, times(1)).clear();
542
+    }
543
+
536
     private void assertContainsOnlyId(String... ids) {
544
     private void assertContainsOnlyId(String... ids) {
537
         assertThat(uut.size()).isEqualTo(ids.length);
545
         assertThat(uut.size()).isEqualTo(ids.length);
538
         assertThat(uut.getChildControllers()).extracting((Extractor<ViewController, String>) ViewController::getId).containsOnly(ids);
546
         assertThat(uut.getChildControllers()).extracting((Extractor<ViewController, String>) ViewController::getId).containsOnly(ids);
543
     }
551
     }
544
 
552
 
545
     private StackController createStackController(String id) {
553
     private StackController createStackController(String id) {
546
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), id, new Options()) {
554
+        topBarController = spy(new TopBarController());
555
+        return new StackController(activity,
556
+                new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(),
557
+                topBarController, id, new Options()) {
547
             @Override
558
             @Override
548
             NavigationAnimator createAnimator() {
559
             NavigationAnimator createAnimator() {
549
                 animator = Mockito.mock(NavigationAnimator.class);
560
                 animator = Mockito.mock(NavigationAnimator.class);

+ 4
- 3
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopBarButtonControllerTest.java View File

10
 import com.reactnativenavigation.parse.Options;
10
 import com.reactnativenavigation.parse.Options;
11
 import com.reactnativenavigation.parse.params.Button;
11
 import com.reactnativenavigation.parse.params.Button;
12
 import com.reactnativenavigation.parse.params.Text;
12
 import com.reactnativenavigation.parse.params.Text;
13
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
13
 
14
 
14
 import org.junit.Ignore;
15
 import org.junit.Ignore;
15
 import org.junit.Test;
16
 import org.junit.Test;
30
 
31
 
31
         TopBarButtonCreatorMock buttonCreatorMock = new TopBarButtonCreatorMock();
32
         TopBarButtonCreatorMock buttonCreatorMock = new TopBarButtonCreatorMock();
32
         uut = spy(new TopBarButtonController(activity, button, buttonCreatorMock, (buttonId) -> {}));
33
         uut = spy(new TopBarButtonController(activity, button, buttonCreatorMock, (buttonId) -> {}));
33
-        stackController = spy(new StackController(activity, buttonCreatorMock, new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack", new Options()));
34
+        stackController = spy(new StackController(activity, buttonCreatorMock, new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options()));
34
 
35
 
35
     }
36
     }
36
 
37
 
37
     @Test
38
     @Test
38
-    public void buttonDoesNotClearStackOptionsOnAppear() throws Exception {
39
+    public void buttonDoesNotClearStackOptionsOnAppear() {
39
         uut.ensureViewIsCreated();
40
         uut.ensureViewIsCreated();
40
         uut.onViewAppeared();
41
         uut.onViewAppeared();
41
         verify(stackController, times(0)).clearOptions();
42
         verify(stackController, times(0)).clearOptions();
42
     }
43
     }
43
 
44
 
44
     @Test @Ignore
45
     @Test @Ignore
45
-    public void destroy_buttonIsDestroyedWhenStackIsDestroyed() throws Exception {
46
+    public void destroy_buttonIsDestroyedWhenStackIsDestroyed() {
46
         uut.ensureViewIsCreated();
47
         uut.ensureViewIsCreated();
47
         uut.onViewAppeared();
48
         uut.onViewAppeared();
48
         stackController.destroy();
49
         stackController.destroy();

+ 12
- 11
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java View File

14
 import com.reactnativenavigation.parse.Options;
14
 import com.reactnativenavigation.parse.Options;
15
 import com.reactnativenavigation.parse.params.Text;
15
 import com.reactnativenavigation.parse.params.Text;
16
 import com.reactnativenavigation.utils.ViewHelper;
16
 import com.reactnativenavigation.utils.ViewHelper;
17
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsAdapter;
18
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsAdapter;
18
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
19
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
19
 import com.reactnativenavigation.views.ReactComponent;
20
 import com.reactnativenavigation.views.ReactComponent;
69
 
70
 
70
     @NonNull
71
     @NonNull
71
     private StackController createStackController(String id) {
72
     private StackController createStackController(String id) {
72
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), id, new Options());
73
+        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), id, new Options());
73
     }
74
     }
74
 
75
 
75
     @NonNull
76
     @NonNull
104
     }
105
     }
105
 
106
 
106
     @Test
107
     @Test
107
-    public void createsViewFromComponentViewCreator() throws Exception {
108
+    public void createsViewFromComponentViewCreator() {
108
         uut.ensureViewIsCreated();
109
         uut.ensureViewIsCreated();
109
         for (int i = 0; i < SIZE; i++) {
110
         for (int i = 0; i < SIZE; i++) {
110
             verify(tabControllers.get(i), times(1)).createView();
111
             verify(tabControllers.get(i), times(1)).createView();
112
     }
113
     }
113
 
114
 
114
     @Test
115
     @Test
115
-    public void componentViewDestroyedOnDestroy() throws Exception {
116
+    public void componentViewDestroyedOnDestroy() {
116
         uut.ensureViewIsCreated();
117
         uut.ensureViewIsCreated();
117
         TopTabsViewPager topTabs = uut.getView();
118
         TopTabsViewPager topTabs = uut.getView();
118
         for (int i = 0; i < SIZE; i++) {
119
         for (int i = 0; i < SIZE; i++) {
125
     }
126
     }
126
 
127
 
127
     @Test
128
     @Test
128
-    public void lifecycleMethodsSentWhenSelectedTabChanges() throws Exception {
129
+    public void lifecycleMethodsSentWhenSelectedTabChanges() {
129
         parentController.ensureViewIsCreated();
130
         parentController.ensureViewIsCreated();
130
         uut.ensureViewIsCreated();
131
         uut.ensureViewIsCreated();
131
         tabControllers.get(0).ensureViewIsCreated();
132
         tabControllers.get(0).ensureViewIsCreated();
145
     }
146
     }
146
 
147
 
147
     @Test
148
     @Test
148
-    public void lifecycleMethodsSentWhenSelectedPreviouslySelectedTab() throws Exception {
149
+    public void lifecycleMethodsSentWhenSelectedPreviouslySelectedTab() {
149
         parentController.ensureViewIsCreated();
150
         parentController.ensureViewIsCreated();
150
         uut.ensureViewIsCreated();
151
         uut.ensureViewIsCreated();
151
         uut.onViewAppeared();
152
         uut.onViewAppeared();
159
     }
160
     }
160
 
161
 
161
     @Test
162
     @Test
162
-    public void setOptionsOfInitialTab() throws Exception {
163
+    public void setOptionsOfInitialTab() {
163
         parentController.ensureViewIsCreated();
164
         parentController.ensureViewIsCreated();
164
         uut.ensureViewIsCreated();
165
         uut.ensureViewIsCreated();
165
         uut.onViewAppeared();
166
         uut.onViewAppeared();
171
     }
172
     }
172
 
173
 
173
     @Test
174
     @Test
174
-    public void setOptionsWhenTabChanges() throws Exception {
175
+    public void setOptionsWhenTabChanges() {
175
         parentController.ensureViewIsCreated();
176
         parentController.ensureViewIsCreated();
176
         uut.ensureViewIsCreated();
177
         uut.ensureViewIsCreated();
177
         tabControllers.get(0).ensureViewIsCreated();
178
         tabControllers.get(0).ensureViewIsCreated();
198
     }
199
     }
199
 
200
 
200
     @Test
201
     @Test
201
-    public void appliesOptionsOnLayoutWhenVisible() throws Exception {
202
+    public void appliesOptionsOnLayoutWhenVisible() {
202
         tabControllers.get(0).ensureViewIsCreated();
203
         tabControllers.get(0).ensureViewIsCreated();
203
         parentController.ensureViewIsCreated();
204
         parentController.ensureViewIsCreated();
204
         uut.ensureViewIsCreated();
205
         uut.ensureViewIsCreated();
209
     }
210
     }
210
 
211
 
211
     @Test
212
     @Test
212
-    public void applyOptions_applyOnlyOnFirstTopTabs() throws Exception {
213
+    public void applyOptions_applyOnlyOnFirstTopTabs() {
213
         tabOptions.get(0).topTabOptions.title = new Text("tab title");
214
         tabOptions.get(0).topTabOptions.title = new Text("tab title");
214
         tabControllers.get(0).onViewAppeared();
215
         tabControllers.get(0).onViewAppeared();
215
         ArgumentCaptor<Options> optionsCaptor = ArgumentCaptor.forClass(Options.class);
216
         ArgumentCaptor<Options> optionsCaptor = ArgumentCaptor.forClass(Options.class);
219
     }
220
     }
220
 
221
 
221
     @Test
222
     @Test
222
-    public void applyOptions_tabsAreRemovedAfterViewDisappears() throws Exception {
223
+    public void applyOptions_tabsAreRemovedAfterViewDisappears() {
223
         parentController.getView().removeAllViews();
224
         parentController.getView().removeAllViews();
224
 
225
 
225
         StackController stackController = spy(createStackController("stack"));
226
         StackController stackController = spy(createStackController("stack"));
247
     }
248
     }
248
 
249
 
249
     @Test
250
     @Test
250
-    public void onNavigationButtonPressInvokedOnCurrentTab() throws Exception {
251
+    public void onNavigationButtonPressInvokedOnCurrentTab() {
251
         uut.ensureViewIsCreated();
252
         uut.ensureViewIsCreated();
252
         uut.switchToTab(1);
253
         uut.switchToTab(1);
253
         uut.sendOnNavigationButtonPressed("btn1");
254
         uut.sendOnNavigationButtonPressed("btn1");

+ 18
- 17
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java View File

13
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
13
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
14
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
14
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
15
 import com.reactnativenavigation.parse.Options;
15
 import com.reactnativenavigation.parse.Options;
16
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
16
 
17
 
17
 import org.assertj.android.api.Assertions;
18
 import org.assertj.android.api.Assertions;
18
 import org.junit.Test;
19
 import org.junit.Test;
39
     }
40
     }
40
 
41
 
41
     @Test
42
     @Test
42
-    public void holdsAView() throws Exception {
43
+    public void holdsAView() {
43
         assertThat(uut.getView()).isNotNull().isInstanceOf(View.class);
44
         assertThat(uut.getView()).isNotNull().isInstanceOf(View.class);
44
     }
45
     }
45
 
46
 
46
     @Test
47
     @Test
47
-    public void holdsARefToActivity() throws Exception {
48
+    public void holdsARefToActivity() {
48
         assertThat(uut.getActivity()).isNotNull().isEqualTo(activity);
49
         assertThat(uut.getActivity()).isNotNull().isEqualTo(activity);
49
     }
50
     }
50
 
51
 
51
     @Test
52
     @Test
52
-    public void canOverrideViewCreation() throws Exception {
53
+    public void canOverrideViewCreation() {
53
         final FrameLayout otherView = new FrameLayout(activity);
54
         final FrameLayout otherView = new FrameLayout(activity);
54
         ViewController myController = new ViewController(activity, "vc", new Options()) {
55
         ViewController myController = new ViewController(activity, "vc", new Options()) {
55
             @Override
56
             @Override
66
     }
67
     }
67
 
68
 
68
     @Test
69
     @Test
69
-    public void holdsAReferenceToStackControllerOrNull() throws Exception {
70
+    public void holdsAReferenceToStackControllerOrNull() {
70
         assertThat(uut.getParentController()).isNull();
71
         assertThat(uut.getParentController()).isNull();
71
-        StackController nav = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), "stack", new Options());
72
+        StackController nav = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options());
72
         nav.animatePush(uut, new MockPromise());
73
         nav.animatePush(uut, new MockPromise());
73
         assertThat(uut.getParentController()).isEqualTo(nav);
74
         assertThat(uut.getParentController()).isEqualTo(nav);
74
     }
75
     }
75
 
76
 
76
     @Test
77
     @Test
77
-    public void handleBackDefaultFalse() throws Exception {
78
+    public void handleBackDefaultFalse() {
78
         assertThat(uut.handleBack()).isFalse();
79
         assertThat(uut.handleBack()).isFalse();
79
     }
80
     }
80
 
81
 
81
     @Test
82
     @Test
82
-    public void holdsId() throws Exception {
83
+    public void holdsId() {
83
         assertThat(uut.getId()).isEqualTo("uut");
84
         assertThat(uut.getId()).isEqualTo("uut");
84
     }
85
     }
85
 
86
 
86
     @Test
87
     @Test
87
-    public void isSameId() throws Exception {
88
+    public void isSameId() {
88
         assertThat(uut.isSameId("")).isFalse();
89
         assertThat(uut.isSameId("")).isFalse();
89
         assertThat(uut.isSameId(null)).isFalse();
90
         assertThat(uut.isSameId(null)).isFalse();
90
         assertThat(uut.isSameId("uut")).isTrue();
91
         assertThat(uut.isSameId("uut")).isTrue();
91
     }
92
     }
92
 
93
 
93
     @Test
94
     @Test
94
-    public void findControllerById_SelfOrNull() throws Exception {
95
+    public void findControllerById_SelfOrNull() {
95
         assertThat(uut.findControllerById("456")).isNull();
96
         assertThat(uut.findControllerById("456")).isNull();
96
         assertThat(uut.findControllerById("uut")).isEqualTo(uut);
97
         assertThat(uut.findControllerById("uut")).isEqualTo(uut);
97
     }
98
     }
98
 
99
 
99
     @Test
100
     @Test
100
-    public void onAppear_WhenShown() throws Exception {
101
+    public void onAppear_WhenShown() {
101
         ViewController spy = spy(uut);
102
         ViewController spy = spy(uut);
102
         spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
103
         spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
103
         Assertions.assertThat(spy.getView()).isNotShown();
104
         Assertions.assertThat(spy.getView()).isNotShown();
111
     }
112
     }
112
 
113
 
113
     @Test
114
     @Test
114
-    public void onAppear_CalledAtMostOnce() throws Exception {
115
+    public void onAppear_CalledAtMostOnce() {
115
         ViewController spy = spy(uut);
116
         ViewController spy = spy(uut);
116
         Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
117
         Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
117
         Assertions.assertThat(spy.getView()).isShown();
118
         Assertions.assertThat(spy.getView()).isShown();
123
     }
124
     }
124
 
125
 
125
     @Test
126
     @Test
126
-    public void onDisappear_WhenNotShown_AfterOnAppearWasCalled() throws Exception {
127
+    public void onDisappear_WhenNotShown_AfterOnAppearWasCalled() {
127
         ViewController spy = spy(uut);
128
         ViewController spy = spy(uut);
128
         Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
129
         Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
129
         Assertions.assertThat(spy.getView()).isShown();
130
         Assertions.assertThat(spy.getView()).isShown();
138
     }
139
     }
139
 
140
 
140
     @Test
141
     @Test
141
-    public void onDisappear_CalledAtMostOnce() throws Exception {
142
+    public void onDisappear_CalledAtMostOnce() {
142
         ViewController spy = spy(uut);
143
         ViewController spy = spy(uut);
143
         Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
144
         Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
144
         Assertions.assertThat(spy.getView()).isShown();
145
         Assertions.assertThat(spy.getView()).isShown();
171
     }
172
     }
172
 
173
 
173
     @Test
174
     @Test
174
-    public void onDestroy_CallsOnDisappearIfNeeded() throws Exception {
175
+    public void onDestroy_CallsOnDisappearIfNeeded() {
175
         ViewController spy = spy(uut);
176
         ViewController spy = spy(uut);
176
         Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
177
         Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
177
         Assertions.assertThat(spy.getView()).isShown();
178
         Assertions.assertThat(spy.getView()).isShown();
184
     }
185
     }
185
 
186
 
186
     @Test
187
     @Test
187
-    public void assignsIdToCreatedView() throws Exception {
188
+    public void assignsIdToCreatedView() {
188
         assertThat(uut.getView().getId()).isPositive();
189
         assertThat(uut.getView().getId()).isPositive();
189
     }
190
     }
190
 
191
 
191
     @Test
192
     @Test
192
-    public void onDestroy_RemovesSelfFromParentIfExists() throws Exception {
193
+    public void onDestroy_RemovesSelfFromParentIfExists() {
193
         LinearLayout parent = new LinearLayout(activity);
194
         LinearLayout parent = new LinearLayout(activity);
194
         parent.addView(uut.getView());
195
         parent.addView(uut.getView());
195
 
196
 
198
     }
199
     }
199
 
200
 
200
     @Test
201
     @Test
201
-    public void ensureViewIsCreated() throws Exception {
202
+    public void ensureViewIsCreated() {
202
         ViewController spy = spy(uut);
203
         ViewController spy = spy(uut);
203
         verify(spy, times(0)).getView();
204
         verify(spy, times(0)).getView();
204
         spy.ensureViewIsCreated();
205
         spy.ensureViewIsCreated();

+ 5
- 4
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarBackgroundComponentTest.java View File

12
 import com.reactnativenavigation.parse.params.Text;
12
 import com.reactnativenavigation.parse.params.Text;
13
 import com.reactnativenavigation.utils.ViewUtils;
13
 import com.reactnativenavigation.utils.ViewUtils;
14
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
14
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
15
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
15
 import com.reactnativenavigation.views.topbar.TopBar;
16
 import com.reactnativenavigation.views.topbar.TopBar;
16
 import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
17
 import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
17
 
18
 
42
                 return backgroundView;
43
                 return backgroundView;
43
             }
44
             }
44
         };
45
         };
45
-        StackLayout parent = new StackLayout(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), backgroundViewCreator, onClickListener, null);
46
+        StackLayout parent = new StackLayout(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), backgroundViewCreator, new TopBarController(), onClickListener, null);
46
         uut = new TopBar(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), backgroundViewCreator, onClickListener, parent);
47
         uut = new TopBar(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), backgroundViewCreator, onClickListener, parent);
47
         parent.addView(uut);
48
         parent.addView(uut);
48
     }
49
     }
49
 
50
 
50
     @Test
51
     @Test
51
-    public void setBackgroundComponent() throws Exception {
52
+    public void setBackgroundComponent() {
52
         uut.getLayoutParams().height = 100;
53
         uut.getLayoutParams().height = 100;
53
         uut.setBackgroundComponent(new Text("someComponent"));
54
         uut.setBackgroundComponent(new Text("someComponent"));
54
         TopBarBackgroundView background = (TopBarBackgroundView) ViewUtils.findChildrenByClassRecursive(uut, TopBarBackgroundView.class).get(0);
55
         TopBarBackgroundView background = (TopBarBackgroundView) ViewUtils.findChildrenByClassRecursive(uut, TopBarBackgroundView.class).get(0);
58
     }
59
     }
59
 
60
 
60
     @Test
61
     @Test
61
-    public void setBackgroundComponent_doesNotSetIfNoComponentIsDefined() throws Exception {
62
+    public void setBackgroundComponent_doesNotSetIfNoComponentIsDefined() {
62
         uut.setBackgroundComponent(new Text("someComponent"));
63
         uut.setBackgroundComponent(new Text("someComponent"));
63
         assertThat(uut.findViewById(R.id.topBarBackgroundComponent)).isNull();
64
         assertThat(uut.findViewById(R.id.topBarBackgroundComponent)).isNull();
64
     }
65
     }
65
 
66
 
66
     @Test
67
     @Test
67
-    public void clear_componentIsDestroyed() throws Exception {
68
+    public void clear_componentIsDestroyed() {
68
         uut.setBackgroundComponent(new Text("someComponent"));
69
         uut.setBackgroundComponent(new Text("someComponent"));
69
         uut.clear();
70
         uut.clear();
70
         verify(backgroundView, times(1)).destroy();
71
         verify(backgroundView, times(1)).destroy();

+ 6
- 5
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java View File

13
 import com.reactnativenavigation.parse.params.Text;
13
 import com.reactnativenavigation.parse.params.Text;
14
 import com.reactnativenavigation.utils.TitleBarHelper;
14
 import com.reactnativenavigation.utils.TitleBarHelper;
15
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
15
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
16
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
16
 import com.reactnativenavigation.views.topbar.TopBar;
17
 import com.reactnativenavigation.views.topbar.TopBar;
17
 
18
 
18
 import org.junit.Test;
19
 import org.junit.Test;
41
                 Log.i("TopBarTest", "onPress: " + buttonId);
42
                 Log.i("TopBarTest", "onPress: " + buttonId);
42
             }
43
             }
43
         });
44
         });
44
-        StackLayout parent = new StackLayout(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), this.onClickListener, null);
45
+        StackLayout parent = new StackLayout(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), this.onClickListener, null);
45
         uut = new TopBar(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), this.onClickListener, parent);
46
         uut = new TopBar(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), this.onClickListener, parent);
46
         animator = spy(new TopBarAnimator(uut));
47
         animator = spy(new TopBarAnimator(uut));
47
         uut.setAnimator(animator);
48
         uut.setAnimator(animator);
72
     }
73
     }
73
 
74
 
74
     @Test
75
     @Test
75
-    public void title() throws Exception {
76
+    public void title() {
76
         assertThat(uut.getTitle()).isEmpty();
77
         assertThat(uut.getTitle()).isEmpty();
77
         uut.setTitle("new title");
78
         uut.setTitle("new title");
78
         assertThat(uut.getTitle()).isEqualTo("new title");
79
         assertThat(uut.getTitle()).isEqualTo("new title");
79
     }
80
     }
80
 
81
 
81
     @Test
82
     @Test
82
-    public void hide_animate() throws Exception {
83
+    public void hide_animate() {
83
         AnimationOptions options = new AnimationOptions();
84
         AnimationOptions options = new AnimationOptions();
84
         uut.hideAnimate(options);
85
         uut.hideAnimate(options);
85
         verify(animator, times(1)).hide(options, null);
86
         verify(animator, times(1)).hide(options, null);
86
     }
87
     }
87
 
88
 
88
     @Test
89
     @Test
89
-    public void show_animate() throws Exception {
90
+    public void show_animate() {
90
         AnimationOptions options = new AnimationOptions();
91
         AnimationOptions options = new AnimationOptions();
91
         uut.hide();
92
         uut.hide();
92
         uut.showAnimate(options);
93
         uut.showAnimate(options);
94
     }
95
     }
95
 
96
 
96
     @Test
97
     @Test
97
-    public void button_TitleBarButtonOnClickInvoked() throws Exception {
98
+    public void button_TitleBarButtonOnClickInvoked() {
98
         uut.setLeftButtons(new ArrayList<>());
99
         uut.setLeftButtons(new ArrayList<>());
99
         uut.setRightButtons(rightButtons);
100
         uut.setRightButtons(rightButtons);
100
         for (int i = 0; i < rightButtons.size(); i++) {
101
         for (int i = 0; i < rightButtons.size(); i++) {