react-native-navigation 7.24.3 → 7.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/lib/android/app/build.gradle +12 -9
  2. package/lib/android/app/src/main/java/com/reactnativenavigation/options/Options.java +2 -0
  3. package/lib/android/app/src/main/java/com/reactnativenavigation/options/layout/LayoutInsets.kt +44 -0
  4. package/lib/android/app/src/main/java/com/reactnativenavigation/options/layout/LayoutOptions.kt +71 -0
  5. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/PrimitiveExt.kt +9 -0
  6. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +4 -3
  7. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/navigator/Navigator.java +5 -0
  8. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +23 -7
  9. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewController.java +12 -3
  10. package/lib/dist/src/interfaces/Options.d.ts +10 -0
  11. package/lib/ios/RNNBasePresenter.m +17 -0
  12. package/lib/ios/RNNBottomTabsController.m +1 -0
  13. package/lib/ios/RNNBridgeManager.mm +5 -3
  14. package/lib/ios/RNNComponentViewController.m +5 -0
  15. package/lib/ios/RNNLayoutOptions.h +2 -1
  16. package/lib/ios/RNNLayoutOptions.m +4 -0
  17. package/lib/ios/RNNModalHostViewManagerHandler.h +11 -0
  18. package/lib/ios/RNNModalHostViewManagerHandler.m +40 -0
  19. package/lib/ios/RNNModalManager.h +2 -2
  20. package/lib/ios/RNNModalManager.m +0 -26
  21. package/lib/ios/RNNStackPresenter.m +1 -0
  22. package/lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj +8 -0
  23. package/lib/src/interfaces/Options.ts +12 -0
  24. package/package.json +3 -1
  25. package/.buildkite/pipeline.yml +0 -59
  26. package/lib/android/app/src/main/java/com/reactnativenavigation/options/LayoutOptions.java +0 -48
  27. package/lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java +0 -178
  28. package/lib/android/app/src/test/java/com/reactnativenavigation/EnvironmentTest.java +0 -43
  29. package/lib/android/app/src/test/java/com/reactnativenavigation/TestActivity.java +0 -23
  30. package/lib/android/app/src/test/java/com/reactnativenavigation/TestApplication.java +0 -35
  31. package/lib/android/app/src/test/java/com/reactnativenavigation/TestUtils.java +0 -62
  32. package/lib/android/app/src/test/java/com/reactnativenavigation/fakes/IconResolverFake.kt +0 -8
  33. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/BackDrawable.java +0 -30
  34. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/ImageLoaderMock.kt +0 -49
  35. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/Mocks.kt +0 -18
  36. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleComponentViewController.java +0 -15
  37. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleOverlay.java +0 -54
  38. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleViewController.java +0 -113
  39. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java +0 -79
  40. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentViewCreator.java +0 -18
  41. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestReactView.java +0 -71
  42. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarButtonCreatorMock.java +0 -34
  43. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarReactViewCreatorMock.java +0 -20
  44. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TopBarBackgroundViewCreatorMock.java +0 -20
  45. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.kt +0 -21
  46. package/lib/android/app/src/test/java/com/reactnativenavigation/options/LayoutNodeParserTest.java +0 -51
  47. package/lib/android/app/src/test/java/com/reactnativenavigation/options/OptionsTest.java +0 -315
  48. package/lib/android/app/src/test/java/com/reactnativenavigation/options/OrientationOptionsTest.java +0 -81
  49. package/lib/android/app/src/test/java/com/reactnativenavigation/options/TopBarButtonsTest.kt +0 -95
  50. package/lib/android/app/src/test/java/com/reactnativenavigation/options/TransitionAnimationOptionsTest.kt +0 -122
  51. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/BoolParserTest.java +0 -28
  52. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/ColorParseTest.java +0 -50
  53. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/JSONParserTest.java +0 -64
  54. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/PresenterTest.java +0 -56
  55. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/RenderCheckerTest.java +0 -59
  56. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/SideMenuPresenterTest.java +0 -35
  57. package/lib/android/app/src/test/java/com/reactnativenavigation/react/NavigationModuleTest.java +0 -102
  58. package/lib/android/app/src/test/java/com/reactnativenavigation/react/ReloadListenerTest.java +0 -24
  59. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/AnimationHelper.kt +0 -33
  60. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonPresenterTest.java +0 -241
  61. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonSpanTest.java +0 -57
  62. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/CompatUtilsTest.java +0 -17
  63. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/LayoutFactoryTest.java +0 -78
  64. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/MotionEventTest.kt +0 -47
  65. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/NativeCommandListenerTest.java +0 -60
  66. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/OptionHelper.java +0 -16
  67. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java +0 -26
  68. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/StringUtilsTest.java +0 -19
  69. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/SystemUiUtilsTest.kt +0 -27
  70. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleAndButtonsMeasurerTest.kt +0 -357
  71. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleBarHelper.java +0 -54
  72. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java +0 -29
  73. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java +0 -22
  74. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ViewHelper.java +0 -9
  75. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java +0 -149
  76. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenterTest.java +0 -206
  77. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsAttacherTest.java +0 -62
  78. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +0 -589
  79. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenterTest.kt +0 -173
  80. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AfterInitialTabTest.java +0 -38
  81. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AttachModeTest.java +0 -86
  82. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/OnSwitchToTabTest.java +0 -31
  83. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/TogetherTest.java +0 -20
  84. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/button/NavigationIconResolverTest.java +0 -78
  85. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllerTest.java +0 -80
  86. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistryTest.java +0 -56
  87. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +0 -216
  88. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/ExternalComponentViewControllerTest.java +0 -97
  89. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/FragmentCreatorMock.java +0 -34
  90. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/SomeFragment.java +0 -8
  91. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/fakes/FakeParentController.kt +0 -33
  92. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorMock.java +0 -40
  93. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorTest.kt +0 -213
  94. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenterTest.java +0 -319
  95. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +0 -367
  96. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java +0 -898
  97. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/RootPresenterTest.kt +0 -254
  98. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManagerTest.java +0 -108
  99. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/parent/ParentControllerTest.java +0 -299
  100. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java +0 -446
  101. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/BackButtonHelperTest.java +0 -77
  102. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/FloatingActionButtonTest.java +0 -154
  103. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/IdStackTest.java +0 -114
  104. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackAnimatorTest.kt +0 -241
  105. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.kt +0 -1165
  106. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenterTest.kt +0 -1081
  107. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarButtonControllerTest.java +0 -61
  108. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarReactViewControllerTest.java +0 -43
  109. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarButtonControllerTest.java +0 -120
  110. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarControllerTest.kt +0 -432
  111. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewControllerTest.java +0 -249
  112. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerTest.java +0 -337
  113. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegateTest.java +0 -68
  114. package/lib/android/app/src/test/java/com/reactnativenavigation/views/OverlayTouchDelegateTest.java +0 -60
  115. package/lib/android/app/src/test/java/com/reactnativenavigation/views/TitleAndButtonsContainerTest.kt +0 -477
  116. package/lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java +0 -82
  117. package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/BaseViewAnimatorTest.kt +0 -109
  118. package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/DefaultViewAnimatorCreatorFake.kt +0 -36
  119. package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainerTest.kt +0 -101
  120. package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsTest.kt +0 -40
  121. package/lib/android/app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +0 -1
