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.
- package/lib/android/app/build.gradle +12 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/Options.java +2 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/layout/LayoutInsets.kt +44 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/layout/LayoutOptions.kt +71 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/PrimitiveExt.kt +9 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +4 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/navigator/Navigator.java +5 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +23 -7
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewController.java +12 -3
- package/lib/dist/src/interfaces/Options.d.ts +10 -0
- package/lib/ios/RNNBasePresenter.m +17 -0
- package/lib/ios/RNNBottomTabsController.m +1 -0
- package/lib/ios/RNNBridgeManager.mm +5 -3
- package/lib/ios/RNNComponentViewController.m +5 -0
- package/lib/ios/RNNLayoutOptions.h +2 -1
- package/lib/ios/RNNLayoutOptions.m +4 -0
- package/lib/ios/RNNModalHostViewManagerHandler.h +11 -0
- package/lib/ios/RNNModalHostViewManagerHandler.m +40 -0
- package/lib/ios/RNNModalManager.h +2 -2
- package/lib/ios/RNNModalManager.m +0 -26
- package/lib/ios/RNNStackPresenter.m +1 -0
- package/lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj +8 -0
- package/lib/src/interfaces/Options.ts +12 -0
- package/package.json +3 -1
- package/.buildkite/pipeline.yml +0 -59
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/LayoutOptions.java +0 -48
- package/lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java +0 -178
- package/lib/android/app/src/test/java/com/reactnativenavigation/EnvironmentTest.java +0 -43
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestActivity.java +0 -23
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestApplication.java +0 -35
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestUtils.java +0 -62
- package/lib/android/app/src/test/java/com/reactnativenavigation/fakes/IconResolverFake.kt +0 -8
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/BackDrawable.java +0 -30
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/ImageLoaderMock.kt +0 -49
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/Mocks.kt +0 -18
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleComponentViewController.java +0 -15
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleOverlay.java +0 -54
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleViewController.java +0 -113
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java +0 -79
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentViewCreator.java +0 -18
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestReactView.java +0 -71
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarButtonCreatorMock.java +0 -34
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarReactViewCreatorMock.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TopBarBackgroundViewCreatorMock.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.kt +0 -21
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/LayoutNodeParserTest.java +0 -51
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/OptionsTest.java +0 -315
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/OrientationOptionsTest.java +0 -81
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/TopBarButtonsTest.kt +0 -95
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/TransitionAnimationOptionsTest.kt +0 -122
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/BoolParserTest.java +0 -28
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/ColorParseTest.java +0 -50
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/JSONParserTest.java +0 -64
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/PresenterTest.java +0 -56
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/RenderCheckerTest.java +0 -59
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/SideMenuPresenterTest.java +0 -35
- package/lib/android/app/src/test/java/com/reactnativenavigation/react/NavigationModuleTest.java +0 -102
- package/lib/android/app/src/test/java/com/reactnativenavigation/react/ReloadListenerTest.java +0 -24
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/AnimationHelper.kt +0 -33
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonPresenterTest.java +0 -241
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonSpanTest.java +0 -57
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/CompatUtilsTest.java +0 -17
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/LayoutFactoryTest.java +0 -78
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/MotionEventTest.kt +0 -47
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/NativeCommandListenerTest.java +0 -60
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/OptionHelper.java +0 -16
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java +0 -26
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/StringUtilsTest.java +0 -19
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/SystemUiUtilsTest.kt +0 -27
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleAndButtonsMeasurerTest.kt +0 -357
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleBarHelper.java +0 -54
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java +0 -29
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java +0 -22
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ViewHelper.java +0 -9
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java +0 -149
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenterTest.java +0 -206
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsAttacherTest.java +0 -62
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +0 -589
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenterTest.kt +0 -173
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AfterInitialTabTest.java +0 -38
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AttachModeTest.java +0 -86
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/OnSwitchToTabTest.java +0 -31
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/TogetherTest.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/button/NavigationIconResolverTest.java +0 -78
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllerTest.java +0 -80
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistryTest.java +0 -56
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +0 -216
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/ExternalComponentViewControllerTest.java +0 -97
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/FragmentCreatorMock.java +0 -34
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/SomeFragment.java +0 -8
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/fakes/FakeParentController.kt +0 -33
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorMock.java +0 -40
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorTest.kt +0 -213
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenterTest.java +0 -319
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +0 -367
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java +0 -898
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/RootPresenterTest.kt +0 -254
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManagerTest.java +0 -108
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/parent/ParentControllerTest.java +0 -299
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java +0 -446
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/BackButtonHelperTest.java +0 -77
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/FloatingActionButtonTest.java +0 -154
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/IdStackTest.java +0 -114
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackAnimatorTest.kt +0 -241
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.kt +0 -1165
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenterTest.kt +0 -1081
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarButtonControllerTest.java +0 -61
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarReactViewControllerTest.java +0 -43
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarButtonControllerTest.java +0 -120
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarControllerTest.kt +0 -432
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewControllerTest.java +0 -249
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerTest.java +0 -337
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegateTest.java +0 -68
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/OverlayTouchDelegateTest.java +0 -60
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/TitleAndButtonsContainerTest.kt +0 -477
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java +0 -82
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/BaseViewAnimatorTest.kt +0 -109
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/DefaultViewAnimatorCreatorFake.kt +0 -36
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainerTest.kt +0 -101
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsTest.kt +0 -40
- package/lib/android/app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +0 -1
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.navigator
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
5
|
-
import com.facebook.react.ReactInstanceManager
|
|
6
|
-
import com.reactnativenavigation.BaseTest
|
|
7
|
-
import com.reactnativenavigation.TestActivity
|
|
8
|
-
import com.reactnativenavigation.hierarchy.root.RootAnimator
|
|
9
|
-
import com.reactnativenavigation.mocks.SimpleViewController
|
|
10
|
-
import com.reactnativenavigation.options.*
|
|
11
|
-
import com.reactnativenavigation.options.params.Bool
|
|
12
|
-
import com.reactnativenavigation.react.CommandListenerAdapter
|
|
13
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry
|
|
14
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.LayoutDirectionApplier
|
|
15
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.RootPresenter
|
|
16
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController
|
|
17
|
-
import com.reactnativenavigation.views.BehaviourDelegate
|
|
18
|
-
import org.assertj.core.api.Java6Assertions
|
|
19
|
-
import org.junit.Test
|
|
20
|
-
import org.mockito.ArgumentCaptor
|
|
21
|
-
import org.mockito.Mockito
|
|
22
|
-
import org.mockito.kotlin.any
|
|
23
|
-
import org.mockito.kotlin.eq
|
|
24
|
-
import org.mockito.kotlin.never
|
|
25
|
-
import org.robolectric.android.controller.ActivityController
|
|
26
|
-
|
|
27
|
-
class RootPresenterTest : BaseTest() {
|
|
28
|
-
private lateinit var uut: RootPresenter
|
|
29
|
-
private lateinit var rootContainer: CoordinatorLayout
|
|
30
|
-
private lateinit var root: ViewController<*>
|
|
31
|
-
private lateinit var root2: ViewController<*>
|
|
32
|
-
private lateinit var animator: RootAnimator
|
|
33
|
-
private lateinit var layoutDirectionApplier: LayoutDirectionApplier
|
|
34
|
-
private lateinit var defaultOptions: Options
|
|
35
|
-
private lateinit var reactInstanceManager: ReactInstanceManager
|
|
36
|
-
private lateinit var activity: Activity
|
|
37
|
-
private lateinit var activityController: ActivityController<TestActivity>
|
|
38
|
-
private lateinit var root1View: SimpleViewController.SimpleView
|
|
39
|
-
private lateinit var root2View: SimpleViewController.SimpleView
|
|
40
|
-
override fun beforeEach() {
|
|
41
|
-
activityController = newActivityController(TestActivity::class.java)
|
|
42
|
-
activity = activityController.create().get()
|
|
43
|
-
reactInstanceManager = Mockito.mock(ReactInstanceManager::class.java)
|
|
44
|
-
rootContainer = CoordinatorLayout(activity)
|
|
45
|
-
root1View = SimpleViewController.SimpleView(activity)
|
|
46
|
-
root2View = SimpleViewController.SimpleView(activity)
|
|
47
|
-
|
|
48
|
-
root = object : SimpleViewController(activity, ChildControllersRegistry(), "child1", Options()) {
|
|
49
|
-
override fun createView(): SimpleView {
|
|
50
|
-
return root1View
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
root2 = object : SimpleViewController(activity, ChildControllersRegistry(), "child1", Options()) {
|
|
54
|
-
override fun createView(): SimpleView {
|
|
55
|
-
return root2View
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
setupWithAnimator(Mockito.spy(createAnimator()))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@Test
|
|
62
|
-
fun setRoot_viewIsAddedToContainer() {
|
|
63
|
-
uut.setRoot(root, null, defaultOptions, CommandListenerAdapter(), reactInstanceManager)
|
|
64
|
-
Java6Assertions.assertThat(root.view.parent).isEqualTo(rootContainer)
|
|
65
|
-
Java6Assertions.assertThat((root.view.layoutParams as CoordinatorLayout.LayoutParams).behavior).isInstanceOf(BehaviourDelegate::class.java)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@Test
|
|
69
|
-
fun setRoot_reportsOnSuccess() {
|
|
70
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
71
|
-
uut.setRoot(root, null, defaultOptions, listener, reactInstanceManager)
|
|
72
|
-
Mockito.verify(listener).onSuccess(root.id)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Test
|
|
76
|
-
fun setRoot_doesNotAnimateByDefault() {
|
|
77
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
78
|
-
uut.setRoot(root, null, defaultOptions, listener, reactInstanceManager)
|
|
79
|
-
Mockito.verifyNoInteractions(animator)
|
|
80
|
-
Mockito.verify(listener).onSuccess(root.id)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@Test
|
|
84
|
-
fun setRoot_playNoAnimationWhenOptionsHaveThemDisabled() {
|
|
85
|
-
setupWithAnimator(RootAnimator())
|
|
86
|
-
val animatedSetRoot = Options()
|
|
87
|
-
val enter = Mockito.spy(AnimationOptions())
|
|
88
|
-
val exit = Mockito.spy(AnimationOptions())
|
|
89
|
-
enter.enabled = Bool(false)
|
|
90
|
-
exit.enabled = Bool(false)
|
|
91
|
-
Mockito.`when`(enter.hasValue()).thenReturn(true)
|
|
92
|
-
Mockito.`when`(enter.hasAnimation()).thenReturn(true)
|
|
93
|
-
|
|
94
|
-
Mockito.`when`(exit.hasValue()).thenReturn(true)
|
|
95
|
-
Mockito.`when`(exit.hasValue()).thenReturn(true)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
animatedSetRoot.animations.setRoot = createEnterExitTransitionAnim(enter, exit)
|
|
99
|
-
val spy = Mockito.spy(root)
|
|
100
|
-
val spy2 = Mockito.spy(root2)
|
|
101
|
-
Mockito.`when`(spy.resolveCurrentOptions(defaultOptions)).thenReturn(animatedSetRoot)
|
|
102
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
103
|
-
uut.setRoot(spy, spy2, defaultOptions, listener, reactInstanceManager)
|
|
104
|
-
|
|
105
|
-
Mockito.verify(enter, never()).getAnimation(spy.view)
|
|
106
|
-
Mockito.verify(exit, never()).getAnimation(spy2.view)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@Test
|
|
110
|
-
fun setRoot_playEnterAnimOnlyWhenNoDisappearingView() {
|
|
111
|
-
setupWithAnimator(RootAnimator())
|
|
112
|
-
val animatedSetRoot = Options()
|
|
113
|
-
val enter = Mockito.spy(AnimationOptions())
|
|
114
|
-
val exit = Mockito.spy(AnimationOptions())
|
|
115
|
-
|
|
116
|
-
Mockito.`when`(enter.hasValue()).thenReturn(true)
|
|
117
|
-
Mockito.`when`(enter.hasAnimation()).thenReturn(true)
|
|
118
|
-
Mockito.`when`(exit.hasValue()).thenReturn(false)
|
|
119
|
-
|
|
120
|
-
animatedSetRoot.animations.setRoot = createEnterExitTransitionAnim(enter, exit)
|
|
121
|
-
val spy = Mockito.spy(root)
|
|
122
|
-
Mockito.`when`(spy.resolveCurrentOptions(defaultOptions)).thenReturn(animatedSetRoot)
|
|
123
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
124
|
-
uut.setRoot(spy, null, defaultOptions, listener, reactInstanceManager)
|
|
125
|
-
Mockito.verify(enter).getAnimation(spy.view)
|
|
126
|
-
Mockito.verify(exit, never()).getAnimation(spy.view)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@Test
|
|
130
|
-
fun setRoot_playExitAnimOnlyWhenNoEnterAnimation() {
|
|
131
|
-
setupWithAnimator(RootAnimator())
|
|
132
|
-
val animatedSetRoot = Options()
|
|
133
|
-
val enter = Mockito.spy(AnimationOptions())
|
|
134
|
-
val exit = Mockito.spy(AnimationOptions())
|
|
135
|
-
|
|
136
|
-
Mockito.`when`(enter.hasValue()).thenReturn(false)
|
|
137
|
-
Mockito.`when`(enter.hasAnimation()).thenReturn(false)
|
|
138
|
-
|
|
139
|
-
Mockito.`when`(exit.hasValue()).thenReturn(true)
|
|
140
|
-
Mockito.`when`(exit.hasAnimation()).thenReturn(true)
|
|
141
|
-
|
|
142
|
-
animatedSetRoot.animations.setRoot = createEnterExitTransitionAnim(enter, exit)
|
|
143
|
-
val spy = Mockito.spy(root)
|
|
144
|
-
val spy2 = Mockito.spy(root2)
|
|
145
|
-
Mockito.`when`(spy.resolveCurrentOptions(defaultOptions)).thenReturn(animatedSetRoot)
|
|
146
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
147
|
-
uut.setRoot(spy, spy2, defaultOptions, listener, reactInstanceManager)
|
|
148
|
-
Mockito.verify(enter, never()).getAnimation(spy.view)
|
|
149
|
-
Mockito.verify(exit).getAnimation(spy2.view)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
@Test
|
|
154
|
-
fun setRoot_playEnterExitAnimOnBothViews() {
|
|
155
|
-
setupWithAnimator(RootAnimator())
|
|
156
|
-
val animatedSetRoot = Options()
|
|
157
|
-
val enter = Mockito.spy(AnimationOptions())
|
|
158
|
-
val exit = Mockito.spy(AnimationOptions())
|
|
159
|
-
|
|
160
|
-
Mockito.`when`(enter.hasValue()).thenReturn(true)
|
|
161
|
-
Mockito.`when`(enter.hasAnimation()).thenReturn(true)
|
|
162
|
-
|
|
163
|
-
Mockito.`when`(exit.hasValue()).thenReturn(true)
|
|
164
|
-
Mockito.`when`(exit.hasAnimation()).thenReturn(true)
|
|
165
|
-
|
|
166
|
-
animatedSetRoot.animations.setRoot = createEnterExitTransitionAnim(enter, exit)
|
|
167
|
-
val spy = Mockito.spy(root)
|
|
168
|
-
val spy2 = Mockito.spy(root2)
|
|
169
|
-
Mockito.`when`(spy.resolveCurrentOptions(defaultOptions)).thenReturn(animatedSetRoot)
|
|
170
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
171
|
-
uut.setRoot(spy, spy2, defaultOptions, listener, reactInstanceManager)
|
|
172
|
-
|
|
173
|
-
Mockito.verify(enter).getAnimation(spy.view)
|
|
174
|
-
Mockito.verify(exit).getAnimation(spy2.view)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
@Test
|
|
180
|
-
fun setRoot_animates() {
|
|
181
|
-
val animatedSetRoot = Options()
|
|
182
|
-
val enter = Mockito.spy(AnimationOptions())
|
|
183
|
-
Mockito.`when`(enter.hasValue()).thenReturn(true)
|
|
184
|
-
Mockito.`when`(enter.hasAnimation()).thenReturn(true)
|
|
185
|
-
|
|
186
|
-
animatedSetRoot.animations.setRoot = createEnterTransitionAnim(enter)
|
|
187
|
-
val spy = Mockito.spy(root)
|
|
188
|
-
Mockito.`when`(spy.resolveCurrentOptions(defaultOptions)).thenReturn(animatedSetRoot)
|
|
189
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
190
|
-
uut.setRoot(spy, null, defaultOptions, listener, reactInstanceManager)
|
|
191
|
-
Mockito.verify(listener).onSuccess(spy.id)
|
|
192
|
-
Mockito.verify(animator).setRoot(eq(spy), eq(null), eq(animatedSetRoot.animations.setRoot), any())
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
@Test
|
|
196
|
-
fun setRoot_waitForRenderIsSet() {
|
|
197
|
-
root.options.animations.setRoot.enter.waitForRender = Bool(true)
|
|
198
|
-
val spy = Mockito.spy(root)
|
|
199
|
-
uut.setRoot(spy, null, defaultOptions, CommandListenerAdapter(), reactInstanceManager)
|
|
200
|
-
val captor = ArgumentCaptor.forClass(Bool::class.java)
|
|
201
|
-
Mockito.verify(spy).setWaitForRender(captor.capture())
|
|
202
|
-
Java6Assertions.assertThat(captor.value.get()).isTrue()
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
@Test
|
|
206
|
-
fun setRoot_waitForRender() {
|
|
207
|
-
root.options.animations.setRoot.enter.waitForRender = Bool(true)
|
|
208
|
-
val spy = Mockito.spy(root)
|
|
209
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
210
|
-
uut.setRoot(spy, null, defaultOptions, listener, reactInstanceManager)
|
|
211
|
-
Mockito.verify(spy).addOnAppearedListener(any())
|
|
212
|
-
Java6Assertions.assertThat(spy.view.alpha).isZero()
|
|
213
|
-
Mockito.verifyNoInteractions(listener)
|
|
214
|
-
spy.onViewWillAppear()
|
|
215
|
-
idleMainLooper()
|
|
216
|
-
Java6Assertions.assertThat(spy.view.alpha).isOne()
|
|
217
|
-
Mockito.verify(listener).onSuccess(spy.id)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
@Test
|
|
221
|
-
fun setRoot_appliesLayoutDirection() {
|
|
222
|
-
val listener = Mockito.spy(CommandListenerAdapter())
|
|
223
|
-
uut.setRoot(root, null, defaultOptions, listener, reactInstanceManager)
|
|
224
|
-
Mockito.verify(layoutDirectionApplier).apply(root, defaultOptions, reactInstanceManager)
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
private fun createAnimator(): RootAnimator {
|
|
228
|
-
return object : RootAnimator() {
|
|
229
|
-
override fun setRoot(appearing: ViewController<*>, disappearing: ViewController<*>?, setRoot: TransitionAnimationOptions, onAnimationEnd: () -> Unit) {
|
|
230
|
-
super.setRoot(appearing, disappearing, setRoot, onAnimationEnd)
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
private fun createEnterExitTransitionAnim(enter: AnimationOptions, exit: AnimationOptions): TransitionAnimationOptions {
|
|
236
|
-
return TransitionAnimationOptions(enter, exit, SharedElements(), ElementTransitions())
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
private fun createEnterTransitionAnim(enter: AnimationOptions): TransitionAnimationOptions {
|
|
240
|
-
return createEnterExitTransitionAnim(enter, AnimationOptions())
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
private fun createExitTransitionAnim(exit: AnimationOptions): TransitionAnimationOptions {
|
|
244
|
-
return createEnterExitTransitionAnim(AnimationOptions(), exit)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
private fun setupWithAnimator(rootAnimator: RootAnimator) {
|
|
248
|
-
animator = rootAnimator
|
|
249
|
-
layoutDirectionApplier = Mockito.mock(LayoutDirectionApplier::class.java)
|
|
250
|
-
uut = RootPresenter(animator, layoutDirectionApplier)
|
|
251
|
-
uut.setRootContainer(rootContainer)
|
|
252
|
-
defaultOptions = Options()
|
|
253
|
-
}
|
|
254
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.overlay;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.view.View;
|
|
5
|
-
import android.widget.FrameLayout;
|
|
6
|
-
|
|
7
|
-
import com.reactnativenavigation.BaseTest;
|
|
8
|
-
import com.reactnativenavigation.mocks.SimpleViewController;
|
|
9
|
-
import com.reactnativenavigation.options.Options;
|
|
10
|
-
import com.reactnativenavigation.react.CommandListener;
|
|
11
|
-
import com.reactnativenavigation.react.CommandListenerAdapter;
|
|
12
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
13
|
-
|
|
14
|
-
import org.junit.Test;
|
|
15
|
-
|
|
16
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
17
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
18
|
-
import static org.mockito.Mockito.never;
|
|
19
|
-
import static org.mockito.Mockito.spy;
|
|
20
|
-
import static org.mockito.Mockito.times;
|
|
21
|
-
import static org.mockito.Mockito.verify;
|
|
22
|
-
|
|
23
|
-
public class OverlayManagerTest extends BaseTest {
|
|
24
|
-
private static final String OVERLAY_ID_1 = "OVERLAY_1";
|
|
25
|
-
private static final String OVERLAY_ID_2 = "OVERLAY_2";
|
|
26
|
-
|
|
27
|
-
private OverlayManager uut;
|
|
28
|
-
private SimpleViewController overlay1;
|
|
29
|
-
private SimpleViewController overlay2;
|
|
30
|
-
private FrameLayout contentLayout;
|
|
31
|
-
private FrameLayout overlayContainer;
|
|
32
|
-
|
|
33
|
-
@Override
|
|
34
|
-
public void beforeEach() {
|
|
35
|
-
super.beforeEach();
|
|
36
|
-
Activity activity = newActivity();
|
|
37
|
-
contentLayout = new FrameLayout(activity);
|
|
38
|
-
contentLayout.layout(0, 0, 1000, 1000);
|
|
39
|
-
activity.setContentView(contentLayout);
|
|
40
|
-
overlayContainer = new FrameLayout(activity);
|
|
41
|
-
contentLayout.addView(overlayContainer);
|
|
42
|
-
|
|
43
|
-
ChildControllersRegistry childRegistry = new ChildControllersRegistry();
|
|
44
|
-
overlay1 = spy(new SimpleViewController(activity, childRegistry, OVERLAY_ID_1, new Options()));
|
|
45
|
-
overlay2 = spy(new SimpleViewController(activity, childRegistry, OVERLAY_ID_2, new Options()));
|
|
46
|
-
uut = new OverlayManager();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Test
|
|
50
|
-
public void show_attachesOverlayContainerToContentLayout() {
|
|
51
|
-
uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
|
|
52
|
-
assertThat(overlayContainer.getParent()).isEqualTo(contentLayout);
|
|
53
|
-
uut.show(overlayContainer, overlay2, new CommandListenerAdapter());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@Test
|
|
57
|
-
public void show() {
|
|
58
|
-
CommandListenerAdapter listener = spy(new CommandListenerAdapter());
|
|
59
|
-
uut.show(overlayContainer, overlay1, listener);
|
|
60
|
-
idleMainLooper();
|
|
61
|
-
verify(listener).onSuccess(OVERLAY_ID_1);
|
|
62
|
-
verify(overlay1).onViewDidAppear();
|
|
63
|
-
assertThat(overlay1.getView().getParent()).isEqualTo(overlayContainer);
|
|
64
|
-
assertMatchParent(overlay1.getView());
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@Test
|
|
68
|
-
public void dismiss() {
|
|
69
|
-
uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
|
|
70
|
-
assertThat(uut.size()).isOne();
|
|
71
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
72
|
-
uut.dismiss(overlayContainer, overlay1.getId(), listener);
|
|
73
|
-
assertThat(uut.size()).isZero();
|
|
74
|
-
verify(listener, times(1)).onSuccess(OVERLAY_ID_1);
|
|
75
|
-
verify(overlay1, times(1)).destroy();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@Test
|
|
79
|
-
public void dismiss_rejectIfOverlayNotFound() {
|
|
80
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
81
|
-
uut.dismiss(overlayContainer, overlay1.getId(), listener);
|
|
82
|
-
verify(listener, times(1)).onError(any());
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@Test
|
|
86
|
-
public void dismiss_onViewReturnedToFront() {
|
|
87
|
-
uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
|
|
88
|
-
uut.show(overlayContainer, overlay2, new CommandListenerAdapter());
|
|
89
|
-
idleMainLooper();
|
|
90
|
-
verify(overlay1, never()).onViewBroughtToFront();
|
|
91
|
-
|
|
92
|
-
uut.dismiss(overlayContainer, OVERLAY_ID_2, new CommandListenerAdapter());
|
|
93
|
-
idleMainLooper();
|
|
94
|
-
verify(overlay1).onViewBroughtToFront();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@Test
|
|
98
|
-
public void dismiss_overlayContainerIsHiddenIfAllOverlaysAreDismissed() {
|
|
99
|
-
uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
|
|
100
|
-
uut.show(overlayContainer, overlay2, new CommandListenerAdapter());
|
|
101
|
-
|
|
102
|
-
uut.dismiss(overlayContainer, OVERLAY_ID_2, new CommandListenerAdapter());
|
|
103
|
-
assertThat(overlayContainer.getVisibility()).isEqualTo(View.VISIBLE);
|
|
104
|
-
assertThat(overlayContainer.getParent()).isEqualTo(contentLayout);
|
|
105
|
-
uut.dismiss(overlayContainer, OVERLAY_ID_1, new CommandListenerAdapter());
|
|
106
|
-
assertThat(overlayContainer.getVisibility()).isEqualTo(View.GONE);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.parent;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.view.ViewGroup;
|
|
5
|
-
import android.widget.FrameLayout;
|
|
6
|
-
|
|
7
|
-
import com.reactnativenavigation.BaseTest;
|
|
8
|
-
import com.reactnativenavigation.TestUtils;
|
|
9
|
-
import com.reactnativenavigation.mocks.SimpleViewController;
|
|
10
|
-
import com.reactnativenavigation.options.Options;
|
|
11
|
-
import com.reactnativenavigation.options.params.Text;
|
|
12
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
13
|
-
import com.reactnativenavigation.react.CommandListenerAdapter;
|
|
14
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
15
|
-
import com.reactnativenavigation.viewcontrollers.stack.StackController;
|
|
16
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
17
|
-
|
|
18
|
-
import org.junit.Test;
|
|
19
|
-
import org.mockito.ArgumentCaptor;
|
|
20
|
-
import org.mockito.Mockito;
|
|
21
|
-
|
|
22
|
-
import java.util.ArrayList;
|
|
23
|
-
import java.util.Arrays;
|
|
24
|
-
import java.util.Collection;
|
|
25
|
-
import java.util.List;
|
|
26
|
-
|
|
27
|
-
import androidx.annotation.NonNull;
|
|
28
|
-
|
|
29
|
-
import static com.reactnativenavigation.utils.CollectionUtils.*;
|
|
30
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
31
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
32
|
-
import static org.mockito.ArgumentMatchers.eq;
|
|
33
|
-
import static org.mockito.Mockito.never;
|
|
34
|
-
import static org.mockito.Mockito.spy;
|
|
35
|
-
import static org.mockito.Mockito.times;
|
|
36
|
-
import static org.mockito.Mockito.verify;
|
|
37
|
-
import static org.mockito.Mockito.when;
|
|
38
|
-
|
|
39
|
-
public class ParentControllerTest extends BaseTest {
|
|
40
|
-
|
|
41
|
-
private static final String INITIAL_TITLE = "initial title";
|
|
42
|
-
private Activity activity;
|
|
43
|
-
private ChildControllersRegistry childRegistry;
|
|
44
|
-
private List<ViewController<?>> children;
|
|
45
|
-
private ParentController<?> uut;
|
|
46
|
-
private Presenter presenter;
|
|
47
|
-
|
|
48
|
-
@Override
|
|
49
|
-
public void beforeEach() {
|
|
50
|
-
super.beforeEach();
|
|
51
|
-
activity = newActivity();
|
|
52
|
-
childRegistry = new ChildControllersRegistry();
|
|
53
|
-
children = new ArrayList<>();
|
|
54
|
-
Options initialOptions = new Options();
|
|
55
|
-
initialOptions.topBar.title.text = new Text(INITIAL_TITLE);
|
|
56
|
-
presenter = spy(new Presenter(activity, new Options()));
|
|
57
|
-
uut = spy(new ParentController<ViewGroup>(activity, childRegistry, "uut", presenter, initialOptions) {
|
|
58
|
-
|
|
59
|
-
@Override
|
|
60
|
-
public ViewController<?> getCurrentChild() {
|
|
61
|
-
return children.get(0);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@NonNull
|
|
65
|
-
@Override
|
|
66
|
-
public ViewGroup createView() {
|
|
67
|
-
FrameLayout layout = new FrameLayout(activity);
|
|
68
|
-
for (ViewController<?> child : children) {
|
|
69
|
-
child.setParentController(this);
|
|
70
|
-
layout.addView(child.getView());
|
|
71
|
-
}
|
|
72
|
-
return layout;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Override
|
|
76
|
-
public void sendOnNavigationButtonPressed(String buttonId) {
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@NonNull
|
|
81
|
-
@Override
|
|
82
|
-
public Collection<ViewController<?>> getChildControllers() {
|
|
83
|
-
return children;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Test
|
|
89
|
-
public void onConfigurationChange_shouldCallConfigurationChangeForPresenterAndChildren() {
|
|
90
|
-
children.add(spy(new SimpleViewController(activity, childRegistry, "child1", new Options())));
|
|
91
|
-
children.add(spy(new SimpleViewController(activity, childRegistry, "child2", new Options())));
|
|
92
|
-
ParentController<?> spyUUT = spy(uut);
|
|
93
|
-
spyUUT.onConfigurationChanged(mockConfiguration);
|
|
94
|
-
verify(presenter).onConfigurationChanged(any(),any());
|
|
95
|
-
for (ViewController<?> controller : children) {
|
|
96
|
-
verify(controller).onConfigurationChanged(any());
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
@Test
|
|
101
|
-
public void onViewDidAppearShouldCallCurrentChildDidAppear(){
|
|
102
|
-
SimpleViewController child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
|
|
103
|
-
SimpleViewController child2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
|
|
104
|
-
children.add(child1);
|
|
105
|
-
children.add(child2);
|
|
106
|
-
|
|
107
|
-
uut.onViewDidAppear();
|
|
108
|
-
|
|
109
|
-
verify(child1).onViewDidAppear();
|
|
110
|
-
verify(child2,never()).onViewDidAppear();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
@Test
|
|
114
|
-
public void onViewDisappearShouldCallCurrentChildDisAppear(){
|
|
115
|
-
SimpleViewController child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
|
|
116
|
-
SimpleViewController child2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
|
|
117
|
-
children.add(child1);
|
|
118
|
-
children.add(child2);
|
|
119
|
-
|
|
120
|
-
uut.onViewDisappear();
|
|
121
|
-
|
|
122
|
-
verify(child1).onViewDisappear();
|
|
123
|
-
verify(child2,never()).onViewDisappear();
|
|
124
|
-
}
|
|
125
|
-
@Test
|
|
126
|
-
public void holdsViewGroup() {
|
|
127
|
-
assertThat(uut.getView()).isInstanceOf(ViewGroup.class);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@Test
|
|
131
|
-
public void mustHaveChildControllers() {
|
|
132
|
-
assertThat(uut.getChildControllers()).isNotNull();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
@Test
|
|
136
|
-
public void findControllerById_ChildById() {
|
|
137
|
-
SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
|
|
138
|
-
SimpleViewController child2 = new SimpleViewController(activity, childRegistry, "child2", new Options());
|
|
139
|
-
children.add(child1);
|
|
140
|
-
children.add(child2);
|
|
141
|
-
|
|
142
|
-
assertThat(uut.findController("uut")).isEqualTo(uut);
|
|
143
|
-
assertThat(uut.findController("child1")).isEqualTo(child1);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@Test
|
|
147
|
-
public void findControllerById_Recursive() {
|
|
148
|
-
StackController stackController = TestUtils.newStackController(activity).build();
|
|
149
|
-
stackController.ensureViewIsCreated();
|
|
150
|
-
SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
|
|
151
|
-
SimpleViewController child2 = new SimpleViewController(activity, childRegistry, "child2", new Options());
|
|
152
|
-
stackController.push(child1, new CommandListenerAdapter());
|
|
153
|
-
stackController.push(child2, new CommandListenerAdapter());
|
|
154
|
-
children.add(stackController);
|
|
155
|
-
|
|
156
|
-
assertThat(uut.findController("child2")).isEqualTo(child2);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
@Test
|
|
160
|
-
public void destroy_DestroysChildren() {
|
|
161
|
-
ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
|
|
162
|
-
children.add(child1);
|
|
163
|
-
|
|
164
|
-
verify(child1, times(0)).destroy();
|
|
165
|
-
uut.destroy();
|
|
166
|
-
verify(child1, times(1)).destroy();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
@Test
|
|
170
|
-
public void optionsAreClearedWhenChildIsAppeared() {
|
|
171
|
-
StackController stackController = spy(TestUtils.newStackController(activity).build());
|
|
172
|
-
stackController.ensureViewIsCreated();
|
|
173
|
-
SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
|
|
174
|
-
stackController.push(child1, new CommandListenerAdapter());
|
|
175
|
-
|
|
176
|
-
child1.onViewWillAppear();
|
|
177
|
-
verify(stackController, times(1)).clearOptions();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
@Test
|
|
181
|
-
public void mergeOptions_optionsAreMergedWhenChildAppears() {
|
|
182
|
-
Options options = new Options();
|
|
183
|
-
options.topBar.title.text = new Text("new title");
|
|
184
|
-
ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", options));
|
|
185
|
-
children.add(child1);
|
|
186
|
-
uut.ensureViewIsCreated();
|
|
187
|
-
|
|
188
|
-
child1.ensureViewIsCreated();
|
|
189
|
-
child1.onViewWillAppear();
|
|
190
|
-
ArgumentCaptor<Options> optionsCaptor = ArgumentCaptor.forClass(Options.class);
|
|
191
|
-
verify(uut, times(1)).clearOptions();
|
|
192
|
-
verify(uut, times(1)).applyChildOptions(optionsCaptor.capture(), eq(child1));
|
|
193
|
-
assertThat(optionsCaptor.getValue().topBar.title.text.get()).isEqualTo("new title");
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
@Test
|
|
197
|
-
public void mergeOptions_initialParentOptionsAreNotMutatedWhenChildAppears() {
|
|
198
|
-
Options options = new Options();
|
|
199
|
-
options.topBar.title.text = new Text("new title");
|
|
200
|
-
ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", options));
|
|
201
|
-
children.add(child1);
|
|
202
|
-
|
|
203
|
-
uut.ensureViewIsCreated();
|
|
204
|
-
|
|
205
|
-
child1.ensureViewIsCreated();
|
|
206
|
-
child1.onViewWillAppear();
|
|
207
|
-
assertThat(uut.initialOptions.topBar.title.text.get()).isEqualTo(INITIAL_TITLE);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
@Test
|
|
211
|
-
public void resolveCurrentOptions_returnOptionsIfNoChildren() {
|
|
212
|
-
assertThat(uut.getChildControllers().size()).isZero();
|
|
213
|
-
assertThat(uut.resolveCurrentOptions()).isEqualTo(uut.initialOptions);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
@Test
|
|
217
|
-
public void resolveCurrentOptions_mergesWithCurrentChild() {
|
|
218
|
-
ViewController child1 = Mockito.mock(ViewController.class);
|
|
219
|
-
when(child1.getView()).thenReturn(new FrameLayout(activity));
|
|
220
|
-
Options copiedChildOptions = spy(new Options());
|
|
221
|
-
Options childOptions = spy(new Options() {
|
|
222
|
-
@Override
|
|
223
|
-
public Options copy() {
|
|
224
|
-
return copiedChildOptions;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
when(child1.resolveCurrentOptions()).thenReturn(childOptions);
|
|
228
|
-
|
|
229
|
-
children.add(child1);
|
|
230
|
-
|
|
231
|
-
uut.ensureViewIsCreated();
|
|
232
|
-
assertThat(uut.getCurrentChild()).isEqualTo(child1);
|
|
233
|
-
uut.resolveCurrentOptions();
|
|
234
|
-
verify(child1).resolveCurrentOptions();
|
|
235
|
-
verify(copiedChildOptions).withDefaultOptions(uut.initialOptions);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
@Test
|
|
239
|
-
public void resolveCurrentOptions_withDefaultOptions() {
|
|
240
|
-
SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
|
|
241
|
-
children.add(child1);
|
|
242
|
-
uut.ensureViewIsCreated();
|
|
243
|
-
|
|
244
|
-
Options defaultOptions = new Options();
|
|
245
|
-
Options currentOptions = spy(new Options());
|
|
246
|
-
ParentController<?> spy = spy(uut);
|
|
247
|
-
Mockito.when(spy.resolveCurrentOptions()).thenReturn(currentOptions);
|
|
248
|
-
spy.resolveCurrentOptions(defaultOptions);
|
|
249
|
-
verify(currentOptions).withDefaultOptions(defaultOptions);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
@Test
|
|
253
|
-
public void applyTopInset() {
|
|
254
|
-
children.addAll(createChildren());
|
|
255
|
-
uut.applyTopInset();
|
|
256
|
-
forEach(children, c -> verify(c).applyTopInset());
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
@Test
|
|
260
|
-
public void getTopInset() {
|
|
261
|
-
assertThat(uut.getTopInset()).isZero();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
@Test
|
|
265
|
-
public void getTopInsetForChild() {
|
|
266
|
-
ParentController<?> parent = Mockito.mock(ParentController.class);
|
|
267
|
-
Mockito.when(parent.resolveChildOptions(uut)).thenReturn(Options.EMPTY);
|
|
268
|
-
|
|
269
|
-
when(parent.getTopInset(any())).thenReturn(123);
|
|
270
|
-
uut.setParentController(parent);
|
|
271
|
-
|
|
272
|
-
assertThat(uut.getTopInset(Mockito.mock(ViewController.class))).isEqualTo(123);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
@Test
|
|
276
|
-
public void applyBottomInset() {
|
|
277
|
-
children.addAll(createChildren());
|
|
278
|
-
uut.applyBottomInset();
|
|
279
|
-
forEach(children, c -> verify(c).applyBottomInset());
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
@Test
|
|
283
|
-
public void getBottomInsetForChild() {
|
|
284
|
-
ParentController<?> parent = Mockito.mock(ParentController.class);
|
|
285
|
-
Mockito.when(parent.resolveChildOptions(uut)).thenReturn(Options.EMPTY);
|
|
286
|
-
|
|
287
|
-
when(parent.getBottomInset(any())).thenReturn(123);
|
|
288
|
-
uut.setParentController(parent);
|
|
289
|
-
|
|
290
|
-
assertThat(uut.getBottomInset(Mockito.mock(ViewController.class))).isEqualTo(123);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
private List<ViewController<?>> createChildren() {
|
|
294
|
-
return Arrays.asList(
|
|
295
|
-
spy(new SimpleViewController(activity, childRegistry, "child1", new Options())),
|
|
296
|
-
spy(new SimpleViewController(activity, childRegistry, "child2", new Options()))
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
}
|