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,1081 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.stack
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.Context
|
|
5
|
-
import android.content.res.Configuration
|
|
6
|
-
import android.graphics.Color
|
|
7
|
-
import android.graphics.Typeface
|
|
8
|
-
import android.view.View
|
|
9
|
-
import android.view.ViewGroup
|
|
10
|
-
import org.mockito.kotlin.*
|
|
11
|
-
import com.reactnativenavigation.BaseTest
|
|
12
|
-
import com.reactnativenavigation.TestUtils
|
|
13
|
-
import com.reactnativenavigation.fakes.IconResolverFake
|
|
14
|
-
import com.reactnativenavigation.mocks.*
|
|
15
|
-
import com.reactnativenavigation.options.*
|
|
16
|
-
import com.reactnativenavigation.options.params.*
|
|
17
|
-
import com.reactnativenavigation.options.params.Number
|
|
18
|
-
import com.reactnativenavigation.options.parsers.TypefaceLoader
|
|
19
|
-
import com.reactnativenavigation.react.CommandListenerAdapter
|
|
20
|
-
import com.reactnativenavigation.utils.CollectionUtils
|
|
21
|
-
import com.reactnativenavigation.utils.RenderChecker
|
|
22
|
-
import com.reactnativenavigation.utils.TitleBarHelper
|
|
23
|
-
import com.reactnativenavigation.utils.UiUtils
|
|
24
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry
|
|
25
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController
|
|
26
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController
|
|
27
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter
|
|
28
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver
|
|
29
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.title.TitleBarReactViewController
|
|
30
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController
|
|
31
|
-
import com.reactnativenavigation.views.stack.StackLayout
|
|
32
|
-
import com.reactnativenavigation.views.stack.topbar.TopBar
|
|
33
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.DEFAULT_LEFT_MARGIN_PX
|
|
34
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleBarReactView
|
|
35
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleSubTitleLayout
|
|
36
|
-
import org.assertj.core.api.Assertions
|
|
37
|
-
import org.assertj.core.api.Java6Assertions.assertThat
|
|
38
|
-
import org.json.JSONObject
|
|
39
|
-
import org.junit.Test
|
|
40
|
-
import org.mockito.Mockito
|
|
41
|
-
import org.robolectric.shadows.ShadowLooper
|
|
42
|
-
import java.util.*
|
|
43
|
-
import kotlin.collections.ArrayList
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class StackPresenterTest : BaseTest() {
|
|
47
|
-
private lateinit var parent: StackController
|
|
48
|
-
private lateinit var uut: StackPresenter
|
|
49
|
-
private lateinit var ogUut: StackPresenter
|
|
50
|
-
private lateinit var child: ViewController<*>
|
|
51
|
-
private lateinit var otherChild: ViewController<*>
|
|
52
|
-
private lateinit var activity: Activity
|
|
53
|
-
private lateinit var topBar: TopBar
|
|
54
|
-
private lateinit var renderChecker: RenderChecker
|
|
55
|
-
private val textBtn1 = TitleBarHelper.textualButton("btn1")
|
|
56
|
-
private val textBtn2 = TitleBarHelper.textualButton("btn2")
|
|
57
|
-
private val componentBtn1 = TitleBarHelper.reactViewButton("btn1_")
|
|
58
|
-
private val componentBtn2 = TitleBarHelper.reactViewButton("btn2_")
|
|
59
|
-
private val titleComponent1 = TitleBarHelper.titleComponent("component1")
|
|
60
|
-
private val titleComponent2 = TitleBarHelper.titleComponent("component2")
|
|
61
|
-
private lateinit var topBarController: TopBarController
|
|
62
|
-
private lateinit var childRegistry: ChildControllersRegistry
|
|
63
|
-
private lateinit var typefaceLoader: TypefaceLoader
|
|
64
|
-
private lateinit var iconResolver: IconResolver
|
|
65
|
-
private lateinit var buttonCreator: TitleBarButtonCreatorMock
|
|
66
|
-
private lateinit var reactTitleView: TitleBarReactView
|
|
67
|
-
|
|
68
|
-
override fun beforeEach() {
|
|
69
|
-
super.beforeEach()
|
|
70
|
-
activity = spy(newActivity())
|
|
71
|
-
val titleViewCreator: TitleBarReactViewCreatorMock = object : TitleBarReactViewCreatorMock() {
|
|
72
|
-
override fun create(activity: Activity, componentId: String, componentName: String): TitleBarReactView {
|
|
73
|
-
reactTitleView = spy(super.create(activity, componentId, componentName))
|
|
74
|
-
return reactTitleView
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
renderChecker = spy(RenderChecker())
|
|
78
|
-
typefaceLoader = createTypeFaceLoader()
|
|
79
|
-
iconResolver = IconResolverFake(activity)
|
|
80
|
-
buttonCreator = TitleBarButtonCreatorMock()
|
|
81
|
-
ogUut = StackPresenter(
|
|
82
|
-
activity,
|
|
83
|
-
titleViewCreator,
|
|
84
|
-
TopBarBackgroundViewCreatorMock(),
|
|
85
|
-
buttonCreator,
|
|
86
|
-
iconResolver,
|
|
87
|
-
typefaceLoader,
|
|
88
|
-
renderChecker,
|
|
89
|
-
Options()
|
|
90
|
-
)
|
|
91
|
-
uut = spy(ogUut)
|
|
92
|
-
createTopBarController()
|
|
93
|
-
parent = TestUtils.newStackController(activity)
|
|
94
|
-
.setTopBarController(topBarController)
|
|
95
|
-
.setStackPresenter(uut)
|
|
96
|
-
.build()
|
|
97
|
-
childRegistry = ChildControllersRegistry()
|
|
98
|
-
child = spy(SimpleViewController(activity, childRegistry, "child1", Options.EMPTY))
|
|
99
|
-
otherChild = spy(SimpleViewController(activity, childRegistry, "child1", Options.EMPTY))
|
|
100
|
-
activity.setContentView(parent.view)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@Test
|
|
104
|
-
fun onConfigurationChange_shouldApplyColors() {
|
|
105
|
-
parent.setRoot(listOf(child), CommandListenerAdapter())
|
|
106
|
-
val options = Options.EMPTY.copy()
|
|
107
|
-
options.topBar.borderColor = ThemeColour.of(Color.BLACK, Color.RED)
|
|
108
|
-
options.topBar.background = TopBarBackgroundOptions().apply {
|
|
109
|
-
color = ThemeColour.of(Color.BLACK, Color.RED)
|
|
110
|
-
}
|
|
111
|
-
options.topBar.title = TitleOptions().apply {
|
|
112
|
-
color = ThemeColour.of(Color.BLACK, Color.RED)
|
|
113
|
-
}
|
|
114
|
-
options.topBar.subtitle = SubtitleOptions().apply {
|
|
115
|
-
color = ThemeColour.of(Color.BLACK, Color.RED)
|
|
116
|
-
}
|
|
117
|
-
options.topBar.buttons.back = BackButton().apply {
|
|
118
|
-
color = ThemeColour.of(Color.BLACK, Color.RED)
|
|
119
|
-
visible = Bool(true)
|
|
120
|
-
}
|
|
121
|
-
options.topBar.rightButtonColor = ThemeColour.of(Color.BLACK, Color.RED)
|
|
122
|
-
options.topBar.buttons.left = arrayListOf(ButtonOptions())
|
|
123
|
-
options.topBar.buttons.right = arrayListOf(ButtonOptions())
|
|
124
|
-
|
|
125
|
-
options.topTabs.selectedTabColor = ThemeColour.of(Color.BLACK, Color.RED)
|
|
126
|
-
options.topTabs.unselectedTabColor = ThemeColour.of(Color.BLACK, Color.RED)
|
|
127
|
-
|
|
128
|
-
mockConfiguration.uiMode = Configuration.UI_MODE_NIGHT_NO
|
|
129
|
-
uut.onConfigurationChanged(options, getCurrentChild())
|
|
130
|
-
|
|
131
|
-
verify(topBar).setTitleTextColor(Color.BLACK)
|
|
132
|
-
verify(topBar).setSubtitleColor(Color.BLACK)
|
|
133
|
-
verify(topBar).setBackgroundColor(Color.BLACK)
|
|
134
|
-
verify(topBar).setBorderColor(Color.BLACK)
|
|
135
|
-
verify(topBar).applyTopTabsColors(options.topTabs.selectedTabColor,options.topTabs.unselectedTabColor)
|
|
136
|
-
verify(topBar).setOverflowButtonColor(Color.BLACK)
|
|
137
|
-
verify(topBar).setBackButton(any())
|
|
138
|
-
|
|
139
|
-
mockConfiguration.uiMode = Configuration.UI_MODE_NIGHT_YES
|
|
140
|
-
uut.onConfigurationChanged(options, getCurrentChild())
|
|
141
|
-
|
|
142
|
-
verify(topBar).setTitleTextColor(Color.RED)
|
|
143
|
-
verify(topBar).setSubtitleColor(Color.RED)
|
|
144
|
-
verify(topBar).setBackgroundColor(Color.RED)
|
|
145
|
-
verify(topBar).setBorderColor(Color.RED)
|
|
146
|
-
verify(topBar,times(2)).applyTopTabsColors(options.topTabs.selectedTabColor,options.topTabs.unselectedTabColor)
|
|
147
|
-
verify(topBar).setOverflowButtonColor(Color.RED)
|
|
148
|
-
verify(topBar,times(2)).setBackButton(any())
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
@Test
|
|
153
|
-
fun onConfigurationChange_shouldApplyColorsOnTopBarButtons() {
|
|
154
|
-
parent.setRoot(listOf(child), CommandListenerAdapter())
|
|
155
|
-
|
|
156
|
-
val options = Options.EMPTY.copy()
|
|
157
|
-
options.topBar.buttons.left = arrayListOf(ButtonOptions())
|
|
158
|
-
options.topBar.buttons.right = arrayListOf(ButtonOptions())
|
|
159
|
-
|
|
160
|
-
uut.applyChildOptions(options,parent,child)
|
|
161
|
-
verify(topBarController, times(1)).applyRightButtonsOptions(any(),any(),any())
|
|
162
|
-
verify(topBarController, times(1)).applyLeftButtonsOptions(any(),any(),any())
|
|
163
|
-
|
|
164
|
-
uut.onConfigurationChanged(options, getCurrentChild())
|
|
165
|
-
verify(topBarController, times(1)).onConfigurationChanged(any(), any(), any())
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
@Test
|
|
169
|
-
fun isRendered() {
|
|
170
|
-
val o1 = Options()
|
|
171
|
-
o1.topBar.title.component = component(Alignment.Default)
|
|
172
|
-
o1.topBar.background.component = component(Alignment.Default)
|
|
173
|
-
o1.topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
174
|
-
o1.topBar.buttons.left = ArrayList(listOf(componentBtn2))
|
|
175
|
-
|
|
176
|
-
uut.applyChildOptions(o1, parent, child)
|
|
177
|
-
uut.isRendered(child.view)
|
|
178
|
-
|
|
179
|
-
val controllers = argumentCaptor<Collection<ViewController<*>>>()
|
|
180
|
-
verify(renderChecker).areRendered(controllers.capture())
|
|
181
|
-
val items = controllers.firstValue
|
|
182
|
-
assertThat(items.size).isEqualTo(4)
|
|
183
|
-
assertThat(items.containsAll(listOf(
|
|
184
|
-
uut.getComponentButtons(child.view)[0],
|
|
185
|
-
uut.titleComponents[child.view] as ViewController<*>,
|
|
186
|
-
uut.backgroundComponents[child.view]
|
|
187
|
-
))).isTrue()
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
@Test
|
|
191
|
-
fun applyChildOptions_setTitleComponent() {
|
|
192
|
-
val options = Options()
|
|
193
|
-
options.topBar.title.component = component(Alignment.Default)
|
|
194
|
-
uut.applyChildOptions(options, parent, child)
|
|
195
|
-
verify(topBar).setTitleComponent(uut.titleComponents[child.view]!!.view, Alignment.Default)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
@Test
|
|
199
|
-
fun applyChildOptions_setTitleComponentCreatesOnce() {
|
|
200
|
-
val options = Options()
|
|
201
|
-
options.topBar.title.component = component(Alignment.Default)
|
|
202
|
-
uut.applyChildOptions(options, parent, child)
|
|
203
|
-
uut.applyChildOptions(Options.EMPTY, parent, otherChild)
|
|
204
|
-
val titleController = uut.titleComponents[child.view]
|
|
205
|
-
uut.applyChildOptions(options, parent, child)
|
|
206
|
-
assertThat(uut.titleComponents.size).isOne()
|
|
207
|
-
assertThat(uut.titleComponents[child.view]).isEqualTo(titleController)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
@Test
|
|
211
|
-
fun applyChildOptions_setTitleComponentAlignmentCenter() {
|
|
212
|
-
val options = Options()
|
|
213
|
-
parent.view.layout(0, 0, 1000, 1000)
|
|
214
|
-
options.topBar.title.component = component(Alignment.Center)
|
|
215
|
-
uut.applyChildOptions(options, parent, child)
|
|
216
|
-
val component = topBar.titleAndButtonsContainer.getComponent()
|
|
217
|
-
Assertions.assertThat(component).isEqualTo(reactTitleView)
|
|
218
|
-
child.view.requestLayout()
|
|
219
|
-
idleMainLooper()
|
|
220
|
-
Assertions.assertThat(component?.left).isEqualTo(parent.view.width / 2 - reactTitleView.width / 2)
|
|
221
|
-
Assertions.assertThat(component?.right).isEqualTo(parent.view.width / 2 + reactTitleView.width / 2)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
@Test
|
|
225
|
-
fun applyChildOptions_setTitleComponentAlignmentStart() {
|
|
226
|
-
val options = Options()
|
|
227
|
-
options.topBar.title.component = component(Alignment.Fill)
|
|
228
|
-
uut.applyChildOptions(options, parent, child)
|
|
229
|
-
val component = topBar.titleAndButtonsContainer.getComponent()
|
|
230
|
-
Assertions.assertThat(component).isEqualTo(reactTitleView)
|
|
231
|
-
Mockito.doReturn(100).`when`(reactTitleView).measuredWidth
|
|
232
|
-
child.view.requestLayout()
|
|
233
|
-
idleMainLooper()
|
|
234
|
-
Assertions.assertThat(component?.left).isEqualTo(DEFAULT_LEFT_MARGIN_PX)
|
|
235
|
-
Assertions.assertThat(component?.right).isEqualTo(DEFAULT_LEFT_MARGIN_PX + reactTitleView.measuredWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
@Test
|
|
239
|
-
fun onChildDestroyed_destroyTitleComponent() {
|
|
240
|
-
val options = Options()
|
|
241
|
-
options.topBar.title.component = component(Alignment.Default)
|
|
242
|
-
uut.applyChildOptions(options, parent, child)
|
|
243
|
-
val titleView = uut.titleComponents[child.view]!!.view
|
|
244
|
-
uut.onChildDestroyed(child)
|
|
245
|
-
verify(titleView).destroy()
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
@Test
|
|
249
|
-
fun mergeOrientation() {
|
|
250
|
-
val options = Options()
|
|
251
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
252
|
-
verify(uut, never()).applyOrientation(any())
|
|
253
|
-
val orientation = JSONObject().put("orientation", "landscape")
|
|
254
|
-
options.layout.orientation = OrientationOptions.parse(orientation)
|
|
255
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
256
|
-
verify(uut).applyOrientation(options.layout.orientation)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
@Test
|
|
260
|
-
fun mergeButtons() {
|
|
261
|
-
uut.mergeChildOptions(EMPTY_OPTIONS, EMPTY_OPTIONS, parent, child)
|
|
262
|
-
verify(topBarController, never()).mergeLeftButtonsOptions(any(),any(),any())
|
|
263
|
-
verify(topBarController, never()).mergeRightButtonsOptions(any(),any(),any())
|
|
264
|
-
|
|
265
|
-
val options = Options()
|
|
266
|
-
val button = ButtonOptions()
|
|
267
|
-
button.text = Text("btn")
|
|
268
|
-
options.topBar.buttons.right = ArrayList(setOf(button))
|
|
269
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
270
|
-
verify(topBarController).mergeRightButtonsOptions(any(), any(),any())
|
|
271
|
-
|
|
272
|
-
options.topBar.buttons.left = ArrayList(setOf(button))
|
|
273
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
274
|
-
verify(topBarController).mergeLeftButtonsOptions(any(), any(), any())
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
@Test
|
|
278
|
-
fun `mergeButtons - modify BackButton should not have effect on stack with with one child`() {
|
|
279
|
-
val options = Options()
|
|
280
|
-
options.topBar.buttons.back = BackButton.parse(activity, JSONObject().apply {
|
|
281
|
-
put("color", Color.RED)
|
|
282
|
-
})
|
|
283
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
284
|
-
verify(topBar, times(0)).setBackButton(any())
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
@Test
|
|
288
|
-
fun mergeButtons_previousRightButtonsAreDestroyed() {
|
|
289
|
-
val options = Options()
|
|
290
|
-
options.topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
291
|
-
uut.applyChildOptions(options, parent, child)
|
|
292
|
-
val initialButtons = uut.getComponentButtons(child.view)
|
|
293
|
-
CollectionUtils.forEach(initialButtons) { obj: ButtonController -> obj.ensureViewIsCreated() }
|
|
294
|
-
options.topBar.buttons.right = ArrayList(listOf(componentBtn2))
|
|
295
|
-
uut.mergeChildOptions(options, Options.EMPTY, parent, child)
|
|
296
|
-
for (button in initialButtons) {
|
|
297
|
-
assertThat(button.isDestroyed).isTrue()
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
@Test
|
|
302
|
-
fun mergeRightButtons_mergingButtonsOnlyDestroysRightButtons() {
|
|
303
|
-
val a = Options()
|
|
304
|
-
a.topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
305
|
-
a.topBar.buttons.left = ArrayList(listOf(componentBtn2))
|
|
306
|
-
uut.applyChildOptions(a, parent, child)
|
|
307
|
-
val initialButtons = uut.getComponentButtons(child.view)
|
|
308
|
-
CollectionUtils.forEach(initialButtons) { obj: ButtonController -> obj.ensureViewIsCreated() }
|
|
309
|
-
val b = Options()
|
|
310
|
-
b.topBar.buttons.right = ArrayList(listOf(componentBtn2))
|
|
311
|
-
uut.mergeChildOptions(b, Options.EMPTY, parent, child)
|
|
312
|
-
assertThat(initialButtons[0].isDestroyed).isTrue()
|
|
313
|
-
assertThat(initialButtons[1].isDestroyed).isFalse()
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
@Test
|
|
317
|
-
fun mergeRightButtons_buttonsAreCreatedOnlyIfNeeded() {
|
|
318
|
-
val toApply = Options()
|
|
319
|
-
textBtn1.color = ThemeColour(Colour(Color.GREEN))
|
|
320
|
-
toApply.topBar.buttons.right = arrayListOf(textBtn1, componentBtn1)
|
|
321
|
-
uut.applyChildOptions(toApply, parent, child)
|
|
322
|
-
|
|
323
|
-
val captor1 = argumentCaptor<List<ButtonOptions>>()
|
|
324
|
-
verify(topBarController).applyRightButtonsOptions(any(),captor1.capture(), any())
|
|
325
|
-
assertThat(topBar.rightButtonBar.menu.size()).isEqualTo(2)
|
|
326
|
-
|
|
327
|
-
val appliedButtons = captor1.firstValue
|
|
328
|
-
val toMerge = Options()
|
|
329
|
-
toMerge.topBar.buttons.right = ArrayList(toApply.topBar.buttons.right!!.map(ButtonOptions::copy))
|
|
330
|
-
toMerge.topBar.buttons.right!![0].color = ThemeColour(Colour(Color.RED))
|
|
331
|
-
toMerge.topBar.buttons.right!!.add(1, componentBtn2)
|
|
332
|
-
uut.mergeChildOptions(toMerge, Options.EMPTY, parent, child)
|
|
333
|
-
|
|
334
|
-
assertThat(topBar.rightButtonBar.menu.size()).isEqualTo(3)
|
|
335
|
-
val captor2 = argumentCaptor<List<ButtonOptions>>()
|
|
336
|
-
verify(topBarController).mergeRightButtonsOptions(any(),captor2.capture(), any())
|
|
337
|
-
val mergedButtons = captor2.firstValue
|
|
338
|
-
assertThat(mergedButtons).hasSize(3)
|
|
339
|
-
assertThat(appliedButtons[0].id).isNotEqualTo(mergedButtons[1].id)
|
|
340
|
-
assertThat(appliedButtons[1].id).isEqualTo(mergedButtons[2].id)
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
@Test
|
|
344
|
-
fun mergeButtons_mergingLeftButtonsDoesNotDestroyRightButtons() {
|
|
345
|
-
val a = Options()
|
|
346
|
-
a.topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
347
|
-
a.topBar.buttons.left = ArrayList(listOf(componentBtn2))
|
|
348
|
-
uut.applyChildOptions(a, parent, child)
|
|
349
|
-
|
|
350
|
-
val initialButtons = uut.getComponentButtons(child.view)
|
|
351
|
-
initialButtons.forEach(ButtonController::ensureViewIsCreated)
|
|
352
|
-
val b = Options()
|
|
353
|
-
b.topBar.buttons.left = ArrayList(listOf(componentBtn2))
|
|
354
|
-
uut.mergeChildOptions(b, Options.EMPTY, parent, child)
|
|
355
|
-
assertThat(initialButtons[0].isDestroyed).isFalse()
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
@Test
|
|
359
|
-
fun mergeChildOptions_backButtonShouldNotAffectLeftButtons() {
|
|
360
|
-
val options = Options()
|
|
361
|
-
options.topBar.buttons.right = ArrayList(listOf(textBtn1))
|
|
362
|
-
options.topBar.buttons.back = BackButton.parse(activity, JSONObject())
|
|
363
|
-
options.topBar.buttons.back.setVisible()
|
|
364
|
-
options.topBar.buttons.left = ArrayList(listOf(textBtn2))
|
|
365
|
-
uut.applyChildOptions(options, parent, child)
|
|
366
|
-
ShadowLooper.idleMainLooper()
|
|
367
|
-
verify(topBarController, times(1)).applyLeftButtonsOptions(any(), any(), any())
|
|
368
|
-
verify(topBar, never()).setBackButton(any())
|
|
369
|
-
|
|
370
|
-
val backButtonHidden = Options()
|
|
371
|
-
backButtonHidden.topBar.buttons.back.setHidden()
|
|
372
|
-
uut.mergeChildOptions(backButtonHidden, options, parent, child)
|
|
373
|
-
ShadowLooper.idleMainLooper()
|
|
374
|
-
verify(topBar, times(1)).clearBackButton()
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
@Test
|
|
378
|
-
fun mergeButtons_backButtonIsRemovedIfVisibleFalse() {
|
|
379
|
-
val pushedChild = spy<ViewController<*>>(SimpleViewController(activity, childRegistry, "child2", Options()))
|
|
380
|
-
disablePushAnimation(child, pushedChild)
|
|
381
|
-
|
|
382
|
-
parent.push(child, CommandListenerAdapter())
|
|
383
|
-
assertThat(topBar.navigationIcon).isNull()
|
|
384
|
-
|
|
385
|
-
parent.push(pushedChild, CommandListenerAdapter())
|
|
386
|
-
ShadowLooper.idleMainLooper()
|
|
387
|
-
verify(pushedChild).onViewWillAppear()
|
|
388
|
-
assertThat(topBar.navigationIcon).isInstanceOf(BackDrawable::class.java)
|
|
389
|
-
|
|
390
|
-
val backButtonHidden = Options()
|
|
391
|
-
backButtonHidden.topBar.buttons.back.setHidden()
|
|
392
|
-
uut.mergeChildOptions(backButtonHidden, backButtonHidden, parent, child)
|
|
393
|
-
ShadowLooper.idleMainLooper()
|
|
394
|
-
assertThat(topBar.navigationIcon).isNull()
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
@Test
|
|
398
|
-
fun mergeButtons_actualLeftButtonIsAppliedEvenIfBackButtonHasValue() {
|
|
399
|
-
val toMerge = Options()
|
|
400
|
-
toMerge.topBar.buttons.back.setHidden()
|
|
401
|
-
toMerge.topBar.buttons.left = ArrayList()
|
|
402
|
-
val leftButton = ButtonOptions()
|
|
403
|
-
leftButton.id = "id"
|
|
404
|
-
leftButton.icon = Text("")
|
|
405
|
-
toMerge.topBar.buttons.left!!.add(leftButton)
|
|
406
|
-
|
|
407
|
-
assertThat(toMerge.topBar.buttons.back.hasValue()).isTrue()
|
|
408
|
-
uut.mergeChildOptions(toMerge, Options.EMPTY, parent, child)
|
|
409
|
-
verify(topBarController).mergeLeftButtonsOptions(any(), any(),any())
|
|
410
|
-
verify(topBar, never()).clearLeftButtons()
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
@Test
|
|
414
|
-
fun mergeChildOptions_mergeAnimateLeftRightButtons() {
|
|
415
|
-
val options = Options().apply {
|
|
416
|
-
topBar.animateLeftButtons = Bool(false)
|
|
417
|
-
}
|
|
418
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
419
|
-
verify(topBar).animateLeftButtons(false)
|
|
420
|
-
verify(topBar, never()).animateRightButtons(any())
|
|
421
|
-
|
|
422
|
-
options.apply {
|
|
423
|
-
topBar.animateRightButtons = Bool(true)
|
|
424
|
-
}
|
|
425
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
426
|
-
verify(topBar).animateRightButtons(true)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
options.apply {
|
|
430
|
-
topBar.animateRightButtons = Bool(false)
|
|
431
|
-
topBar.animateLeftButtons = Bool(true)
|
|
432
|
-
}
|
|
433
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
434
|
-
verify(topBar).animateRightButtons(false)
|
|
435
|
-
verify(topBar).animateLeftButtons(true)
|
|
436
|
-
}
|
|
437
|
-
@Test
|
|
438
|
-
fun mergeTopBarOptions() {
|
|
439
|
-
val options = Options()
|
|
440
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
441
|
-
assertTopBarOptions(options, 0)
|
|
442
|
-
val title = TitleOptions()
|
|
443
|
-
title.text = Text("abc")
|
|
444
|
-
title.color = ThemeColour(Colour(0))
|
|
445
|
-
title.fontSize = Fraction(1.0)
|
|
446
|
-
title.font = FontOptions()
|
|
447
|
-
title.font.fontStyle = Text("bold")
|
|
448
|
-
options.topBar.title = title
|
|
449
|
-
val subtitleOptions = SubtitleOptions()
|
|
450
|
-
subtitleOptions.text = Text("Sub")
|
|
451
|
-
subtitleOptions.color = ThemeColour(Colour(1))
|
|
452
|
-
subtitleOptions.font.fontStyle = Text("bold")
|
|
453
|
-
subtitleOptions.fontSize = Fraction(1.0)
|
|
454
|
-
options.topBar.subtitle = subtitleOptions
|
|
455
|
-
options.topBar.background.color = ThemeColour(Colour(0))
|
|
456
|
-
options.topBar.testId = Text("test123")
|
|
457
|
-
options.topBar.animate = Bool(false)
|
|
458
|
-
options.topBar.visible = Bool(false)
|
|
459
|
-
options.topBar.drawBehind = Bool(false)
|
|
460
|
-
options.topBar.hideOnScroll = Bool(false)
|
|
461
|
-
options.topBar.validate()
|
|
462
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
463
|
-
assertTopBarOptions(options, 1)
|
|
464
|
-
options.topBar.drawBehind = Bool(true)
|
|
465
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
@Test
|
|
469
|
-
fun mergeOptions_defaultOptionsAreNotApplied() {
|
|
470
|
-
val defaultOptions = Options()
|
|
471
|
-
defaultOptions.topBar.background.color = ThemeColour(Colour(10))
|
|
472
|
-
uut.defaultOptions = defaultOptions
|
|
473
|
-
val toMerge = Options()
|
|
474
|
-
toMerge.topBar.title.text = Text("someText")
|
|
475
|
-
uut.mergeOptions(toMerge, parent, child)
|
|
476
|
-
verify(topBar, never()).setBackgroundColor(any())
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
@Test
|
|
480
|
-
fun mergeOptions_shouldUpdateTitleAlignmentWhenNotDefault() {
|
|
481
|
-
val defaultOptions = Options()
|
|
482
|
-
defaultOptions.topBar.title.text = Text("title")
|
|
483
|
-
uut.defaultOptions = defaultOptions
|
|
484
|
-
val toMerge = Options()
|
|
485
|
-
toMerge.topBar.title.text = Text("newTitle")
|
|
486
|
-
uut.mergeOptions(toMerge, parent, child)
|
|
487
|
-
|
|
488
|
-
val alignmentOptions = Options()
|
|
489
|
-
alignmentOptions.topBar.title.alignment = Alignment.Center
|
|
490
|
-
uut.mergeOptions(alignmentOptions, parent, child)
|
|
491
|
-
verify(topBarController).alignTitleComponent(Alignment.Center)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
@Test
|
|
495
|
-
fun mergeOptions_resolvedTitleFontOptionsAreApplied() {
|
|
496
|
-
val childOptions = Options()
|
|
497
|
-
childOptions.topBar.title.font.fontFamily = Text(SOME_FONT_FAMILY)
|
|
498
|
-
child.mergeOptions(childOptions)
|
|
499
|
-
val parentOptions = Options()
|
|
500
|
-
parentOptions.topBar.title.color = ThemeColour.of(Color.RED)
|
|
501
|
-
parent.mergeOptions(parentOptions)
|
|
502
|
-
val defaultOptions = Options()
|
|
503
|
-
defaultOptions.topBar.title.fontSize = Fraction(9.0)
|
|
504
|
-
uut.defaultOptions = defaultOptions
|
|
505
|
-
val toMerge = Options()
|
|
506
|
-
toMerge.topBar.title.text = Text("New Title")
|
|
507
|
-
uut.mergeOptions(toMerge, parent, child)
|
|
508
|
-
val title = (topBar.titleAndButtonsContainer.getTitleComponent() as TitleSubTitleLayout).getTitleTxtView()
|
|
509
|
-
assertThat(title).isNotNull()
|
|
510
|
-
assertThat(title.typeface).isEqualTo(SOME_TYPEFACE)
|
|
511
|
-
verify(topBar).setTitleFontSize(9.0)
|
|
512
|
-
verify(topBar).setTitleTextColor(Color.RED)
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
@Test
|
|
516
|
-
fun mergeOptions_resolvedSubtitleFontOptionsAreApplied() {
|
|
517
|
-
val childOptions = Options()
|
|
518
|
-
childOptions.topBar.subtitle.font.fontFamily = Text(SOME_FONT_FAMILY)
|
|
519
|
-
child.mergeOptions(childOptions)
|
|
520
|
-
val parentOptions = Options()
|
|
521
|
-
parentOptions.topBar.subtitle.color = ThemeColour(Colour(Color.RED))
|
|
522
|
-
parent.mergeOptions(parentOptions)
|
|
523
|
-
val defaultOptions = Options()
|
|
524
|
-
defaultOptions.topBar.subtitle.fontSize = Fraction(9.0)
|
|
525
|
-
uut.defaultOptions = defaultOptions
|
|
526
|
-
val toMerge = Options()
|
|
527
|
-
toMerge.topBar.subtitle.text = Text("New Title")
|
|
528
|
-
uut.mergeOptions(toMerge, parent, child)
|
|
529
|
-
val subtitle = (topBar.titleAndButtonsContainer.getTitleComponent() as TitleSubTitleLayout).getSubTitleTxtView()
|
|
530
|
-
assertThat(subtitle).isNotNull()
|
|
531
|
-
assertThat(subtitle.typeface).isEqualTo(SOME_TYPEFACE)
|
|
532
|
-
verify(topBar).setSubtitleFontSize(9.0)
|
|
533
|
-
verify(topBar).setSubtitleColor(Color.RED)
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
@Test
|
|
537
|
-
fun mergeChildOptions_resolvedTitleFontOptionsAreApplied() {
|
|
538
|
-
val defaultOptions = Options()
|
|
539
|
-
defaultOptions.topBar.title.fontSize = Fraction(9.0)
|
|
540
|
-
uut.defaultOptions = defaultOptions
|
|
541
|
-
val resolvedOptions = Options()
|
|
542
|
-
resolvedOptions.topBar.title.font.fontFamily = Text(SOME_FONT_FAMILY)
|
|
543
|
-
resolvedOptions.topBar.title.color = ThemeColour(Colour(Color.RED))
|
|
544
|
-
val toMerge = Options()
|
|
545
|
-
toMerge.topBar.title.text = Text("New Title")
|
|
546
|
-
uut.mergeChildOptions(toMerge, resolvedOptions, parent, child)
|
|
547
|
-
val title = (topBar.titleAndButtonsContainer.getTitleComponent() as TitleSubTitleLayout).getTitleTxtView()
|
|
548
|
-
assertThat(title).isNotNull()
|
|
549
|
-
assertThat(title.typeface).isEqualTo(SOME_TYPEFACE)
|
|
550
|
-
verify(topBar).setTitleFontSize(9.0)
|
|
551
|
-
verify(topBar).setTitleTextColor(Color.RED)
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
@Test
|
|
555
|
-
fun mergeChildOptions_resolvedSubtitleFontOptionsAreApplied() {
|
|
556
|
-
val defaultOptions = Options()
|
|
557
|
-
defaultOptions.topBar.subtitle.fontSize = Fraction(9.0)
|
|
558
|
-
uut.defaultOptions = defaultOptions
|
|
559
|
-
val resolvedOptions = Options()
|
|
560
|
-
resolvedOptions.topBar.subtitle.font.fontFamily = Text(SOME_FONT_FAMILY)
|
|
561
|
-
resolvedOptions.topBar.subtitle.color = ThemeColour(Colour(Color.RED))
|
|
562
|
-
val toMerge = Options()
|
|
563
|
-
toMerge.topBar.subtitle.text = Text("New Title")
|
|
564
|
-
uut.mergeChildOptions(toMerge, resolvedOptions, parent, child)
|
|
565
|
-
val subtitle = (topBar.titleAndButtonsContainer.getTitleComponent() as TitleSubTitleLayout).getSubTitleTxtView()
|
|
566
|
-
assertThat(subtitle).isNotNull()
|
|
567
|
-
assertThat(subtitle.typeface).isEqualTo(SOME_TYPEFACE)
|
|
568
|
-
verify(topBar).setSubtitleFontSize(9.0)
|
|
569
|
-
verify(topBar).setSubtitleColor(Color.RED)
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
@Test
|
|
573
|
-
fun mergeChildOptions_defaultOptionsAreNotApplied() {
|
|
574
|
-
val defaultOptions = Options()
|
|
575
|
-
defaultOptions.topBar.background.color = ThemeColour(Colour(10))
|
|
576
|
-
uut.defaultOptions = defaultOptions
|
|
577
|
-
val childOptions = Options()
|
|
578
|
-
childOptions.topBar.title.text = Text("someText")
|
|
579
|
-
uut.mergeChildOptions(childOptions, EMPTY_OPTIONS, parent, child)
|
|
580
|
-
verify(topBar, never()).setBackgroundColor(any())
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
@Test
|
|
584
|
-
fun applyTopBarOptions_setTitleComponent() {
|
|
585
|
-
val applyComponent = Options()
|
|
586
|
-
applyComponent.topBar.title.component.name = Text("Component1")
|
|
587
|
-
applyComponent.topBar.title.component.componentId = Text("Component1id")
|
|
588
|
-
uut.applyChildOptions(applyComponent, parent, child)
|
|
589
|
-
verify(topBarController).setTitleComponent(any())
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
@Test
|
|
593
|
-
fun mergeTopBarOptions_settingTitleDestroysComponent() {
|
|
594
|
-
val componentOptions = Options()
|
|
595
|
-
componentOptions.topBar.title.component = titleComponent1
|
|
596
|
-
uut.applyChildOptions(componentOptions, parent, child)
|
|
597
|
-
val applyCaptor = argumentCaptor<TitleBarReactViewController>()
|
|
598
|
-
verify(topBarController).setTitleComponent(applyCaptor.capture())
|
|
599
|
-
val titleOptions = Options()
|
|
600
|
-
titleOptions.topBar.title.text = Text("Some title")
|
|
601
|
-
uut.mergeChildOptions(titleOptions, Options.EMPTY, parent, child)
|
|
602
|
-
assertThat(applyCaptor.firstValue.isDestroyed).isTrue()
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
@Test
|
|
606
|
-
fun mergeTopBarOptions_doesNotRecreateTitleComponentIfEquals() {
|
|
607
|
-
val options = Options()
|
|
608
|
-
options.topBar.title.component = titleComponent1
|
|
609
|
-
uut.applyChildOptions(options, parent, child)
|
|
610
|
-
val applyCaptor = argumentCaptor<TitleBarReactViewController>()
|
|
611
|
-
verify(topBarController).setTitleComponent(applyCaptor.capture())
|
|
612
|
-
uut.mergeChildOptions(options, Options.EMPTY, parent, child)
|
|
613
|
-
verify(topBarController, times(2)).setTitleComponent(applyCaptor.firstValue)
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
@Test
|
|
617
|
-
fun mergeTopBarOptions_previousTitleComponentIsDestroyed() {
|
|
618
|
-
val options = Options()
|
|
619
|
-
options.topBar.title.component = titleComponent1
|
|
620
|
-
uut.applyChildOptions(options, parent, child)
|
|
621
|
-
|
|
622
|
-
val toMerge = Options()
|
|
623
|
-
toMerge.topBar.title.component = titleComponent2
|
|
624
|
-
uut.mergeChildOptions(toMerge, Options.EMPTY, parent, child)
|
|
625
|
-
val captor = argumentCaptor<TitleBarReactViewController>()
|
|
626
|
-
verify(topBarController, times(2)).setTitleComponent(captor.capture())
|
|
627
|
-
assertThat(captor.firstValue).isNotEqualTo(captor.secondValue)
|
|
628
|
-
assertThat(captor.firstValue.isDestroyed).isTrue()
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
@Test
|
|
632
|
-
fun mergeTopTabsOptions() {
|
|
633
|
-
val options = Options()
|
|
634
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
635
|
-
verify(topBar, never()).applyTopTabsColors(any(), any())
|
|
636
|
-
verify(topBar, never()).applyTopTabsFontSize(any())
|
|
637
|
-
verify(topBar, never()).setTopTabsVisible(any())
|
|
638
|
-
options.topTabs.selectedTabColor = ThemeColour(Colour(1))
|
|
639
|
-
options.topTabs.unselectedTabColor = ThemeColour(Colour(1))
|
|
640
|
-
options.topTabs.fontSize = Number(1)
|
|
641
|
-
options.topTabs.visible = Bool(true)
|
|
642
|
-
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child)
|
|
643
|
-
verify(topBar).applyTopTabsColors(options.topTabs.selectedTabColor, options.topTabs.unselectedTabColor)
|
|
644
|
-
verify(topBar).applyTopTabsFontSize(options.topTabs.fontSize)
|
|
645
|
-
verify(topBar).setTopTabsVisible(any())
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
@Test
|
|
649
|
-
fun applyInitialChildLayoutOptions() {
|
|
650
|
-
val options = Options()
|
|
651
|
-
options.topBar.visible = Bool(false)
|
|
652
|
-
options.topBar.animate = Bool(true)
|
|
653
|
-
uut.applyInitialChildLayoutOptions(options)
|
|
654
|
-
verify(topBarController).hide()
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
@Test
|
|
658
|
-
fun applyButtons_buttonColorIsMergedToButtons() {
|
|
659
|
-
val options = Options()
|
|
660
|
-
val rightButton1 = ButtonOptions()
|
|
661
|
-
val rightButton2 = ButtonOptions()
|
|
662
|
-
val leftButton = ButtonOptions()
|
|
663
|
-
options.topBar.rightButtonColor = ThemeColour(Colour(10))
|
|
664
|
-
options.topBar.leftButtonColor = ThemeColour(Colour(100))
|
|
665
|
-
options.topBar.buttons.right = ArrayList()
|
|
666
|
-
options.topBar.buttons.right!!.add(rightButton1)
|
|
667
|
-
options.topBar.buttons.right!!.add(rightButton2)
|
|
668
|
-
options.topBar.buttons.left = ArrayList()
|
|
669
|
-
options.topBar.buttons.left!!.add(leftButton)
|
|
670
|
-
uut.applyChildOptions(options, parent, child)
|
|
671
|
-
val rightCaptor = argumentCaptor<List<ButtonOptions>>()
|
|
672
|
-
verify(topBarController).applyRightButtonsOptions(any(),rightCaptor.capture(), any())
|
|
673
|
-
assertThat(rightCaptor.firstValue[0].color.get()).isEqualTo(options.topBar.rightButtonColor.get())
|
|
674
|
-
assertThat(rightCaptor.firstValue[1].color.get()).isEqualTo(options.topBar.rightButtonColor.get())
|
|
675
|
-
assertThat(rightCaptor.firstValue[0]).isNotEqualTo(rightButton1)
|
|
676
|
-
assertThat(rightCaptor.firstValue[1]).isNotEqualTo(rightButton2)
|
|
677
|
-
val leftCaptor = argumentCaptor<List<ButtonOptions>>()
|
|
678
|
-
verify(topBarController).applyLeftButtonsOptions(any(),leftCaptor.capture(),any())
|
|
679
|
-
assertThat(leftCaptor.firstValue[0].color).isEqualTo(options.topBar.leftButtonColor)
|
|
680
|
-
assertThat(leftCaptor.firstValue[0]).isNotEqualTo(leftButton)
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
@Test
|
|
684
|
-
fun applyTopBarOptions_backgroundComponentIsCreatedOnceIfNameAndIdAreEqual() {
|
|
685
|
-
val o = Options()
|
|
686
|
-
o.topBar.background.component.name = Text("comp")
|
|
687
|
-
o.topBar.background.component.componentId = Text("compId")
|
|
688
|
-
uut.applyChildOptions(o, parent, Mocks.viewController())
|
|
689
|
-
assertThat(uut.backgroundComponents.size).isOne()
|
|
690
|
-
uut.applyChildOptions(o, parent, Mocks.viewController())
|
|
691
|
-
assertThat(uut.backgroundComponents.size).isOne()
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
@Test
|
|
695
|
-
fun mergeChildOptions_applyTopBarButtonsColor() {
|
|
696
|
-
val mergeOptions = Options()
|
|
697
|
-
val initialOptions = Options()
|
|
698
|
-
val rightButton = ButtonOptions()
|
|
699
|
-
val leftButton = ButtonOptions()
|
|
700
|
-
initialOptions.topBar.buttons.right = ArrayList(listOf(rightButton))
|
|
701
|
-
initialOptions.topBar.buttons.left = ArrayList(listOf(leftButton))
|
|
702
|
-
|
|
703
|
-
//add buttons
|
|
704
|
-
uut.applyChildOptions(initialOptions, parent, child)
|
|
705
|
-
|
|
706
|
-
//Merge color change for right and left buttons
|
|
707
|
-
mergeOptions.topBar.rightButtonColor = ThemeColour(Colour(100))
|
|
708
|
-
mergeOptions.topBar.leftButtonColor = ThemeColour(Colour(10))
|
|
709
|
-
val rightController = spy(ButtonController(activity, ButtonPresenter(activity, rightButton, iconResolver), rightButton, buttonCreator, mock()))
|
|
710
|
-
val leftController = spy(ButtonController(activity, ButtonPresenter(activity, leftButton, iconResolver), leftButton, buttonCreator, mock()))
|
|
711
|
-
uut.setComponentsButtonController(child.view, rightController, leftController)
|
|
712
|
-
uut.mergeChildOptions(mergeOptions, initialOptions, parent, child)
|
|
713
|
-
|
|
714
|
-
val rightColorCaptor = argumentCaptor<ThemeColour>()
|
|
715
|
-
verify(rightController).applyColor(any(), rightColorCaptor.capture())
|
|
716
|
-
assertThat(rightColorCaptor.allValues[0]).isEqualTo(mergeOptions.topBar.rightButtonColor)
|
|
717
|
-
|
|
718
|
-
val leftColorCaptor = argumentCaptor<ThemeColour>()
|
|
719
|
-
verify(leftController).applyColor(any(), leftColorCaptor.capture())
|
|
720
|
-
assertThat(leftColorCaptor.allValues[0]).isEqualTo(mergeOptions.topBar.leftButtonColor)
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
@Test
|
|
724
|
-
fun mergeChildOptions_applyTopBarButtonsDisabledColor() {
|
|
725
|
-
val mergeOptions = Options()
|
|
726
|
-
val initialOptions = Options()
|
|
727
|
-
val rightButton = ButtonOptions()
|
|
728
|
-
val leftButton = ButtonOptions()
|
|
729
|
-
initialOptions.topBar.buttons.right = ArrayList(listOf(rightButton))
|
|
730
|
-
initialOptions.topBar.buttons.left = ArrayList(listOf(leftButton))
|
|
731
|
-
|
|
732
|
-
//add buttons
|
|
733
|
-
uut.applyChildOptions(initialOptions, parent, child)
|
|
734
|
-
|
|
735
|
-
//Merge color change for right and left buttons
|
|
736
|
-
mergeOptions.topBar.rightButtonDisabledColor = ThemeColour(Colour(100))
|
|
737
|
-
mergeOptions.topBar.leftButtonDisabledColor = ThemeColour(Colour(10))
|
|
738
|
-
val rightController = spy(ButtonController(activity, ButtonPresenter(activity, rightButton, iconResolver), rightButton, buttonCreator, mock { }))
|
|
739
|
-
val leftController = spy(ButtonController(activity, ButtonPresenter(activity, leftButton, iconResolver), leftButton, buttonCreator, mock { }))
|
|
740
|
-
uut.setComponentsButtonController(child.view, rightController, leftController)
|
|
741
|
-
uut.mergeChildOptions(mergeOptions, initialOptions, parent, child)
|
|
742
|
-
|
|
743
|
-
val rightColorCaptor = argumentCaptor<ThemeColour>()
|
|
744
|
-
verify(rightController).applyDisabledColor(any(), rightColorCaptor.capture())
|
|
745
|
-
assertThat(rightColorCaptor.allValues[0]).isEqualTo(mergeOptions.topBar.rightButtonDisabledColor)
|
|
746
|
-
|
|
747
|
-
val leftColorCaptor = argumentCaptor<ThemeColour>()
|
|
748
|
-
verify(leftController).applyDisabledColor(any(), leftColorCaptor.capture())
|
|
749
|
-
assertThat(leftColorCaptor.allValues[0]).isEqualTo(mergeOptions.topBar.leftButtonDisabledColor)
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
@Test
|
|
753
|
-
fun mergeChildOptions_ignoreColorWhenClearingButtons() {
|
|
754
|
-
val mergeOptions = Options()
|
|
755
|
-
val initialOptions = Options()
|
|
756
|
-
val rightButton = ButtonOptions()
|
|
757
|
-
val leftButton = ButtonOptions()
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
//add buttons
|
|
761
|
-
initialOptions.topBar.buttons.right = ArrayList()
|
|
762
|
-
initialOptions.topBar.buttons.left = ArrayList()
|
|
763
|
-
uut.applyChildOptions(initialOptions, parent, child)
|
|
764
|
-
|
|
765
|
-
//Merge color change for right and left buttons with clear buttons
|
|
766
|
-
mergeOptions.topBar.buttons.right = ArrayList()
|
|
767
|
-
mergeOptions.topBar.buttons.left = ArrayList()
|
|
768
|
-
mergeOptions.topBar.rightButtonColor = ThemeColour(Colour(100))
|
|
769
|
-
mergeOptions.topBar.leftButtonColor = ThemeColour(Colour(100))
|
|
770
|
-
mergeOptions.topBar.rightButtonDisabledColor = ThemeColour(Colour(100))
|
|
771
|
-
mergeOptions.topBar.leftButtonDisabledColor = ThemeColour(Colour(10))
|
|
772
|
-
val rightController = spy(ButtonController(activity, ButtonPresenter(activity, rightButton, iconResolver), rightButton, buttonCreator, mock { }))
|
|
773
|
-
val leftController = spy(ButtonController(activity, ButtonPresenter(activity, leftButton, iconResolver), leftButton, buttonCreator, mock { }))
|
|
774
|
-
uut.setComponentsButtonController(child.view, rightController, leftController)
|
|
775
|
-
uut.mergeChildOptions(mergeOptions, initialOptions, parent, child)
|
|
776
|
-
|
|
777
|
-
verify(rightController, never()).applyColor(any(), any())
|
|
778
|
-
verify(leftController, never()).applyColor(any(), any())
|
|
779
|
-
verify(leftController, never()).applyDisabledColor(any(), any())
|
|
780
|
-
verify(leftController, never()).applyDisabledColor(any(), any())
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
@Test
|
|
786
|
-
fun mergeChildOptions_buttonColorIsResolvedFromAppliedOptions() {
|
|
787
|
-
val appliedOptions = Options()
|
|
788
|
-
appliedOptions.topBar.rightButtonColor = ThemeColour(Colour(10))
|
|
789
|
-
appliedOptions.topBar.leftButtonColor = ThemeColour(Colour(100))
|
|
790
|
-
|
|
791
|
-
val options2 = Options()
|
|
792
|
-
val rightButton1 = ButtonOptions()
|
|
793
|
-
val rightButton2 = ButtonOptions()
|
|
794
|
-
val leftButton = ButtonOptions()
|
|
795
|
-
options2.topBar.buttons.right = ArrayList(listOf(rightButton1, rightButton2))
|
|
796
|
-
options2.topBar.buttons.left = ArrayList(listOf(leftButton))
|
|
797
|
-
|
|
798
|
-
uut.mergeChildOptions(options2, appliedOptions, parent, child)
|
|
799
|
-
val rightCaptor = argumentCaptor<List<ButtonOptions>>()
|
|
800
|
-
verify(topBarController).mergeRightButtonsOptions(any(),rightCaptor.capture(), any())
|
|
801
|
-
assertThat(rightCaptor.firstValue[0].color.get()).isEqualTo(appliedOptions.topBar.rightButtonColor.get())
|
|
802
|
-
assertThat(rightCaptor.firstValue[1].color.get()).isEqualTo(appliedOptions.topBar.rightButtonColor.get())
|
|
803
|
-
assertThat(rightCaptor.firstValue[0]).isNotEqualTo(rightButton1)
|
|
804
|
-
assertThat(rightCaptor.firstValue[1]).isNotEqualTo(rightButton2)
|
|
805
|
-
val leftCaptor = argumentCaptor<List<ButtonOptions>>()
|
|
806
|
-
verify(topBarController).mergeLeftButtonsOptions(any(),leftCaptor.capture(), any())
|
|
807
|
-
assertThat(leftCaptor.firstValue[0].color.get()).isEqualTo(appliedOptions.topBar.leftButtonColor.get())
|
|
808
|
-
assertThat(leftCaptor.firstValue[0]).isNotEqualTo(leftButton)
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
@Test
|
|
812
|
-
fun mergeChildOptions_buttonColorIsResolvedFromMergedOptions() {
|
|
813
|
-
val resolvedOptions = Options()
|
|
814
|
-
resolvedOptions.topBar.rightButtonColor = ThemeColour(Colour(10))
|
|
815
|
-
resolvedOptions.topBar.leftButtonColor = ThemeColour(Colour(100))
|
|
816
|
-
|
|
817
|
-
val rightButton1 = ButtonOptions()
|
|
818
|
-
val rightButton2 = ButtonOptions()
|
|
819
|
-
val leftButton = ButtonOptions()
|
|
820
|
-
val options2 = Options()
|
|
821
|
-
options2.topBar.buttons.right = ArrayList(listOf(rightButton1, rightButton2))
|
|
822
|
-
options2.topBar.buttons.left = ArrayList(listOf(leftButton))
|
|
823
|
-
|
|
824
|
-
uut.mergeChildOptions(options2, resolvedOptions, parent, child)
|
|
825
|
-
val rightCaptor = argumentCaptor<List<ButtonOptions>>()
|
|
826
|
-
verify(topBarController).mergeRightButtonsOptions(any(),rightCaptor.capture(), any())
|
|
827
|
-
assertThat(rightCaptor.firstValue[0].color.get()).isEqualTo(resolvedOptions.topBar.rightButtonColor.get())
|
|
828
|
-
assertThat(rightCaptor.firstValue[1].color.get()).isEqualTo(resolvedOptions.topBar.rightButtonColor.get())
|
|
829
|
-
assertThat(rightCaptor.firstValue[0]).isNotEqualTo(rightButton1)
|
|
830
|
-
assertThat(rightCaptor.firstValue[1]).isNotEqualTo(rightButton2)
|
|
831
|
-
val leftCaptor = argumentCaptor<List<ButtonOptions>>()
|
|
832
|
-
verify(topBarController).mergeLeftButtonsOptions(any(),leftCaptor.capture(), any())
|
|
833
|
-
assertThat(leftCaptor.firstValue[0].color.get()).isEqualTo(resolvedOptions.topBar.leftButtonColor.get())
|
|
834
|
-
assertThat(leftCaptor.firstValue[0]).isNotEqualTo(leftButton)
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
@Test
|
|
838
|
-
fun buttonControllers_buttonControllersArePassedToTopBar() {
|
|
839
|
-
val options = Options()
|
|
840
|
-
options.topBar.buttons.right = ArrayList(listOf(textBtn1))
|
|
841
|
-
options.topBar.buttons.left = ArrayList(listOf(textBtn1))
|
|
842
|
-
uut.applyChildOptions(options, parent, child)
|
|
843
|
-
val rightCaptor = argumentCaptor<List<ButtonOptions>>()
|
|
844
|
-
val leftCaptor = argumentCaptor<List<ButtonOptions>>()
|
|
845
|
-
verify(topBarController).applyRightButtonsOptions(any(),rightCaptor.capture(),any())
|
|
846
|
-
verify(topBarController).applyLeftButtonsOptions(any(),leftCaptor.capture(),any())
|
|
847
|
-
assertThat(rightCaptor.firstValue.size).isOne()
|
|
848
|
-
assertThat(leftCaptor.firstValue.size).isOne()
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
@Test
|
|
852
|
-
fun buttonControllers_storesButtonsByComponent() {
|
|
853
|
-
val options = Options()
|
|
854
|
-
options.topBar.buttons.right = ArrayList(listOf(textBtn1))
|
|
855
|
-
options.topBar.buttons.left = ArrayList(listOf(textBtn2))
|
|
856
|
-
uut.applyChildOptions(options, parent, child)
|
|
857
|
-
val componentButtons = uut.getComponentButtons(child.view)
|
|
858
|
-
assertThat(componentButtons.size).isEqualTo(2)
|
|
859
|
-
assertThat(componentButtons[0].button.text.get()).isEqualTo(textBtn1.text.get())
|
|
860
|
-
assertThat(componentButtons[1].button.text.get()).isEqualTo(textBtn2.text.get())
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
@Test
|
|
864
|
-
fun buttonControllers_createdOnce() {
|
|
865
|
-
val options = Options()
|
|
866
|
-
options.topBar.buttons.right = ArrayList(listOf(textBtn1))
|
|
867
|
-
options.topBar.buttons.left = ArrayList(listOf(textBtn2))
|
|
868
|
-
uut.applyChildOptions(options, parent, child)
|
|
869
|
-
val buttons1 = uut.getComponentButtons(child.view)
|
|
870
|
-
uut.applyChildOptions(options, parent, child)
|
|
871
|
-
val buttons2 = uut.getComponentButtons(child.view)
|
|
872
|
-
for (i in 0..1) {
|
|
873
|
-
assertThat(buttons1[i]).isEqualTo(buttons2[i])
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
@Test
|
|
878
|
-
fun applyButtons_doesNotDestroyOtherComponentButtons() {
|
|
879
|
-
val options = Options()
|
|
880
|
-
options.topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
881
|
-
options.topBar.buttons.left = ArrayList(listOf(componentBtn2))
|
|
882
|
-
uut.applyChildOptions(options, parent, child)
|
|
883
|
-
val buttons = uut.getComponentButtons(child.view)
|
|
884
|
-
buttons.forEach(ButtonController::ensureViewIsCreated)
|
|
885
|
-
uut.applyChildOptions(options, parent, otherChild)
|
|
886
|
-
buttons.forEach { assertThat(it.isDestroyed).isFalse() }
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
@Test
|
|
890
|
-
fun applyChildOptions_shouldNotPassAnimateLeftRightButtonBarWhenNoValue() {
|
|
891
|
-
val options = Options().apply {
|
|
892
|
-
topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
893
|
-
topBar.buttons.left = ArrayList(listOf(componentBtn2))
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
uut.applyChildOptions(options, parent, child)
|
|
897
|
-
verify(topBar, never()).animateLeftButtons(any())
|
|
898
|
-
verify(topBar, never()).animateLeftButtons(any())
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
@Test
|
|
902
|
-
fun applyChildOptions_shouldPassAnimateLeftRightButtonBar() {
|
|
903
|
-
val options = Options().apply {
|
|
904
|
-
topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
905
|
-
topBar.buttons.left = ArrayList(listOf(componentBtn2))
|
|
906
|
-
topBar.animateLeftButtons = Bool(false)
|
|
907
|
-
topBar.animateRightButtons = Bool(true)
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
uut.applyChildOptions(options, parent, child)
|
|
911
|
-
verify(topBar).animateRightButtons(true)
|
|
912
|
-
verify(topBar).animateLeftButtons(false)
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
@Test
|
|
916
|
-
fun onChildDestroyed_destroyedButtons() {
|
|
917
|
-
val options = Options()
|
|
918
|
-
options.topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
919
|
-
options.topBar.buttons.left = ArrayList(listOf(componentBtn2))
|
|
920
|
-
uut.applyChildOptions(options, parent, child)
|
|
921
|
-
val buttons = uut.getComponentButtons(child.view)
|
|
922
|
-
buttons.forEach(ButtonController::ensureViewIsCreated)
|
|
923
|
-
uut.onChildDestroyed(child)
|
|
924
|
-
buttons.forEach { assertThat(it.isDestroyed).isTrue() }
|
|
925
|
-
assertThat(uut.getComponentButtons(child.view, null)).isNull()
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
@Test
|
|
929
|
-
fun onChildDestroyed_mergedRightButtonsAreDestroyed() {
|
|
930
|
-
val options = Options()
|
|
931
|
-
options.topBar.buttons.right = ArrayList(listOf(componentBtn1))
|
|
932
|
-
uut.mergeChildOptions(options, Options.EMPTY, parent, child)
|
|
933
|
-
val buttons = uut.getComponentButtons(child.view)
|
|
934
|
-
assertThat(buttons).hasSize(1)
|
|
935
|
-
uut.onChildDestroyed(child)
|
|
936
|
-
assertThat(buttons[0].isDestroyed).isTrue()
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
@Test
|
|
940
|
-
fun applyChildOptions_topBarShouldExtendBehindStatusBarWhenDrawBehind() {
|
|
941
|
-
val statusBarHeight = 10
|
|
942
|
-
val statusBarHeightDp = 20
|
|
943
|
-
val topBarHeightDp = 100
|
|
944
|
-
val options = Options().apply {
|
|
945
|
-
statusBar.drawBehind = Bool(true)
|
|
946
|
-
}
|
|
947
|
-
Mockito.`when`(child.resolveCurrentOptions()).thenReturn(options)
|
|
948
|
-
mockSystemUiUtils(statusBarHeight, statusBarHeightDp) {
|
|
949
|
-
uut.applyChildOptions(Options.EMPTY.copy().apply {
|
|
950
|
-
topBar.height = Number(topBarHeightDp)
|
|
951
|
-
}, parent, child)
|
|
952
|
-
assertThat(topBar.paddingTop).isEqualTo(statusBarHeight)
|
|
953
|
-
assertThat(topBar.y).isEqualTo(0f)
|
|
954
|
-
assertThat(topBar.layoutParams.height).isEqualTo(statusBarHeightDp + topBarHeightDp)
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
@Test
|
|
959
|
-
fun mergeChildOptions_topBarShouldExtendBehindStatusBarWhenDrawBehind() {
|
|
960
|
-
val statusBarHeight = 10
|
|
961
|
-
val statusBarHeightDp = 20
|
|
962
|
-
val topBarHeightDp = 100
|
|
963
|
-
|
|
964
|
-
mockSystemUiUtils(statusBarHeight, statusBarHeightDp) {
|
|
965
|
-
uut.mergeChildOptions(Options.EMPTY.copy().apply {
|
|
966
|
-
topBar.height = Number(topBarHeightDp)
|
|
967
|
-
statusBar.drawBehind = Bool(true)
|
|
968
|
-
}, Options.EMPTY, parent, child)
|
|
969
|
-
assertThat(topBar.paddingTop).isEqualTo(statusBarHeight)
|
|
970
|
-
assertThat(topBar.y).isEqualTo(0f)
|
|
971
|
-
assertThat(topBar.layoutParams.height).isEqualTo(statusBarHeightDp + topBarHeightDp)
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
@Test
|
|
976
|
-
fun mergeChildOptions_topBarShouldNotExtendBehindStatusBarWhenNoDrawBehind() {
|
|
977
|
-
val statusBarHeight = 10
|
|
978
|
-
val statusBarHeightDp = 20
|
|
979
|
-
val topBarHeightDp = 100
|
|
980
|
-
|
|
981
|
-
mockSystemUiUtils(statusBarHeight, statusBarHeightDp) {
|
|
982
|
-
uut.mergeChildOptions(Options.EMPTY.copy().apply {
|
|
983
|
-
topBar.height = Number(topBarHeightDp)
|
|
984
|
-
statusBar.drawBehind = Bool(false)
|
|
985
|
-
}, Options.EMPTY, parent, child)
|
|
986
|
-
assertThat(topBar.paddingTop).isEqualTo(0)
|
|
987
|
-
assertThat(topBar.y).isEqualTo(0f)
|
|
988
|
-
assertThat(topBar.layoutParams.height).isEqualTo( topBarHeightDp)
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
@Test
|
|
993
|
-
fun applyTopInsets_topBarIsDrawnUnderStatusBarIfDrawBehindIsTrue() {
|
|
994
|
-
val options = Options()
|
|
995
|
-
options.statusBar.drawBehind = Bool(true)
|
|
996
|
-
uut.applyTopInsets(parent, child)
|
|
997
|
-
assertThat(topBar.y).isEqualTo(0f)
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
@Test
|
|
1001
|
-
fun applyTopInsets_topBarIsDrawnUnderStatusBarIfStatusBarIsHidden() {
|
|
1002
|
-
val options = Options()
|
|
1003
|
-
options.statusBar.visible = Bool(false)
|
|
1004
|
-
uut.applyTopInsets(parent, Mocks.viewController())
|
|
1005
|
-
assertThat(topBar.y).isEqualTo(0f)
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
@Test
|
|
1009
|
-
fun applyTopInsets_delegatesToChild() {
|
|
1010
|
-
uut.applyTopInsets(parent, child)
|
|
1011
|
-
verify(child).applyTopInset()
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
@Test
|
|
1015
|
-
fun applyChildOptions_shouldNotChangeTopMargin() {
|
|
1016
|
-
val options = Options()
|
|
1017
|
-
(topBar.layoutParams as ViewGroup.MarginLayoutParams).topMargin = 20
|
|
1018
|
-
uut.applyChildOptions(options, parent, child)
|
|
1019
|
-
assertThat((topBar.layoutParams as ViewGroup.MarginLayoutParams).topMargin).isEqualTo(20)
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
@Test
|
|
1023
|
-
fun applyChildOptions_shouldChangeTopMargin() {
|
|
1024
|
-
val options = Options()
|
|
1025
|
-
(topBar.layoutParams as ViewGroup.MarginLayoutParams).topMargin = 20
|
|
1026
|
-
options.topBar.topMargin = Number(10)
|
|
1027
|
-
uut.applyChildOptions(options, parent, child)
|
|
1028
|
-
assertThat((topBar.layoutParams as ViewGroup.MarginLayoutParams).topMargin).isEqualTo(10)
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
private fun getCurrentChild()=parent.currentChild
|
|
1032
|
-
private fun assertTopBarOptions(options: Options, t: Int) {
|
|
1033
|
-
if (options.topBar.title.component.hasValue()) {
|
|
1034
|
-
verify(topBar, never()).title = any()
|
|
1035
|
-
verify(topBar, never()).setSubtitle(any())
|
|
1036
|
-
verify(topBar, times(t)).setTitleComponent(any<View>(), any<Alignment>())
|
|
1037
|
-
} else if (options.topBar.title.text.hasValue()) {
|
|
1038
|
-
verify(topBar, times(t)).title = any()
|
|
1039
|
-
verify(topBar, times(t)).setSubtitle(any())
|
|
1040
|
-
verify(topBar, never()).setTitleComponent(any<View>())
|
|
1041
|
-
}
|
|
1042
|
-
verify(topBar, times(t)).setBackgroundColor(any())
|
|
1043
|
-
verify(topBar, times(t)).setTitleTextColor(any())
|
|
1044
|
-
verify(topBar, times(t)).setSubtitleFontSize(any())
|
|
1045
|
-
verify(topBar, times(t)).setTitleTypeface(any(), any())
|
|
1046
|
-
verify(topBar, times(t)).setSubtitleTypeface(any(), any())
|
|
1047
|
-
verify(topBar, times(t)).setSubtitleColor(any())
|
|
1048
|
-
verify(topBar, times(t)).setTestId(any())
|
|
1049
|
-
verify(topBarController, times(t)).hide()
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
private fun createTopBarController() {
|
|
1053
|
-
topBarController = spy(object : TopBarController() {
|
|
1054
|
-
override fun createTopBar(context: Context, stackLayout: StackLayout): TopBar {
|
|
1055
|
-
topBar = spy(super.createTopBar(context, stackLayout))
|
|
1056
|
-
topBar.layout(0, 0, 1000, UiUtils.getTopBarHeight(activity))
|
|
1057
|
-
return topBar
|
|
1058
|
-
}
|
|
1059
|
-
})
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
fun component(alignment: Alignment): ComponentOptions {
|
|
1063
|
-
val component = ComponentOptions()
|
|
1064
|
-
component.name = Text("myComp")
|
|
1065
|
-
component.alignment = alignment
|
|
1066
|
-
component.componentId = Text("compId")
|
|
1067
|
-
return component
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
private fun createTypeFaceLoader(): TypefaceLoaderMock {
|
|
1071
|
-
val map: MutableMap<String, Typeface> = HashMap()
|
|
1072
|
-
map[SOME_FONT_FAMILY] = SOME_TYPEFACE
|
|
1073
|
-
return TypefaceLoaderMock(map)
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
companion object {
|
|
1077
|
-
private val EMPTY_OPTIONS = Options()
|
|
1078
|
-
const val SOME_FONT_FAMILY = "someFontFamily"
|
|
1079
|
-
val SOME_TYPEFACE = mock<Typeface>()
|
|
1080
|
-
}
|
|
1081
|
-
}
|