@@ -1,898 +0,0 @@
1
- package com.reactnativenavigation.viewcontrollers.navigator;
2
-
3
- import android.os.Bundle;
4
- import android.view.View;
5
- import android.view.ViewGroup;
6
- import android.widget.FrameLayout;
7
-
8
- import androidx.annotation.NonNull;
9
-
10
- import com.facebook.react.ReactInstanceManager;
11
- import com.reactnativenavigation.BaseTest;
12
- import com.reactnativenavigation.TestActivity;
13
- import com.reactnativenavigation.TestUtils;
14
- import com.reactnativenavigation.mocks.ImageLoaderMock;
15
- import com.reactnativenavigation.mocks.SimpleComponentViewController;
16
- import com.reactnativenavigation.mocks.SimpleViewController;
17
- import com.reactnativenavigation.mocks.TypefaceLoaderMock;
18
- import com.reactnativenavigation.options.ModalOptions;
19
- import com.reactnativenavigation.options.ModalPresentationStyle;
20
- import com.reactnativenavigation.options.Options;
21
- import com.reactnativenavigation.options.params.Bool;
22
- import com.reactnativenavigation.options.params.Text;
23
- import com.reactnativenavigation.react.CommandListener;
24
- import com.reactnativenavigation.react.CommandListenerAdapter;
25
- import com.reactnativenavigation.react.events.EventEmitter;
26
- import com.reactnativenavigation.utils.CompatUtils;
27
- import com.reactnativenavigation.utils.ImageLoader;
28
- import com.reactnativenavigation.utils.OptionHelper;
29
- import com.reactnativenavigation.utils.ViewUtils;
30
- import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabPresenter;
31
- import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsAnimator;
32
- import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
33
- import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsPresenter;
34
- import com.reactnativenavigation.viewcontrollers.bottomtabs.attacher.BottomTabsAttacher;
35
- import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
36
- import com.reactnativenavigation.viewcontrollers.component.ComponentViewController;
37
- import com.reactnativenavigation.viewcontrollers.modal.ModalStack;
38
- import com.reactnativenavigation.viewcontrollers.overlay.OverlayManager;
39
- import com.reactnativenavigation.viewcontrollers.stack.StackController;
40
- import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
41
- import com.reactnativenavigation.viewcontrollers.viewcontroller.RootPresenter;
42
- import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
43
- import com.reactnativenavigation.views.bottomtabs.BottomTabs;
44
-
45
- import org.junit.Test;
46
- import org.mockito.ArgumentCaptor;
47
- import org.mockito.Mockito;
48
- import org.robolectric.android.controller.ActivityController;
49
- import org.robolectric.annotation.Config;
50
-
51
- import java.util.Arrays;
52
- import java.util.Collections;
53
- import java.util.List;
54
-
55
- import static org.assertj.core.api.Java6Assertions.assertThat;
56
- import static org.junit.Assert.assertTrue;
57
- import static org.mockito.ArgumentMatchers.any;
58
- import static org.mockito.ArgumentMatchers.eq;
59
- import static org.mockito.Mockito.never;
60
- import static org.mockito.Mockito.spy;
61
- import static org.mockito.Mockito.times;
62
- import static org.mockito.Mockito.verify;
63
- import static org.mockito.Mockito.when;
64
-
65
- @Config(qualifiers = "xxhdpi")
66
- public class NavigatorTest extends BaseTest {
67
- private TestActivity activity;
68
- private ChildControllersRegistry childRegistry;
69
- private Navigator uut;
70
- private RootPresenter rootPresenter;
71
- private StackController parentController;
72
- private SimpleViewController child1;
73
- private ViewController<?> child2;
74
- private ViewController<?> child3;
75
- private ViewController<?> child4;
76
- private ViewController<?> child5;
77
- private final Options tabOptions = OptionHelper.createBottomTabOptions();
78
- private ImageLoader imageLoaderMock;
79
- private ActivityController<TestActivity> activityController;
80
- private OverlayManager overlayManager;
81
- private EventEmitter eventEmitter;
82
- private ViewController.ViewVisibilityListener parentVisibilityListener;
83
- private ModalStack modalStack;
84
- private ReactInstanceManager reactInstanceManager;
85
-
86
- @Override
87
- public void beforeEach() {
88
- super.beforeEach();
89
- childRegistry = new ChildControllersRegistry();
90
- eventEmitter = Mockito.mock(EventEmitter.class);
91
- reactInstanceManager = Mockito.mock(ReactInstanceManager.class);
92
- overlayManager = spy(new OverlayManager());
93
- imageLoaderMock = ImageLoaderMock.mock();
94
- activityController = newActivityController(TestActivity.class);
95
- activity = activityController.create().get();
96
- modalStack = spy(new ModalStack(activity));
97
- rootPresenter = spy(new RootPresenter());
98
- modalStack.setEventEmitter(Mockito.mock(EventEmitter.class));
99
- uut = new Navigator(activity, childRegistry, modalStack, overlayManager, rootPresenter);
100
- activity.setNavigator(uut);
101
-
102
- ViewController<?> initialChild = new SimpleViewController(activity, childRegistry, "initialChild", Options.EMPTY);
103
- parentController = newStack(initialChild);
104
- parentVisibilityListener = spy(new ViewController.ViewVisibilityListener() {
105
- @Override
106
- public boolean onViewAppeared(View view) {
107
- return false;
108
- }
109
-
110
- @Override
111
- public boolean onViewDisappear(View view) {
112
- return false;
113
- }
114
- });
115
- parentController.setViewVisibilityListener(parentVisibilityListener);
116
- child1 = new SimpleViewController(activity, childRegistry, "child1", tabOptions);
117
- child2 = new SimpleViewController(activity, childRegistry, "child2", tabOptions);
118
- child3 = new SimpleViewController(activity, childRegistry, "child3", tabOptions);
119
- child4 = new SimpleViewController(activity, childRegistry, "child4", tabOptions);
120
- child5 = new SimpleViewController(activity, childRegistry, "child5", tabOptions);
121
-
122
- uut.bindViews();
123
-
124
- activityController.visible();
125
- activityController.postCreate(Bundle.EMPTY);
126
- idleMainLooper();
127
- }
128
-
129
- @Test
130
- public void onConfigurationChange_shouldCallOnConfigurationChangedForModals() {
131
- Navigator spyUUT = spy(uut);
132
- SimpleViewController spyChild1 = spy(child1);
133
- ViewController<?> spyChild2 = spy(child2);
134
- ViewController<?> spyChild3 = spy(child3);
135
-
136
- spyUUT.setRoot(spyChild1, new CommandListenerAdapter(), reactInstanceManager);
137
- spyUUT.showModal(spyChild2, new CommandListenerAdapter());
138
- spyUUT.showModal(spyChild3, new CommandListenerAdapter());
139
- spyUUT.onConfigurationChanged(mockConfiguration);
140
-
141
- verify(spyChild2).onConfigurationChanged(any());
142
- verify(spyChild3).onConfigurationChanged(any());
143
- }
144
-
145
- @Test
146
- public void onConfigurationChange_shouldCallOnConfigurationChangedForOverlays() {
147
- Navigator spyUUT = spy(uut);
148
- SimpleViewController spyChild1 = spy(child1);
149
- ViewController<?> spyChild2 = spy(child2);
150
- ViewController<?> spyChild3 = spy(child3);
151
-
152
- spyUUT.setRoot(spyChild1, new CommandListenerAdapter(), reactInstanceManager);
153
- spyUUT.showOverlay(spyChild2, new CommandListenerAdapter());
154
- spyUUT.showOverlay(spyChild3, new CommandListenerAdapter());
155
- spyUUT.onConfigurationChanged(mockConfiguration);
156
-
157
- verify(spyChild2).onConfigurationChanged(any());
158
- verify(spyChild3).onConfigurationChanged(any());
159
- }
160
-
161
- @Test
162
- public void setContentLayout() {
163
- ViewGroup contentLayout = Mockito.mock(ViewGroup.class);
164
- uut.setContentLayout(contentLayout);
165
- }
166
-
167
- @Test
168
- public void setContentLayout_modalAndOverlayLayoutsAreGONE() {
169
- ViewGroup contentLayout = Mockito.mock(ViewGroup.class);
170
- uut.setContentLayout(contentLayout);
171
- assertThat(uut.getModalsLayout().getVisibility()).isEqualTo(View.GONE);
172
- assertThat(uut.getOverlaysLayout().getVisibility()).isEqualTo(View.GONE);
173
- }
174
-
175
- @Test
176
- public void bindViews() {
177
- verify(rootPresenter).setRootContainer(uut.getRootLayout());
178
- verify(modalStack).setModalsLayout(uut.getModalsLayout());
179
- }
180
-
181
- @Test
182
- public void shouldCallOnViewDidAppearWhenHostResumes() {
183
- SimpleViewController child1 = spy(this.child1);
184
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
185
- uut.onHostResume();
186
- verify(child1, times(2)).onViewDidAppear();
187
- }
188
-
189
- @Test
190
- public void shouldCallOverlaysOnHostResumeWhenHostResumes() {
191
- SimpleViewController child1 = spy(this.child1);
192
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
193
- uut.onHostResume();
194
- verify(overlayManager).onHostResume();
195
- }
196
-
197
- @Test
198
- public void shouldCallOverlaysChildrenOnViewDidAppearOnHostResume() {
199
- SimpleViewController child1 = spy(this.child1);
200
- ViewController<?> child2 = spy(this.child2);
201
- ViewController<?> child3 = spy(this.child3);
202
-
203
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
204
- uut.showOverlay(child2, new CommandListenerAdapter());
205
- uut.showOverlay(child3, new CommandListenerAdapter());
206
- verify(child1, times(1)).onViewDidAppear();
207
-
208
- uut.onHostResume();
209
-
210
- verify(overlayManager).onHostResume();
211
- verify(child1, times(2)).onViewDidAppear();
212
- verify(child2).onViewDidAppear();
213
- verify(child3).onViewDidAppear();
214
- }
215
-
216
- @Test
217
- public void shouldCallRootOnViewDidAppearWhenModalDisplayedOverContext(){
218
- SimpleViewController child1 = spy(this.child1);
219
- final Options overContextOptions = tabOptions.copy();
220
- overContextOptions.modal =new ModalOptions();
221
- overContextOptions.modal.presentationStyle = ModalPresentationStyle.OverCurrentContext;
222
- ViewController<?> overContextModal = spy(new SimpleViewController(activity, childRegistry, "overContextModal",
223
- overContextOptions));
224
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
225
- uut.showModal(overContextModal, new CommandListenerAdapter());
226
- uut.onHostResume();
227
-
228
- verify(child1, times(2)).onViewDidAppear();
229
- verify(overContextModal, times(1)).onViewDidAppear();
230
- }
231
-
232
- @Test
233
- public void shouldCallRootOnViewDisappearWhenModalDisplayedOverContext(){
234
- SimpleViewController child1 = spy(this.child1);
235
- final Options overContextOptions = tabOptions.copy();
236
- overContextOptions.modal =new ModalOptions();
237
- overContextOptions.modal.presentationStyle = ModalPresentationStyle.OverCurrentContext;
238
- ViewController<?> overContextModal = spy(new SimpleViewController(activity, childRegistry, "overContextModal",
239
- overContextOptions));
240
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
241
- uut.showModal(overContextModal, new CommandListenerAdapter());
242
- uut.onHostPause();
243
-
244
- verify(child1, times(1)).onViewDisappear();
245
- verify(overContextModal, times(1)).onViewDisappear();
246
- }
247
-
248
- @Test
249
- public void shouldCallModalOnViewDisappearWhenModalDisplayedOverContextUnderneath(){
250
- SimpleViewController child1 = spy(this.child1);
251
- ViewController<?> child2 = spy(this.child2);
252
- final Options overContextOptions = tabOptions.copy();
253
- overContextOptions.modal =new ModalOptions();
254
- overContextOptions.modal.presentationStyle = ModalPresentationStyle.OverCurrentContext;
255
- ViewController<?> overContextModal = spy(new SimpleViewController(activity, childRegistry, "overContextModal",
256
- overContextOptions));
257
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
258
- uut.showModal(overContextModal, new CommandListenerAdapter());
259
- uut.showModal(child2, new CommandListenerAdapter());
260
- uut.onHostPause();
261
-
262
- verify(child2, times(1)).onViewDisappear();
263
- verify(overContextModal, never()).onViewDisappear();
264
- }
265
- @Test
266
- public void shouldCallOverlaysAndModalsChildrenOnViewDidAppearOnHostResume() {
267
- SimpleViewController child1 = spy(this.child1);
268
- ViewController<?> child2 = spy(this.child2);
269
- ViewController<?> child3 = spy(this.child3);
270
- ViewController<?> child4 = spy(this.child4);
271
-
272
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
273
- uut.showModal(child2, new CommandListenerAdapter());
274
- uut.showOverlay(child3, new CommandListenerAdapter());
275
- uut.showOverlay(child4, new CommandListenerAdapter());
276
- verify(child1, times(1)).onViewDidAppear();
277
-
278
- uut.onHostResume();
279
-
280
- verify(overlayManager).onHostResume();
281
- verify(child1, times(1)).onViewDidAppear();
282
- verify(child2).onViewDidAppear();
283
- verify(child3).onViewDidAppear();
284
- verify(child4).onViewDidAppear();
285
- }
286
-
287
- @Test
288
- public void shouldNotCallModalOnHostResumeWhenHostResumesAndNoModals() {
289
- SimpleViewController child1 = spy(this.child1);
290
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
291
- uut.onHostResume();
292
- verify(modalStack, never()).onHostResume();
293
- }
294
-
295
- @Test
296
- public void shouldCallModalPeekDidAppearWhenHostResumes() {
297
- SimpleViewController child1 = spy(this.child1);
298
- ViewController<?> child2 = spy(this.child2);
299
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
300
- uut.showModal(child2, new CommandListenerAdapter());
301
- uut.onHostResume();
302
-
303
- verify(modalStack).onHostResume();
304
- verify(child2).onViewDidAppear();
305
- verify(child1, times(1)).onViewDidAppear();
306
- }
307
-
308
- @Test
309
- public void shouldCallOnViewDisappearWhenHostPauses() {
310
- SimpleViewController child1 = spy(this.child1);
311
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
312
- uut.onHostPause();
313
- verify(child1).onViewDidAppear();
314
- }
315
-
316
- @Test
317
- public void shouldNotCallModalOnHostPauseWhenHostPausesAndNoModals() {
318
- SimpleViewController child1 = spy(this.child1);
319
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
320
- uut.onHostPause();
321
- verify(modalStack, never()).onHostPause();
322
- }
323
-
324
- @Test
325
- public void shouldCallModalPeekDidDisappearWhenHostPauses() {
326
- SimpleViewController child1 = spy(this.child1);
327
- ViewController<?> child2 = spy(this.child2);
328
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
329
- uut.showModal(child2, new CommandListenerAdapter());
330
- uut.onHostPause();
331
-
332
- verify(modalStack).onHostPause();
333
- verify(child2).onViewDisappear();
334
- }
335
-
336
-
337
- @Test
338
- public void setDefaultOptions() {
339
- uut.setDefaultOptions(new Options());
340
-
341
- SimpleViewController spy = spy(child1);
342
- uut.setRoot(spy, new CommandListenerAdapter(), reactInstanceManager);
343
- Options defaultOptions = new Options();
344
- uut.setDefaultOptions(defaultOptions);
345
-
346
- verify(spy).setDefaultOptions(defaultOptions);
347
- verify(modalStack).setDefaultOptions(defaultOptions);
348
- }
349
-
350
- @Test
351
- public void setRoot_delegatesToRootPresenter() {
352
- CommandListenerAdapter listener = new CommandListenerAdapter();
353
- uut.setRoot(child1, listener, reactInstanceManager);
354
- ArgumentCaptor<CommandListenerAdapter> captor = ArgumentCaptor.forClass(CommandListenerAdapter.class);
355
- verify(rootPresenter).setRoot(eq(child1), eq(null), eq(uut.getDefaultOptions()), captor.capture(), eq(reactInstanceManager));
356
- assertThat(captor.getValue().getListener()).isEqualTo(listener);
357
- }
358
-
359
-
360
- @Test
361
- public void setRoot_clearsSplashLayout() {
362
- FrameLayout content = activity.findViewById(android.R.id.content);
363
- assertThat(content.getChildCount()).isEqualTo(4); // 3 frame layouts (root, modal and overlay containers) and the default splash layout
364
-
365
- uut.setRoot(child2, new CommandListenerAdapter(), reactInstanceManager);
366
-
367
- assertThat(content.getChildCount()).isEqualTo(3);
368
- }
369
-
370
- @Test
371
- public void setRoot_AddsChildControllerView() {
372
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
373
- assertIsChild(uut.getRootLayout(), child1.getView());
374
- }
375
-
376
- @Test
377
- public void setRoot_ReplacesExistingChildControllerViews() {
378
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
379
- uut.setRoot(child2, new CommandListenerAdapter(), reactInstanceManager);
380
- assertIsChild(uut.getRootLayout(), child2.getView());
381
- }
382
-
383
- @Test
384
- public void setRoot_withWaitForRender() {
385
- ViewController<?> initialRoot = spy(child2);
386
- uut.setRoot(initialRoot, new CommandListenerAdapter(), reactInstanceManager);
387
-
388
- child3.options.animations.setRoot.getEnter().waitForRender = new Bool(true);
389
- ViewController<?> secondRoot = spy(child3);
390
- CommandListenerAdapter listener = spy(new CommandListenerAdapter());
391
- uut.setRoot(secondRoot, listener, reactInstanceManager);
392
-
393
- verify(secondRoot).addOnAppearedListener(any());
394
-
395
- secondRoot.getView().addView(new View(activity)); // make isRendered return true and trigger onViewAppeared
396
- idleMainLooper();
397
- assertThat(initialRoot.isDestroyed()).isTrue();
398
- assertThat(secondRoot.isViewShown()).isEqualTo(true);
399
- }
400
-
401
- @Test
402
- public void setRoot_destroysModals() {
403
- uut.showModal(child1, new CommandListenerAdapter());
404
- uut.setRoot(child2, new CommandListenerAdapter(), reactInstanceManager);
405
- assertTrue(child1.isDestroyed());
406
- }
407
-
408
- @Test
409
- public void hasUniqueId() {
410
- assertThat(uut.getId()).startsWith("navigator");
411
- assertThat(new Navigator(activity, childRegistry, modalStack, overlayManager, rootPresenter).getId()).isNotEqualTo(uut.getId());
412
- }
413
-
414
- @Test
415
- public void push() {
416
- StackController stackController = newStack();
417
- stackController.push(child1, new CommandListenerAdapter());
418
- uut.setRoot(stackController, new CommandListenerAdapter(), reactInstanceManager);
419
-
420
- assertIsChild(uut.getView(), stackController.getView());
421
- assertIsChild(stackController.getView(), child1.getView());
422
-
423
- uut.push(child1.getId(), child2, new CommandListenerAdapter());
424
-
425
- assertIsChild(uut.getView(), stackController.getView());
426
- assertIsChild(stackController.getView(), child2.getView());
427
- }
428
-
429
- @Test
430
- public void push_InvalidPushWithoutAStack_DoesNothing() {
431
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
432
- uut.push(child1.getId(), child2, new CommandListenerAdapter());
433
- assertIsChild(uut.getView(), child1.getView());
434
- }
435
-
436
- @Test
437
- public void push_OnCorrectStackByFindingChildId() {
438
- StackController stack1 = newStack();
439
- stack1.ensureViewIsCreated();
440
- StackController stack2 = newStack();
441
- stack2.ensureViewIsCreated();
442
- stack1.push(child1, new CommandListenerAdapter());
443
- stack2.push(child2, new CommandListenerAdapter());
444
- BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
445
- uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
446
-
447
- SimpleViewController newChild = new SimpleViewController(activity, childRegistry, "new child", tabOptions);
448
- uut.push(child2.getId(), newChild, new CommandListenerAdapter());
449
-
450
- assertThat(stack1.getChildControllers()).doesNotContain(newChild);
451
- assertThat(stack2.getChildControllers()).contains(newChild);
452
- }
453
-
454
- @Test
455
- public void push_rejectIfNotContainedInStack() {
456
- CommandListener listener = Mockito.mock(CommandListener.class);
457
- uut.push("someId", child1, listener);
458
- verify(listener).onError(any());
459
- }
460
-
461
- @Test
462
- public void pop_InvalidDoesNothing() {
463
- uut.pop("123", Options.EMPTY, new CommandListenerAdapter());
464
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
465
- uut.pop(child1.getId(), Options.EMPTY, new CommandListenerAdapter());
466
- assertThat(uut.getChildControllers()).hasSize(1);
467
- }
468
-
469
- @Test
470
- public void pop_FromCorrectStackByFindingChildId() {
471
- StackController stack1 = newStack(child1);
472
- StackController stack2 = newStack(child2);
473
- BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
474
- uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
475
- stack2.push(child3, new CommandListenerAdapter() {
476
- @Override
477
- public void onSuccess(String childId) {
478
- stack2.push(child4, new CommandListenerAdapter() {
479
- @Override
480
- public void onSuccess(String childId) {
481
- uut.pop("child4", Options.EMPTY, new CommandListenerAdapter());
482
- assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
483
- }
484
- }
485
- );
486
- }
487
- });
488
- }
489
-
490
- @Test
491
- public void pop_byStackId() {
492
- disablePushAnimation(child1, child2);
493
- disablePopAnimation(child2, child1);
494
- StackController stack = newStack(child1, child2);
495
- stack.ensureViewIsCreated();
496
- uut.setRoot(stack, new CommandListenerAdapter(), reactInstanceManager);
497
-
498
- uut.pop(stack.getId(), Options.EMPTY, new CommandListenerAdapter());
499
- assertThat(stack.getChildControllers()).containsOnly(child1);
500
- }
501
-
502
- @Test
503
- public void popTo_FromCorrectStackUpToChild() {
504
- disablePushAnimation(child5);
505
-
506
- StackController stack1 = newStack(child1);
507
- StackController stack2 = newStack(child2, child3, child4);
508
- BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
509
- uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
510
- idleMainLooper();
511
- CommandListenerAdapter listener = spy(new CommandListenerAdapter() {
512
- @Override
513
- public void onSuccess(String childId) {
514
- uut.popTo(child2.getId(), Options.EMPTY, new CommandListenerAdapter());
515
- assertThat(stack2.getChildControllers()).containsOnly(child2);
516
- }
517
- });
518
- stack2.push(child5, listener);
519
- verify(listener).onSuccess(child5.getId());
520
- }
521
-
522
- @Test
523
- public void popToRoot() {
524
- StackController stack1 = newStack(child1);
525
- StackController stack2 = newStack(child2, child3, child4);
526
- BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
527
- uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
528
-
529
- stack2.push(child5, new CommandListenerAdapter() {
530
- @Override
531
- public void onSuccess(String childId) {
532
- uut.popToRoot(child3.getId(), Options.EMPTY, new CommandListenerAdapter());
533
- assertThat(stack2.getChildControllers()).containsOnly(child2);
534
- }
535
- });
536
- }
537
-
538
- @Test
539
- public void setStackRoot() {
540
- disablePushAnimation(child1, child2, child3);
541
-
542
- StackController stack = newStack(child1, child2);
543
- uut.setRoot(stack, new CommandListenerAdapter(), reactInstanceManager);
544
-
545
- stack.setRoot(Collections.singletonList(child3), new CommandListenerAdapter());
546
-
547
- assertThat(stack.getChildControllers()).containsOnly(child3);
548
- }
549
-
550
- @Test
551
- public void handleBack_DelegatesToRoot() {
552
- assertThat(uut.handleBack(new CommandListenerAdapter())).isFalse();
553
-
554
- ViewController<?> root = spy(child1);
555
- uut.setRoot(root, new CommandListenerAdapter(), reactInstanceManager);
556
- when(root.handleBack(any(CommandListener.class))).thenReturn(true);
557
- assertThat(uut.handleBack(new CommandListenerAdapter())).isTrue();
558
- verify(root, times(1)).handleBack(any());
559
- }
560
-
561
- @Test
562
- public void handleBack_modalTakePrecedenceOverRoot() {
563
- ViewController<?> root = spy(child1);
564
- uut.setRoot(root, new CommandListenerAdapter(), reactInstanceManager);
565
- uut.showModal(child2, new CommandListenerAdapter());
566
- verify(root, times(0)).handleBack(new CommandListenerAdapter());
567
- }
568
-
569
- @Test
570
- public void mergeOptions_CallsApplyNavigationOptions() {
571
- ComponentViewController componentVc = new SimpleComponentViewController(activity, childRegistry, "theId", new Options());
572
- componentVc.setParentController(parentController);
573
- assertThat(componentVc.options.topBar.title.text.get("")).isEmpty();
574
- uut.setRoot(componentVc, new CommandListenerAdapter(), reactInstanceManager);
575
-
576
- Options options = new Options();
577
- options.topBar.title.text = new Text("new title");
578
-
579
- uut.mergeOptions("theId", options);
580
- assertThat(componentVc.options.topBar.title.text.get()).isEqualTo("new title");
581
- }
582
-
583
- @Test
584
- public void mergeOptions_AffectsOnlyComponentViewControllers() {
585
- uut.mergeOptions("some unknown child id", new Options());
586
- }
587
-
588
- @NonNull
589
- private BottomTabsController newTabs(List<ViewController<?>> tabs) {
590
- BottomTabsPresenter bottomTabsPresenter = new BottomTabsPresenter(tabs, new Options(), new BottomTabsAnimator());
591
- return new BottomTabsController(activity, tabs, childRegistry, eventEmitter, imageLoaderMock, "tabsController", new Options(), new Presenter(activity, new Options()), new BottomTabsAttacher(tabs, bottomTabsPresenter, Options.EMPTY), bottomTabsPresenter, new BottomTabPresenter(activity, tabs, ImageLoaderMock.mock(), new TypefaceLoaderMock(), new Options())) {
592
- @NonNull
593
- @Override
594
- protected BottomTabs createBottomTabs() {
595
- return new BottomTabs(activity) {
596
- @Override
597
- protected void createItems() {
598
-
599
- }
600
- };
601
- }
602
- };
603
- }
604
-
605
- @Test
606
- public void findController_root() {
607
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
608
- assertThat(uut.findController(child1.getId())).isEqualTo(child1);
609
- }
610
-
611
- @Test
612
- public void findController_overlay() {
613
- uut.showOverlay(child1, new CommandListenerAdapter());
614
- assertThat(uut.findController(child1.getId())).isEqualTo(child1);
615
- }
616
-
617
- @Test
618
- public void findController_modal() {
619
- uut.showModal(child1, new CommandListenerAdapter());
620
- assertThat(uut.findController(child1.getId())).isEqualTo(child1);
621
- }
622
-
623
- @Test
624
- public void push_promise() {
625
- final StackController stackController = newStack();
626
- stackController.push(child1, new CommandListenerAdapter());
627
- uut.setRoot(stackController, new CommandListenerAdapter(), reactInstanceManager);
628
-
629
- assertIsChild(uut.getView(), stackController.getView());
630
- assertIsChild(stackController.getView(), child1.getView());
631
-
632
- uut.push(child1.getId(), child2, new CommandListenerAdapter() {
633
- @Override
634
- public void onSuccess(String childId) {
635
- assertIsChild(uut.getView(), stackController.getView());
636
- assertIsChild(stackController.getView(), child2.getView());
637
- }
638
- });
639
- }
640
-
641
- @Test
642
- public void push_InvalidPushWithoutAStack_DoesNothing_Promise() {
643
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
644
- uut.push(child1.getId(), child2, new CommandListenerAdapter() {
645
- @Override
646
- public void onError(String message) {
647
- assertIsChild(uut.getView(), child1.getView());
648
- }
649
- });
650
-
651
- }
652
-
653
- @Test
654
- public void pop_InvalidDoesNothing_Promise() {
655
- uut.pop("123", Options.EMPTY, new CommandListenerAdapter());
656
- uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
657
- uut.pop(child1.getId(), Options.EMPTY, new CommandListenerAdapter() {
658
- @Override
659
- public void onError(String reason) {
660
- assertThat(uut.getChildControllers()).hasSize(1);
661
- }
662
- });
663
- }
664
-
665
- @Test
666
- public void pop_FromCorrectStackByFindingChildId_Promise() {
667
- disablePushAnimation(child4);
668
-
669
- StackController stack1 = newStack(child1);
670
- final StackController stack2 = newStack(child2, child3);
671
- BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
672
- uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
673
- idleMainLooper();
674
- CommandListenerAdapter listener = spy(new CommandListenerAdapter() {
675
- @Override
676
- public void onSuccess(String childId) {
677
- uut.pop("child4", Options.EMPTY, new CommandListenerAdapter());
678
- assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
679
- }
680
- });
681
- stack2.push(child4, listener);
682
- verify(listener).onSuccess(child4.getId());
683
- }
684
-
685
- @Test
686
- public void pushIntoModal() {
687
- uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
688
- StackController stackController = newStack();
689
- stackController.push(child1, new CommandListenerAdapter());
690
- uut.showModal(stackController, new CommandListenerAdapter());
691
- uut.push(stackController.getId(), child2, new CommandListenerAdapter());
692
- assertIsChild(stackController.getView(), child2.getView());
693
- }
694
-
695
- @Test
696
- public void pushedStackCanBePopped() {
697
- StackController spy = spy(parentController);
698
- disablePushAnimation(spy, child2);
699
- spy.push(child2, new CommandListenerAdapter());
700
-
701
- StackController parent = newStack(spy);
702
- parent.options.animations.setRoot.getEnter().enabled = new Bool(false);
703
-
704
- uut.setRoot(parent, new CommandListenerAdapter(), reactInstanceManager);
705
-
706
- CommandListenerAdapter listener = new CommandListenerAdapter() {
707
- @Override
708
- public void onSuccess(String childId) {
709
- assertThat(spy.getChildControllers().size()).isEqualTo(1);
710
- }
711
- };
712
- disablePopAnimation(child2);
713
- uut.pop("child2", Options.EMPTY, listener);
714
- verify(spy, times(1)).pop(Options.EMPTY, listener);
715
- }
716
-
717
- @Test
718
- public void showModal_onViewDisappearIsInvokedOnRoot() {
719
- uut.setRoot(parentController, new CommandListenerAdapter() {
720
- @Override
721
- public void onSuccess(String childId) {
722
- idleMainLooper();
723
- verify(parentVisibilityListener).onViewAppeared(parentController.getView());
724
-
725
- uut.showModal(child1, new CommandListenerAdapter() {
726
- @Override
727
- public void onSuccess(String childId) {
728
- assertThat(parentController.getView().getParent()).isNull();
729
- idleMainLooper();
730
- verify(parentVisibilityListener).onViewDisappear(parentController.getView());
731
- }
732
- });
733
- }
734
- }, reactInstanceManager);
735
- }
736
-
737
- @Test
738
- public void dismissModal_onViewAppearedInvokedOnRoot() {
739
- disableModalAnimations(child1);
740
- disablePushAnimation(child2);
741
-
742
- parentController.push(child2, new CommandListenerAdapter());
743
- uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
744
- idleMainLooper();
745
- verify(parentVisibilityListener).onViewAppeared(parentController.getView());
746
-
747
- uut.showModal(child1, new CommandListenerAdapter());
748
- idleMainLooper();
749
- assertThat(parentController.getView().getParent()).isNull();
750
- verify(parentVisibilityListener).onViewDisappear(parentController.getView());
751
-
752
- uut.dismissModal(child1.getId(), new CommandListenerAdapter());
753
- idleMainLooper();
754
- assertThat(parentController.getView().getParent()).isNotNull();
755
- verify(parentVisibilityListener, times(2)).onViewAppeared(parentController.getView());
756
- }
757
-
758
- @Test
759
- public void dismissModal_reattachedToRoot() {
760
- disableModalAnimations(child1);
761
-
762
- uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
763
- assertThat(ViewUtils.isChildOf(uut.getRootLayout(), parentController.getView())).isTrue();
764
- uut.showModal(child1, new CommandListenerAdapter());
765
-
766
- uut.dismissModal(child1.getId(), new CommandListenerAdapter());
767
- assertThat(ViewUtils.isChildOf(uut.getRootLayout(), parentController.getView())).isTrue();
768
- }
769
-
770
- @Test
771
- public void dismissModal_rejectIfRootIsNotSetAndSingleModalIsDisplayed() {
772
- disableModalAnimations(child1, child2);
773
- uut.showModal(child1, new CommandListenerAdapter());
774
- uut.showModal(child2, new CommandListenerAdapter());
775
-
776
- CommandListenerAdapter listener1 = spy(new CommandListenerAdapter());
777
- uut.dismissModal(child2.getId(), listener1);
778
- verify(listener1).onSuccess(any());
779
- assertThat(child2.isDestroyed()).isTrue();
780
-
781
- CommandListenerAdapter listener2 = spy(new CommandListenerAdapter());
782
- uut.dismissModal(child1.getId(), listener2);
783
- verify(listener2).onError(any());
784
- assertThat(child1.isDestroyed()).isFalse();
785
- }
786
-
787
- @Test
788
- public void dismissAllModals_onViewAppearedInvokedOnRoot() {
789
- disableModalAnimations(child1);
790
- disablePushAnimation(child2);
791
-
792
- parentController.push(child2, new CommandListenerAdapter());
793
- uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
794
- idleMainLooper();
795
- verify(parentVisibilityListener).onViewAppeared(parentController.getView());
796
-
797
- uut.showModal(child1, new CommandListenerAdapter());
798
- idleMainLooper();
799
- assertThat(parentController.getView().getParent()).isNull();
800
- verify(parentVisibilityListener).onViewDisappear(parentController.getView());
801
-
802
- uut.dismissAllModals(Options.EMPTY, new CommandListenerAdapter());
803
- idleMainLooper();
804
- assertThat(parentController.getView().getParent()).isNotNull();
805
- verify(parentVisibilityListener, times(2)).onViewAppeared(parentController.getView());
806
- }
807
-
808
- @Test
809
- public void handleBack_onViewAppearedInvokedOnRoot() {
810
- disableModalAnimations(child1);
811
- disablePushAnimation(child2);
812
-
813
- parentController.push(child2, new CommandListenerAdapter());
814
- uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
815
- idleMainLooper();
816
- verify(parentVisibilityListener).onViewAppeared(parentController.getView());
817
-
818
- uut.showModal(child1, new CommandListenerAdapter());
819
- idleMainLooper();
820
- assertThat(parentController.getView().getParent()).isNull();
821
- verify(parentVisibilityListener).onViewDisappear(parentController.getView());
822
-
823
- uut.handleBack(new CommandListenerAdapter());
824
- idleMainLooper();
825
- assertThat(parentController.getView().getParent()).isNotNull();
826
- verify(parentVisibilityListener, times(2)).onViewAppeared(parentController.getView());
827
- }
828
-
829
- @Test
830
- public void handleBack_falseIfRootIsNotSetAndSingleModalIsDisplayed() {
831
- disableShowModalAnimation(child1, child2, child3);
832
- uut.showModal(child1, new CommandListenerAdapter());
833
- uut.showModal(child2, new CommandListenerAdapter());
834
-
835
- assertThat(uut.handleBack(new CommandListenerAdapter())).isTrue();
836
- assertThat(uut.handleBack(new CommandListenerAdapter())).isFalse();
837
- }
838
-
839
- @Test
840
- public void destroy_shouldNotChangeViewIds() {
841
- disablePushAnimation(child1);
842
- disableShowModalAnimation(child1, child2, child3);
843
-
844
- StackController spy = spy(parentController);
845
- SimpleViewController.SimpleView view = child1.getView();
846
- ViewGroup view1 = child2.getView();
847
- view.setId(10);
848
- view1.setId(11);
849
- spy.options.animations.setRoot.getEnter().enabled = new Bool(false);
850
- uut.setRoot(spy, new CommandListenerAdapter(), reactInstanceManager);
851
- spy.push(child1, new CommandListenerAdapter());
852
- uut.showModal(child2, new CommandListenerAdapter());
853
- activityController.destroy();
854
- assertThat(view.getId()).isEqualTo(10);
855
- assertThat(view1.getId()).isEqualTo(11);
856
- verify(spy, times(1)).destroy();
857
- }
858
-
859
- @Test
860
- public void destroy_destroyedRoot() {
861
- disablePushAnimation(child1);
862
-
863
- StackController spy = spy(parentController);
864
- spy.options.animations.setRoot.getEnter().enabled = new Bool(false);
865
- uut.setRoot(spy, new CommandListenerAdapter(), reactInstanceManager);
866
- spy.push(child1, new CommandListenerAdapter());
867
- activityController.destroy();
868
- verify(spy, times(1)).destroy();
869
- }
870
-
871
- @Test
872
- public void destroy_destroyOverlayManager() {
873
- uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
874
- activityController.destroy();
875
- verify(overlayManager).destroy(uut.getOverlaysLayout());
876
- }
877
-
878
- @Test
879
- public void destroyViews() {
880
- uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
881
- uut.showModal(child1, new CommandListenerAdapter());
882
- uut.showOverlay(child2, new CommandListenerAdapter());
883
- uut.destroy();
884
- assertThat(childRegistry.size()).isZero();
885
- }
886
-
887
- @NonNull
888
- private StackController newStack(ViewController<?>... children) {
889
- StackController stack = TestUtils.newStackController(activity)
890
- .setChildren(children)
891
- .setChildRegistry(childRegistry)
892
- .setId("stack" + CompatUtils.generateViewId())
893
- .setInitialOptions(tabOptions)
894
- .build();
895
- stack.ensureViewIsCreated();
896
- return stack;
897
- }
898
- }