react-native-navigation 7.24.3 → 7.25.0
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/RNNComponentViewController.m +5 -0
- package/lib/ios/RNNLayoutOptions.h +2 -1
- package/lib/ios/RNNLayoutOptions.m +4 -0
- package/lib/ios/RNNStackPresenter.m +1 -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
package/lib/android/app/src/test/java/com/reactnativenavigation/views/OverlayTouchDelegateTest.java
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.views;
|
|
2
|
-
|
|
3
|
-
import android.view.MotionEvent;
|
|
4
|
-
|
|
5
|
-
import com.reactnativenavigation.BaseTest;
|
|
6
|
-
import com.reactnativenavigation.options.params.Bool;
|
|
7
|
-
import com.reactnativenavigation.react.ReactView;
|
|
8
|
-
import com.reactnativenavigation.views.component.ComponentLayout;
|
|
9
|
-
import com.reactnativenavigation.views.touch.OverlayTouchDelegate;
|
|
10
|
-
|
|
11
|
-
import org.junit.Test;
|
|
12
|
-
|
|
13
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
14
|
-
import static org.mockito.Mockito.mock;
|
|
15
|
-
import static org.mockito.Mockito.spy;
|
|
16
|
-
import static org.mockito.Mockito.times;
|
|
17
|
-
import static org.mockito.Mockito.verify;
|
|
18
|
-
|
|
19
|
-
public class OverlayTouchDelegateTest extends BaseTest {
|
|
20
|
-
private OverlayTouchDelegate uut;
|
|
21
|
-
private final int x = 10;
|
|
22
|
-
private final int y = 10;
|
|
23
|
-
private final MotionEvent downEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, x, y, 0);
|
|
24
|
-
private final MotionEvent upEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, x, y, 0);
|
|
25
|
-
private ComponentLayout component;
|
|
26
|
-
|
|
27
|
-
@Override
|
|
28
|
-
public void beforeEach() {
|
|
29
|
-
ReactView reactView = mock(ReactView.class);
|
|
30
|
-
component = mock(ComponentLayout.class);
|
|
31
|
-
uut = spy(new OverlayTouchDelegate(component, reactView));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Test
|
|
35
|
-
public void downEventIsHandled() {
|
|
36
|
-
uut.setInterceptTouchOutside(new Bool(true));
|
|
37
|
-
uut.onInterceptTouchEvent(downEvent);
|
|
38
|
-
verify(uut, times(1)).handleDown(downEvent);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Test
|
|
42
|
-
public void onlyDownEventIsHandled() {
|
|
43
|
-
uut.setInterceptTouchOutside(new Bool(true));
|
|
44
|
-
uut.onInterceptTouchEvent(upEvent);
|
|
45
|
-
verify(uut, times(0)).handleDown(upEvent);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@Test
|
|
49
|
-
public void nonDownEventsDontIntercept() {
|
|
50
|
-
uut.setInterceptTouchOutside(new Bool(true));
|
|
51
|
-
assertThat(uut.onInterceptTouchEvent(upEvent)).isFalse();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@Test
|
|
55
|
-
public void nonDownEventsInvokeSuperImplementation() {
|
|
56
|
-
uut.setInterceptTouchOutside(new Bool(true));
|
|
57
|
-
uut.onInterceptTouchEvent(upEvent);
|
|
58
|
-
verify(component).superOnInterceptTouchEvent(upEvent);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,477 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.views
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.graphics.Color
|
|
5
|
-
import android.view.Gravity
|
|
6
|
-
import android.view.View
|
|
7
|
-
import android.view.ViewGroup
|
|
8
|
-
import android.widget.FrameLayout
|
|
9
|
-
import android.widget.LinearLayout
|
|
10
|
-
import org.mockito.kotlin.spy
|
|
11
|
-
import org.mockito.kotlin.verify
|
|
12
|
-
import com.reactnativenavigation.BaseTest
|
|
13
|
-
import com.reactnativenavigation.options.Alignment
|
|
14
|
-
import com.reactnativenavigation.options.params.Colour
|
|
15
|
-
import com.reactnativenavigation.options.params.ThemeColour
|
|
16
|
-
import com.reactnativenavigation.options.params.NullThemeColour
|
|
17
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar
|
|
18
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.DEFAULT_LEFT_MARGIN_PX
|
|
19
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleAndButtonsContainer
|
|
20
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleSubTitleLayout
|
|
21
|
-
import org.assertj.core.api.Assertions
|
|
22
|
-
import org.assertj.core.api.AssertionsForInterfaceTypes.assertThat
|
|
23
|
-
import org.junit.Test
|
|
24
|
-
import org.mockito.Mockito
|
|
25
|
-
import org.mockito.Mockito.times
|
|
26
|
-
import kotlin.math.roundToInt
|
|
27
|
-
import kotlin.test.assertFalse
|
|
28
|
-
|
|
29
|
-
private const val UUT_WIDTH = 1000
|
|
30
|
-
private const val UUT_HEIGHT = 100
|
|
31
|
-
|
|
32
|
-
class TitleAndButtonsContainerTest : BaseTest() {
|
|
33
|
-
lateinit var uut: TitleAndButtonsContainer
|
|
34
|
-
private lateinit var activity: Activity
|
|
35
|
-
private lateinit var mockLeftBar: ButtonBar
|
|
36
|
-
private lateinit var mockRightBar: ButtonBar
|
|
37
|
-
private lateinit var mockComponent: View
|
|
38
|
-
override fun beforeEach() {
|
|
39
|
-
super.beforeEach()
|
|
40
|
-
setup()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private fun setup(
|
|
44
|
-
mockUUT: Boolean = true,
|
|
45
|
-
direction: Int = View.LAYOUT_DIRECTION_LTR,
|
|
46
|
-
titleBarWidth: Int = 0,
|
|
47
|
-
titleBarHeight: Int = 0,
|
|
48
|
-
componentWidth: Int = 0,
|
|
49
|
-
componentHeight: Int = 0,
|
|
50
|
-
rightBarWidth: Int = 0,
|
|
51
|
-
leftBarWidth: Int = 0,
|
|
52
|
-
alignment: Alignment = Alignment.Default
|
|
53
|
-
) {
|
|
54
|
-
activity = newActivity()
|
|
55
|
-
val originalUUT = TitleAndButtonsContainer(activity)
|
|
56
|
-
uut = if (mockUUT) spy(originalUUT) else originalUUT
|
|
57
|
-
mockLeftBar = spy(ButtonBar(activity))
|
|
58
|
-
mockRightBar = spy(ButtonBar(activity))
|
|
59
|
-
mockComponent = spy(View(activity))
|
|
60
|
-
val mockTitleSubtitleLayout = spy(TitleSubTitleLayout(activity))
|
|
61
|
-
Mockito.doReturn(rightBarWidth).`when`(mockRightBar).measuredWidth
|
|
62
|
-
Mockito.doReturn(leftBarWidth).`when`(mockLeftBar).measuredWidth
|
|
63
|
-
if (mockUUT)
|
|
64
|
-
Mockito.doReturn(direction).`when`(uut).layoutDirection
|
|
65
|
-
Mockito.doReturn(titleBarWidth).`when`(mockTitleSubtitleLayout).measuredWidth
|
|
66
|
-
Mockito.doReturn(titleBarHeight).`when`(mockTitleSubtitleLayout).measuredHeight
|
|
67
|
-
Mockito.doReturn(componentWidth).`when`(mockComponent).measuredWidth
|
|
68
|
-
Mockito.doReturn(componentHeight).`when`(mockComponent).measuredHeight
|
|
69
|
-
uut.setTitleBarAlignment(alignment)
|
|
70
|
-
if (rightBarWidth > 0 || leftBarWidth > 0)
|
|
71
|
-
uut.setButtonBars(mockLeftBar, mockRightBar)
|
|
72
|
-
if (componentWidth > 0)
|
|
73
|
-
uut.setComponent(mockComponent, alignment)
|
|
74
|
-
uut.setTitleSubtitleLayout(mockTitleSubtitleLayout)
|
|
75
|
-
|
|
76
|
-
activity.window.decorView.layoutDirection = direction
|
|
77
|
-
activity.setContentView(FrameLayout(activity).apply {
|
|
78
|
-
layoutDirection = direction
|
|
79
|
-
addView(uut, ViewGroup.LayoutParams(UUT_WIDTH, UUT_HEIGHT))
|
|
80
|
-
})
|
|
81
|
-
idleMainLooper()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@Test
|
|
85
|
-
fun `animateLeftRightButtons - should be false as default`(){
|
|
86
|
-
assertFalse(mockLeftBar.shouldAnimate)
|
|
87
|
-
assertFalse(mockRightBar.shouldAnimate)
|
|
88
|
-
}
|
|
89
|
-
@Test
|
|
90
|
-
fun `animateLeftRightButtons - should change corresponding button bar`(){
|
|
91
|
-
setup(rightBarWidth = 10,leftBarWidth = 20)
|
|
92
|
-
|
|
93
|
-
uut.animateLeftButtons(true)
|
|
94
|
-
verify(mockLeftBar).shouldAnimate=true
|
|
95
|
-
|
|
96
|
-
uut.animateLeftButtons(false)
|
|
97
|
-
verify(mockLeftBar).shouldAnimate=false
|
|
98
|
-
|
|
99
|
-
uut.animateRightButtons(true)
|
|
100
|
-
verify(mockRightBar).shouldAnimate=true
|
|
101
|
-
|
|
102
|
-
uut.animateRightButtons(false)
|
|
103
|
-
verify(mockRightBar).shouldAnimate=false
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
@Test
|
|
107
|
-
fun `setComponent - should not change component id`() {
|
|
108
|
-
val component = View(activity).apply { id = 19 }
|
|
109
|
-
val component2 = View(activity).apply { id = 29 }
|
|
110
|
-
uut.setComponent(component)
|
|
111
|
-
assertThat(component.id).isEqualTo(19)
|
|
112
|
-
|
|
113
|
-
uut.setComponent(component2)
|
|
114
|
-
assertThat(component.id).isEqualTo(19)
|
|
115
|
-
assertThat(component2.id).isEqualTo(29)
|
|
116
|
-
|
|
117
|
-
uut.clearTitle()
|
|
118
|
-
assertThat(component.id).isEqualTo(19)
|
|
119
|
-
assertThat(component2.id).isEqualTo(29)
|
|
120
|
-
|
|
121
|
-
uut.setComponent(component2)
|
|
122
|
-
assertThat(component.id).isEqualTo(19)
|
|
123
|
-
assertThat(component2.id).isEqualTo(29)
|
|
124
|
-
|
|
125
|
-
uut.setTitle("title")
|
|
126
|
-
assertThat(component.id).isEqualTo(19)
|
|
127
|
-
assertThat(component2.id).isEqualTo(29)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@Test
|
|
131
|
-
fun `onLayout - should set title component center vertically`() {
|
|
132
|
-
val componentHeight = (UUT_HEIGHT / 4f).roundToInt()
|
|
133
|
-
setup(componentWidth = 100, componentHeight = componentHeight)
|
|
134
|
-
|
|
135
|
-
val component = uut.getTitleComponent()
|
|
136
|
-
assertThat(component.top).isEqualTo((UUT_HEIGHT / 2f - componentHeight / 2f).roundToInt())
|
|
137
|
-
assertThat(component.bottom).isEqualTo((UUT_HEIGHT / 2f + componentHeight / 2f).roundToInt())
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
@Test
|
|
141
|
-
fun `onLayout - set title text should take all parent height`() {
|
|
142
|
-
setup(titleBarWidth = 100, titleBarHeight = UUT_HEIGHT)
|
|
143
|
-
|
|
144
|
-
val component = uut.getTitleComponent()
|
|
145
|
-
|
|
146
|
-
assertThat(component.layoutParams.height).isEqualTo(ViewGroup.LayoutParams.MATCH_PARENT)
|
|
147
|
-
assertThat(component.top).isEqualTo(0)
|
|
148
|
-
assertThat(component.bottom).isEqualTo(UUT_HEIGHT)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
@Test
|
|
152
|
-
fun `onLayout - title should not overlap with toolbar and have to re-layout`() {
|
|
153
|
-
val leftBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
154
|
-
val rightBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
155
|
-
val titleBarWidth = 3 * (UUT_WIDTH / 4f).roundToInt()
|
|
156
|
-
setup(titleBarWidth = titleBarWidth, titleBarHeight = UUT_HEIGHT, leftBarWidth = leftBarWidth, rightBarWidth = rightBarWidth)
|
|
157
|
-
|
|
158
|
-
val component = uut.getTitleComponent()
|
|
159
|
-
assertThat(component.left).isEqualTo(leftBarWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
160
|
-
assertThat(component.right).isEqualTo(UUT_WIDTH - rightBarWidth - DEFAULT_LEFT_MARGIN_PX)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
@Test
|
|
164
|
-
fun `onLayout - title component should not overlap with toolbar and have to re-layout`() {
|
|
165
|
-
val leftBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
166
|
-
val rightBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
167
|
-
val titleBarWidth = 3 * (UUT_WIDTH / 4f).roundToInt()
|
|
168
|
-
setup(componentWidth = titleBarWidth, componentHeight = UUT_HEIGHT, leftBarWidth = leftBarWidth, rightBarWidth =
|
|
169
|
-
rightBarWidth)
|
|
170
|
-
|
|
171
|
-
val component = uut.getTitleComponent()
|
|
172
|
-
assertThat(component.left).isEqualTo(leftBarWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
173
|
-
assertThat(component.right).isEqualTo(UUT_WIDTH - rightBarWidth - DEFAULT_LEFT_MARGIN_PX)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@Test
|
|
177
|
-
fun `onLayout - title should be aligned left and take needed the width + margins when no buttons`() {
|
|
178
|
-
val titleBarWidth = 200
|
|
179
|
-
setup(titleBarWidth = titleBarWidth)
|
|
180
|
-
|
|
181
|
-
val component = uut.getTitleComponent()
|
|
182
|
-
assertThat(component.left).isEqualTo(DEFAULT_LEFT_MARGIN_PX)
|
|
183
|
-
assertThat(component.right).isEqualTo(titleBarWidth + 2 * DEFAULT_LEFT_MARGIN_PX)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
@Test
|
|
187
|
-
fun `setTitle - RTL - should be aligned right and take available width when no buttons`() {
|
|
188
|
-
val titleBarWidth = 200
|
|
189
|
-
setup(direction = View.LAYOUT_DIRECTION_RTL, titleBarWidth = titleBarWidth)
|
|
190
|
-
|
|
191
|
-
val titleComponent = uut.getTitleComponent()
|
|
192
|
-
assertThat(titleComponent.right).isEqualTo(UUT_WIDTH - DEFAULT_LEFT_MARGIN_PX)
|
|
193
|
-
assertThat(titleComponent.left).isEqualTo(UUT_WIDTH- DEFAULT_LEFT_MARGIN_PX-titleBarWidth-DEFAULT_LEFT_MARGIN_PX )
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
@Test
|
|
197
|
-
fun `Title - should place title between the toolbars`() {
|
|
198
|
-
val leftBarWidth = 50
|
|
199
|
-
val rightBarWidth = 100
|
|
200
|
-
val titleBarWidth = 200
|
|
201
|
-
setup(leftBarWidth = leftBarWidth, rightBarWidth = rightBarWidth, titleBarWidth = titleBarWidth)
|
|
202
|
-
val titleSubTitleLayout = uut.getTitleComponent() as TitleSubTitleLayout
|
|
203
|
-
|
|
204
|
-
idleMainLooper()
|
|
205
|
-
assertThat(titleSubTitleLayout.left).isEqualTo(leftBarWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
206
|
-
assertThat(titleSubTitleLayout.right).isEqualTo(leftBarWidth + DEFAULT_LEFT_MARGIN_PX + titleBarWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
@Test
|
|
210
|
-
fun `Title - should place title between the toolbars at center`() {
|
|
211
|
-
val leftBarWidth = 50
|
|
212
|
-
val rightBarWidth = 100
|
|
213
|
-
val titleBarWidth = 200
|
|
214
|
-
setup(
|
|
215
|
-
leftBarWidth = leftBarWidth,
|
|
216
|
-
rightBarWidth = rightBarWidth,
|
|
217
|
-
titleBarWidth = titleBarWidth,
|
|
218
|
-
alignment = Alignment.Center
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
idleMainLooper()
|
|
222
|
-
assertThat(uut.getTitleComponent().left).isEqualTo((UUT_WIDTH / 2f - titleBarWidth / 2f).roundToInt())
|
|
223
|
-
assertThat(uut.getTitleComponent().right).isEqualTo((UUT_WIDTH / 2f + titleBarWidth / 2f).roundToInt())
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
@Test
|
|
227
|
-
fun `Title - center should not overlap with toolbars and be resized to fit between`() {
|
|
228
|
-
val leftBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
229
|
-
val rightBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
230
|
-
val titleBarWidth = (0.75 * UUT_WIDTH).roundToInt()
|
|
231
|
-
val spaceBetween = UUT_WIDTH - leftBarWidth - rightBarWidth
|
|
232
|
-
setup(
|
|
233
|
-
leftBarWidth = leftBarWidth,
|
|
234
|
-
rightBarWidth = rightBarWidth,
|
|
235
|
-
titleBarWidth = titleBarWidth,
|
|
236
|
-
alignment = Alignment.Center
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
idleMainLooper()
|
|
240
|
-
assertThat(uut.getTitleComponent().left).isEqualTo((UUT_WIDTH / 2f - spaceBetween / 2f).roundToInt())
|
|
241
|
-
assertThat(uut.getTitleComponent().right).isEqualTo((UUT_WIDTH / 2f + spaceBetween / 2f).roundToInt())
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
@Test
|
|
245
|
-
fun `Title - left should not overlap with toolbars and be resized to fit between`() {
|
|
246
|
-
val leftBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
247
|
-
val rightBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
248
|
-
val titleBarWidth = (0.75 * UUT_WIDTH).roundToInt()
|
|
249
|
-
setup(
|
|
250
|
-
leftBarWidth = leftBarWidth,
|
|
251
|
-
rightBarWidth = rightBarWidth,
|
|
252
|
-
titleBarWidth = titleBarWidth,
|
|
253
|
-
alignment = Alignment.Default
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
idleMainLooper()
|
|
257
|
-
assertThat(uut.getTitleComponent().left).isEqualTo(leftBarWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
258
|
-
assertThat(uut.getTitleComponent().right).isEqualTo(UUT_WIDTH - rightBarWidth - DEFAULT_LEFT_MARGIN_PX)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
@Test
|
|
262
|
-
fun `Component - center should not overlap with toolbars and be resized to fit between`() {
|
|
263
|
-
val leftBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
264
|
-
val rightBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
265
|
-
val componentWidth = (0.75 * UUT_WIDTH).roundToInt()
|
|
266
|
-
val spaceBetween = UUT_WIDTH - leftBarWidth - rightBarWidth
|
|
267
|
-
setup(
|
|
268
|
-
leftBarWidth = leftBarWidth,
|
|
269
|
-
rightBarWidth = rightBarWidth,
|
|
270
|
-
componentWidth = componentWidth,
|
|
271
|
-
alignment = Alignment.Center
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
idleMainLooper()
|
|
275
|
-
assertThat(uut.getTitleComponent().left).isEqualTo((UUT_WIDTH / 2f - spaceBetween / 2f).roundToInt())
|
|
276
|
-
assertThat(uut.getTitleComponent().right).isEqualTo((UUT_WIDTH / 2f + spaceBetween / 2f).roundToInt())
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
@Test
|
|
280
|
-
fun `Component - left should not overlap with toolbars and be resized to fit between`() {
|
|
281
|
-
val leftBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
282
|
-
val rightBarWidth = (UUT_WIDTH / 4f).roundToInt()
|
|
283
|
-
val componentWidth = (0.75 * UUT_WIDTH).roundToInt()
|
|
284
|
-
setup(
|
|
285
|
-
leftBarWidth = leftBarWidth,
|
|
286
|
-
rightBarWidth = rightBarWidth,
|
|
287
|
-
componentWidth = componentWidth,
|
|
288
|
-
alignment = Alignment.Default
|
|
289
|
-
)
|
|
290
|
-
|
|
291
|
-
idleMainLooper()
|
|
292
|
-
assertThat(uut.getTitleComponent().left).isEqualTo(leftBarWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
293
|
-
assertThat(uut.getTitleComponent().right).isEqualTo(UUT_WIDTH - rightBarWidth - DEFAULT_LEFT_MARGIN_PX)
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
@Test
|
|
297
|
-
fun `Component - should place title between the toolbars`() {
|
|
298
|
-
val leftBarWidth = 50
|
|
299
|
-
val rightBarWidth = 100
|
|
300
|
-
val componentWidth = 200
|
|
301
|
-
setup(leftBarWidth = leftBarWidth, rightBarWidth = rightBarWidth, titleBarWidth = 0, componentWidth = componentWidth)
|
|
302
|
-
val component = uut.getTitleComponent()
|
|
303
|
-
|
|
304
|
-
idleMainLooper()
|
|
305
|
-
assertThat(component.left).isEqualTo(leftBarWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
306
|
-
assertThat(component.right).isEqualTo(leftBarWidth + DEFAULT_LEFT_MARGIN_PX + componentWidth + DEFAULT_LEFT_MARGIN_PX)
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
@Test
|
|
310
|
-
fun `onLayout - should place title component between the toolbars at center`() {
|
|
311
|
-
val componentWidth = 200
|
|
312
|
-
setup(leftBarWidth = 50, rightBarWidth = 100, componentWidth = componentWidth,
|
|
313
|
-
alignment = Alignment.Center)
|
|
314
|
-
val component = uut.getTitleComponent()
|
|
315
|
-
|
|
316
|
-
idleMainLooper()
|
|
317
|
-
assertThat(component.left).isEqualTo((UUT_WIDTH / 2f - componentWidth / 2f).roundToInt())
|
|
318
|
-
assertThat(component.right).isEqualTo((UUT_WIDTH / 2f + componentWidth / 2f).roundToInt())
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
@Test
|
|
322
|
-
fun `onLayout - should measure and layout children when alignment changes`() {
|
|
323
|
-
val titleBarWidth = 200
|
|
324
|
-
setup(
|
|
325
|
-
titleBarWidth = titleBarWidth,
|
|
326
|
-
alignment = Alignment.Center
|
|
327
|
-
)
|
|
328
|
-
var component = uut.getTitleComponent()
|
|
329
|
-
idleMainLooper()
|
|
330
|
-
|
|
331
|
-
assertThat(component.left).isEqualTo((UUT_WIDTH / 2f - titleBarWidth / 2f).roundToInt())
|
|
332
|
-
assertThat(component.right).isEqualTo((UUT_WIDTH / 2f + titleBarWidth / 2f).roundToInt())
|
|
333
|
-
|
|
334
|
-
setup(
|
|
335
|
-
titleBarWidth = titleBarWidth,
|
|
336
|
-
alignment = Alignment.Fill
|
|
337
|
-
)
|
|
338
|
-
component = uut.getTitleComponent()
|
|
339
|
-
idleMainLooper()
|
|
340
|
-
assertThat(component.left).isEqualTo(DEFAULT_LEFT_MARGIN_PX)
|
|
341
|
-
assertThat(component.right).isEqualTo(titleBarWidth + 2 * DEFAULT_LEFT_MARGIN_PX)
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
@Test
|
|
345
|
-
fun `setComponent - should set dynamic width-height`() {
|
|
346
|
-
val component = View(activity).apply { id = 19 }
|
|
347
|
-
uut.setComponent(component)
|
|
348
|
-
idleMainLooper()
|
|
349
|
-
assertThat(component.layoutParams.width).isEqualTo(ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
350
|
-
assertThat(component.layoutParams.height).isEqualTo(ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
@Test
|
|
354
|
-
fun setComponent_shouldChangeDifferentComponents() {
|
|
355
|
-
setup(mockUUT = false)
|
|
356
|
-
val component = View(activity).apply { id = 19 }
|
|
357
|
-
val component2 = View(activity).apply { id = 29 }
|
|
358
|
-
uut.setComponent(component)
|
|
359
|
-
|
|
360
|
-
val titleComponent = uut.getTitleComponent()
|
|
361
|
-
assertThat(titleComponent).isEqualTo(component)
|
|
362
|
-
|
|
363
|
-
uut.setComponent(component2, Alignment.Fill)
|
|
364
|
-
assertThat(uut.findViewById<View?>(component.id)).isNull()
|
|
365
|
-
assertThat(uut.findViewById<View?>(component2.id)).isEqualTo(component2)
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
@Test
|
|
371
|
-
fun setComponent_shouldResetTextTitleWhenSettingComponent() {
|
|
372
|
-
setup(mockUUT = false)
|
|
373
|
-
uut.setTitle("Title")
|
|
374
|
-
assertThat(uut.getTitle()).isEqualTo("Title")
|
|
375
|
-
val component = View(activity)
|
|
376
|
-
uut.setComponent(component)
|
|
377
|
-
assertThat(uut.getTitle()).isNullOrEmpty()
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
@Test
|
|
382
|
-
fun setComponent_doesNothingIfComponentIsAlreadyAdded() {
|
|
383
|
-
setup(componentWidth = 100)
|
|
384
|
-
idleMainLooper()
|
|
385
|
-
assertThat(uut.getComponent()).isNotNull()
|
|
386
|
-
uut.setComponent(mockComponent)
|
|
387
|
-
idleMainLooper()
|
|
388
|
-
assertThat(uut.getComponent()?.id).isEqualTo(mockComponent.id)
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
@Test
|
|
392
|
-
fun setTitle_shouldChangeTheTitle() {
|
|
393
|
-
uut.setTitle("Title")
|
|
394
|
-
assertThat(uut.getTitle()).isEqualTo("Title")
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
@Test
|
|
398
|
-
fun setTitle_shouldResetTitleComponentWhenSettingTextTitle() {
|
|
399
|
-
setup(mockUUT = false)
|
|
400
|
-
val component = View(activity)
|
|
401
|
-
uut.setComponent(component)
|
|
402
|
-
assertThat(uut.getTitle()).isNullOrEmpty()
|
|
403
|
-
|
|
404
|
-
uut.setTitle("Title")
|
|
405
|
-
assertThat(uut.getTitle()).isEqualTo("Title")
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
@Test
|
|
410
|
-
fun setSubTitle_textShouldBeAlignedAtStartCenterVertical() {
|
|
411
|
-
uut.setSubtitle("Subtitle")
|
|
412
|
-
val passedView = uut.getTitleSubtitleBar()
|
|
413
|
-
assertThat(passedView.visibility).isEqualTo(View.VISIBLE)
|
|
414
|
-
assertThat(passedView.getSubTitleTxtView().text).isEqualTo("Subtitle")
|
|
415
|
-
assertThat((passedView.getSubTitleTxtView().layoutParams as LinearLayout.LayoutParams).gravity).isEqualTo(Gravity.START or Gravity.CENTER_VERTICAL)
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
@Test
|
|
419
|
-
fun setBackgroundColor_changesTitleBarBgColor() {
|
|
420
|
-
uut = Mockito.spy(uut)
|
|
421
|
-
uut.setBackgroundColor(NullThemeColour())
|
|
422
|
-
verify(uut, times(0)).setBackgroundColor(Color.GRAY)
|
|
423
|
-
uut.setBackgroundColor(ThemeColour(Colour(Color.GRAY)))
|
|
424
|
-
verify(uut, times(1)).setBackgroundColor(Color.GRAY)
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
@Test
|
|
428
|
-
fun setTitleFontSize_changesTitleFontSize() {
|
|
429
|
-
uut.setTitleFontSize(1f)
|
|
430
|
-
Assertions.assertThat(getTitleSubtitleView().getTitleTxtView().textSize).isEqualTo(1f)
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
@Test
|
|
434
|
-
fun setSubTitleFontSize_changesTitleFontSize() {
|
|
435
|
-
uut.setSubtitleFontSize(1f)
|
|
436
|
-
Assertions.assertThat(getTitleSubtitleView().getSubTitleTxtView().textSize).isEqualTo(1f)
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
@Test
|
|
440
|
-
fun setTitleColor_changesTitleColor() {
|
|
441
|
-
uut.setTitleColor(Color.YELLOW)
|
|
442
|
-
assertThat(getTitleSubtitleView().getTitleTxtView().currentTextColor).isEqualTo(Color.YELLOW)
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
@Test
|
|
446
|
-
fun setSubTitleColor_changesTitleColor() {
|
|
447
|
-
uut.setSubtitleColor(Color.YELLOW)
|
|
448
|
-
assertThat(getTitleSubtitleView().getSubTitleTxtView().currentTextColor).isEqualTo(Color.YELLOW)
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
@Test
|
|
454
|
-
fun getTitle_returnCurrentTextInTitleTextView() {
|
|
455
|
-
assertThat(uut.getTitle()).isEmpty()
|
|
456
|
-
uut.setTitle("TiTle")
|
|
457
|
-
assertThat(uut.getTitle()).isEqualTo("TiTle")
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
@Test
|
|
461
|
-
fun clearCurrentTitle_shouldCleatTextAndRemoveComponent() {
|
|
462
|
-
uut.setTitle("Title")
|
|
463
|
-
assertThat(uut.getTitle()).isEqualTo("Title")
|
|
464
|
-
uut.clearTitle()
|
|
465
|
-
assertThat(uut.getTitle()).isNullOrEmpty()
|
|
466
|
-
|
|
467
|
-
val component = View(activity)
|
|
468
|
-
uut.setComponent(component)
|
|
469
|
-
assertThat(uut.getTitleComponent()).isEqualTo(component)
|
|
470
|
-
|
|
471
|
-
uut.clearTitle()
|
|
472
|
-
assertThat(uut.getTitleComponent()).isNotEqualTo(component)
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
private fun getTitleSubtitleView() = (uut.getTitleComponent() as TitleSubTitleLayout)
|
|
477
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.views;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.view.ViewGroup;
|
|
5
|
-
|
|
6
|
-
import com.google.android.material.appbar.AppBarLayout;
|
|
7
|
-
import com.reactnativenavigation.BaseTest;
|
|
8
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
|
|
9
|
-
import com.reactnativenavigation.utils.UiUtils;
|
|
10
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController;
|
|
11
|
-
import com.reactnativenavigation.views.stack.StackLayout;
|
|
12
|
-
import com.reactnativenavigation.views.stack.topbar.TopBar;
|
|
13
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleAndButtonsContainer;
|
|
14
|
-
|
|
15
|
-
import org.junit.Test;
|
|
16
|
-
import org.mockito.Mockito;
|
|
17
|
-
import org.robolectric.annotation.Config;
|
|
18
|
-
|
|
19
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
20
|
-
|
|
21
|
-
@Config(qualifiers = "xxhdpi")
|
|
22
|
-
public class TopBarTest extends BaseTest {
|
|
23
|
-
|
|
24
|
-
private TopBar uut;
|
|
25
|
-
private Activity activity;
|
|
26
|
-
|
|
27
|
-
@Override
|
|
28
|
-
public void beforeEach() {
|
|
29
|
-
activity = newActivity();
|
|
30
|
-
StackLayout parent = new StackLayout(activity, new TopBarController(), null);
|
|
31
|
-
uut = new TopBar(activity);
|
|
32
|
-
parent.addView(uut);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@Test
|
|
36
|
-
public void title() {
|
|
37
|
-
assertThat(uut.getTitle()).isEmpty();
|
|
38
|
-
uut.setTitle("new title");
|
|
39
|
-
assertThat(uut.getTitle()).isEqualTo("new title");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Test
|
|
43
|
-
public void setElevation_ignoreValuesNotSetByNavigation() {
|
|
44
|
-
float initialElevation = uut.getElevation();
|
|
45
|
-
uut.setElevation(1f);
|
|
46
|
-
assertThat(uut.getElevation()).isEqualTo(initialElevation);
|
|
47
|
-
|
|
48
|
-
uut.setElevation(Double.valueOf(2));
|
|
49
|
-
assertThat(uut.getElevation()).isEqualTo(UiUtils.dpToPx(activity, 2));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@Test
|
|
53
|
-
public void setTitleHeight_changesTitleBarHeight() {
|
|
54
|
-
int width = 1080;
|
|
55
|
-
int height = 150;
|
|
56
|
-
uut.layout(0, 0, width, height);
|
|
57
|
-
uut.setTitleHeight(height / 2);
|
|
58
|
-
TitleAndButtonsContainer titleAndButtonsContainer = uut.getTitleAndButtonsContainer();
|
|
59
|
-
assertThat(titleAndButtonsContainer.getLayoutParams().height).isEqualTo(UiUtils.dpToPx(activity, height / 2));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@Test
|
|
63
|
-
public void setTopMargin_changesTitleBarTopMargin() {
|
|
64
|
-
int width = 1080;
|
|
65
|
-
int height = 150;
|
|
66
|
-
uut.layout(0, 0, width, height);
|
|
67
|
-
int topMargin = 10;
|
|
68
|
-
uut.setTitleTopMargin(topMargin);
|
|
69
|
-
TitleAndButtonsContainer titleAndButtonsContainer = uut.getTitleAndButtonsContainer();
|
|
70
|
-
assertThat(((ViewGroup.MarginLayoutParams) titleAndButtonsContainer.getLayoutParams()).topMargin).isEqualTo(UiUtils.dpToPx(activity, topMargin));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@Test
|
|
74
|
-
public void disableCollapse_scrollIsDisabled() {
|
|
75
|
-
AppBarLayout.LayoutParams lp = (AppBarLayout.LayoutParams) uut.getChildAt(0).getLayoutParams();
|
|
76
|
-
uut.enableCollapse(Mockito.mock(ScrollEventListener.class));
|
|
77
|
-
assertThat(lp.getScrollFlags()).isEqualTo(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL);
|
|
78
|
-
|
|
79
|
-
uut.disableCollapse();
|
|
80
|
-
assertThat(lp.getScrollFlags()).isZero();
|
|
81
|
-
}
|
|
82
|
-
}
|