react-native-navigation 7.24.0 → 7.24.3-snapshot.492

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/lib/Mock/Components/ComponentScreen.tsx +1 -1
  2. package/lib/Mock/Components/NavigationButton.tsx +1 -1
  3. package/lib/Mock/Components/TopBar.tsx +6 -2
  4. package/lib/android/app/build.gradle +12 -9
  5. package/lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java +13 -9
  6. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/SystemUiUtils.kt +3 -2
  7. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +1 -0
  8. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +2 -0
  9. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenter.java +4 -6
  10. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java +2 -4
  11. package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabs.java +6 -0
  12. package/lib/dist/Mock/Components/ComponentScreen.js +2 -2
  13. package/lib/dist/Mock/Components/NavigationButton.d.ts +1 -1
  14. package/lib/dist/Mock/Components/NavigationButton.js +3 -3
  15. package/lib/dist/Mock/Components/TopBar.d.ts +1 -2
  16. package/lib/dist/Mock/Components/TopBar.js +3 -3
  17. package/lib/ios/RNNComponentRootView.m +0 -14
  18. package/package.json +1 -1
  19. package/.buildkite/pipeline.yml +0 -59
  20. package/lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java +0 -178
  21. package/lib/android/app/src/test/java/com/reactnativenavigation/EnvironmentTest.java +0 -43
  22. package/lib/android/app/src/test/java/com/reactnativenavigation/TestActivity.java +0 -23
  23. package/lib/android/app/src/test/java/com/reactnativenavigation/TestApplication.java +0 -35
  24. package/lib/android/app/src/test/java/com/reactnativenavigation/TestUtils.java +0 -62
  25. package/lib/android/app/src/test/java/com/reactnativenavigation/fakes/IconResolverFake.kt +0 -8
  26. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/BackDrawable.java +0 -30
  27. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/ImageLoaderMock.kt +0 -49
  28. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/Mocks.kt +0 -18
  29. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleComponentViewController.java +0 -15
  30. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleOverlay.java +0 -54
  31. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleViewController.java +0 -113
  32. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java +0 -79
  33. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentViewCreator.java +0 -18
  34. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestReactView.java +0 -71
  35. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarButtonCreatorMock.java +0 -34
  36. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarReactViewCreatorMock.java +0 -20
  37. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TopBarBackgroundViewCreatorMock.java +0 -20
  38. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.kt +0 -21
  39. package/lib/android/app/src/test/java/com/reactnativenavigation/options/LayoutNodeParserTest.java +0 -51
  40. package/lib/android/app/src/test/java/com/reactnativenavigation/options/OptionsTest.java +0 -315
  41. package/lib/android/app/src/test/java/com/reactnativenavigation/options/OrientationOptionsTest.java +0 -81
  42. package/lib/android/app/src/test/java/com/reactnativenavigation/options/TopBarButtonsTest.kt +0 -95
  43. package/lib/android/app/src/test/java/com/reactnativenavigation/options/TransitionAnimationOptionsTest.kt +0 -122
  44. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/BoolParserTest.java +0 -28
  45. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/ColorParseTest.java +0 -50
  46. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/JSONParserTest.java +0 -64
  47. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/PresenterTest.java +0 -56
  48. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/RenderCheckerTest.java +0 -59
  49. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/SideMenuPresenterTest.java +0 -35
  50. package/lib/android/app/src/test/java/com/reactnativenavigation/react/NavigationModuleTest.java +0 -102
  51. package/lib/android/app/src/test/java/com/reactnativenavigation/react/ReloadListenerTest.java +0 -24
  52. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/AnimationHelper.kt +0 -33
  53. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonPresenterTest.java +0 -241
  54. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonSpanTest.java +0 -57
  55. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/CompatUtilsTest.java +0 -17
  56. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/LayoutFactoryTest.java +0 -78
  57. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/MotionEventTest.kt +0 -47
  58. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/NativeCommandListenerTest.java +0 -60
  59. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/OptionHelper.java +0 -16
  60. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java +0 -26
  61. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/StringUtilsTest.java +0 -19
  62. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleAndButtonsMeasurerTest.kt +0 -357
  63. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleBarHelper.java +0 -54
  64. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java +0 -29
  65. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java +0 -22
  66. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ViewHelper.java +0 -9
  67. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java +0 -149
  68. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenterTest.java +0 -206
  69. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsAttacherTest.java +0 -62
  70. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +0 -572
  71. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenterTest.kt +0 -173
  72. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AfterInitialTabTest.java +0 -38
  73. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AttachModeTest.java +0 -86
  74. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/OnSwitchToTabTest.java +0 -31
  75. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/TogetherTest.java +0 -20
  76. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/button/NavigationIconResolverTest.java +0 -78
  77. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllerTest.java +0 -80
  78. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistryTest.java +0 -56
  79. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +0 -191
  80. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/ExternalComponentViewControllerTest.java +0 -97
  81. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/FragmentCreatorMock.java +0 -34
  82. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/SomeFragment.java +0 -8
  83. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/fakes/FakeParentController.kt +0 -33
  84. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorMock.java +0 -40
  85. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorTest.kt +0 -213
  86. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenterTest.java +0 -319
  87. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +0 -368
  88. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java +0 -898
  89. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/RootPresenterTest.kt +0 -254
  90. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManagerTest.java +0 -108
  91. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/parent/ParentControllerTest.java +0 -299
  92. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java +0 -446
  93. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/BackButtonHelperTest.java +0 -77
  94. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/FloatingActionButtonTest.java +0 -154
  95. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/IdStackTest.java +0 -114
  96. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackAnimatorTest.kt +0 -241
  97. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.kt +0 -1165
  98. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenterTest.kt +0 -1081
  99. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarButtonControllerTest.java +0 -61
  100. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarReactViewControllerTest.java +0 -43
  101. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarButtonControllerTest.java +0 -120
  102. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarControllerTest.kt +0 -432
  103. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewControllerTest.java +0 -247
  104. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerTest.java +0 -337
  105. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegateTest.java +0 -68
  106. package/lib/android/app/src/test/java/com/reactnativenavigation/views/OverlayTouchDelegateTest.java +0 -60
  107. package/lib/android/app/src/test/java/com/reactnativenavigation/views/TitleAndButtonsContainerTest.kt +0 -477
  108. package/lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java +0 -82
  109. package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/BaseViewAnimatorTest.kt +0 -109
  110. package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/DefaultViewAnimatorCreatorFake.kt +0 -36
  111. package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainerTest.kt +0 -101
  112. package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsTest.kt +0 -40
  113. package/lib/android/app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +0 -1
@@ -1,57 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import android.app.Activity;
4
- import android.graphics.Color;
5
- import android.graphics.Paint;
6
-
7
- import com.reactnativenavigation.BaseTest;
8
- import com.reactnativenavigation.mocks.TypefaceLoaderMock;
9
- import com.reactnativenavigation.options.ButtonOptions;
10
- import com.reactnativenavigation.options.params.Colour;
11
- import com.reactnativenavigation.options.params.Fraction;
12
- import com.reactnativenavigation.options.params.ThemeColour;
13
- import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonSpan;
14
-
15
- import org.jetbrains.annotations.NotNull;
16
- import org.junit.Test;
17
- import org.robolectric.annotation.Config;
18
-
19
- import static org.assertj.core.api.Java6Assertions.assertThat;
20
-
21
- @Config(qualifiers = "xhdpi")
22
- public class ButtonSpanTest extends BaseTest {
23
- private ButtonSpan uut;
24
- private ButtonOptions button;
25
- private Activity activity;
26
-
27
- @Override
28
- public void beforeEach() {
29
- button = createButton();
30
- activity = newActivity();
31
- uut = new ButtonSpan(activity, button, new TypefaceLoaderMock());
32
- }
33
-
34
- @Test
35
- public void apply_colorIsNotHandled() {
36
- Paint paint = new Paint();
37
- uut.apply(paint);
38
-
39
- assertThat(paint.getColor()).isNotEqualTo(button.color.get());
40
- }
41
-
42
- @Test
43
- public void apply_fontSizeIsAppliedInDp() {
44
- button.fontSize = new Fraction(14);
45
- Paint paint = new Paint();
46
- uut.apply(paint);
47
-
48
- assertThat(paint.getTextSize()).isEqualTo(UiUtils.dpToPx(activity, 14));
49
- }
50
-
51
- @NotNull
52
- private ButtonOptions createButton() {
53
- ButtonOptions button = new ButtonOptions();
54
- button.color = new ThemeColour(new Colour(Color.RED));
55
- return button;
56
- }
57
- }
@@ -1,17 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import com.reactnativenavigation.*;
4
-
5
- import org.junit.*;
6
-
7
- import static org.assertj.core.api.Java6Assertions.*;
8
-
9
- public class CompatUtilsTest extends BaseTest {
10
-
11
- @Test
12
- public void generateViewId() throws Exception {
13
- assertThat(CompatUtils.generateViewId())
14
- .isPositive()
15
- .isNotEqualTo(CompatUtils.generateViewId());
16
- }
17
- }
@@ -1,78 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import com.facebook.react.ReactInstanceManager;
4
- import com.reactnativenavigation.BaseTest;
5
- import com.reactnativenavigation.options.LayoutFactory;
6
- import com.reactnativenavigation.options.LayoutNode;
7
- import com.reactnativenavigation.react.events.EventEmitter;
8
- import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
9
-
10
- import org.json.JSONException;
11
- import org.json.JSONObject;
12
- import org.junit.Test;
13
- import org.mockito.Mockito;
14
-
15
- import java.util.HashMap;
16
-
17
- import static org.assertj.core.api.Java6Assertions.assertThat;
18
- import static org.assertj.core.api.Java6Assertions.fail;
19
- import static org.mockito.Mockito.mock;
20
- import static org.mockito.Mockito.when;
21
-
22
- public class LayoutFactoryTest extends BaseTest {
23
- private LayoutFactory uut;
24
- private ReactInstanceManager mockReactInstanceManager;
25
-
26
- @Override
27
- public void beforeEach() {
28
- super.beforeEach();
29
- mockReactInstanceManager = mock(ReactInstanceManager.class);
30
- uut = new LayoutFactory(mockReactInstanceManager);
31
- uut.init(
32
- newActivity(),
33
- Mockito.mock(EventEmitter.class),
34
- new ChildControllersRegistry(),
35
- new HashMap<>()
36
- );
37
- }
38
-
39
- @Test
40
- public void sanity() throws JSONException {
41
- assertThat(uut.create(component())).isNotNull();
42
- }
43
-
44
- @Test
45
- public void shouldParseOptionsWhenReactContextIsNull() {
46
- when(mockReactInstanceManager.getCurrentReactContext()).thenReturn(null);
47
- try {
48
- uut.create(component());
49
- } catch (Exception e) {
50
- fail("Create should not fail! when react instance has null context");
51
- }
52
- }
53
-
54
- @Test
55
- public void defaultOptionsAreNotNull() {
56
- assertThat(uut.getDefaultOptions()).isNotNull();
57
- boolean exceptionThrown = false;
58
- try {
59
- //noinspection ConstantConditions
60
- uut.setDefaultOptions(null);
61
- } catch (AssertionError exception) {
62
- exceptionThrown = true;
63
- }
64
- assertThat(exceptionThrown).isTrue();
65
- }
66
-
67
- private LayoutNode component() throws JSONException {
68
- final JSONObject component = new JSONObject();
69
- final JSONObject layout = new JSONObject();
70
- final JSONObject backgroundColor = new JSONObject();
71
- backgroundColor.put("dark",0);
72
- backgroundColor.put("light",1);
73
- layout.put("backgroundColor",backgroundColor );
74
- component.put("name", "com.component");
75
- component.put("options",new JSONObject().put("layout", layout));
76
- return new LayoutNode("Component1", LayoutNode.Type.Component, component, null);
77
- }
78
- }
@@ -1,47 +0,0 @@
1
- package com.reactnativenavigation.utils
2
-
3
- import android.app.Activity
4
- import android.view.MotionEvent
5
- import android.view.View
6
- import android.widget.FrameLayout
7
- import org.mockito.kotlin.mock
8
- import com.reactnativenavigation.BaseTest
9
- import org.assertj.core.api.Java6Assertions.assertThat
10
- import org.junit.Test
11
-
12
- class MotionEventTest : BaseTest() {
13
- private lateinit var uut: MotionEvent
14
- private lateinit var activity: Activity
15
- private lateinit var parent: FrameLayout
16
- private val x = 173f
17
- private val y = 249f
18
-
19
- override fun beforeEach() {
20
- uut = MotionEvent.obtain(0L, 0, 0, x, y, 0)
21
- activity = newActivity()
22
- parent = FrameLayout(activity)
23
- activity.setContentView(parent)
24
- }
25
-
26
- @Test
27
- fun coordinatesInsideView() {
28
- val v: View = mock()
29
- assertThat(uut.coordinatesInsideView(v)).isFalse()
30
- }
31
-
32
- @Test
33
- fun coordinatesInsideView_inside() {
34
- val view = View(activity)
35
- parent.addView(view, 200, 300)
36
- idleMainLooper()
37
- assertThat(uut.coordinatesInsideView(view)).isTrue()
38
- }
39
-
40
- @Test
41
- fun coordinatesInsideView_outside() {
42
- val view = View(activity)
43
- parent.addView(view, 200, 300)
44
- view.top = (y + 1).toInt()
45
- assertThat(uut.coordinatesInsideView(view)).isFalse()
46
- }
47
- }
@@ -1,60 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import com.facebook.react.bridge.Promise;
4
- import com.reactnativenavigation.BaseTest;
5
- import com.reactnativenavigation.react.NativeCommandListener;
6
- import com.reactnativenavigation.react.events.EventEmitter;
7
-
8
- import org.junit.Test;
9
- import org.mockito.ArgumentCaptor;
10
- import org.mockito.Mockito;
11
-
12
- import static org.assertj.core.api.Java6Assertions.assertThat;
13
- import static org.mockito.Mockito.times;
14
- import static org.mockito.Mockito.verify;
15
- import static org.mockito.Mockito.when;
16
-
17
- public class NativeCommandListenerTest extends BaseTest {
18
- private static final String COMMAND_NAME = "someCommandName";
19
- private static final String COMMAND_ID = "someCommand";
20
- private static final String CHILD_ID = "someChild";
21
- private static final long NOW = 1535374334;
22
-
23
- private EventEmitter eventEmitter;
24
- private Promise promise;
25
-
26
- private NativeCommandListener uut;
27
-
28
- @Override
29
- public void beforeEach() {
30
- promise = Mockito.mock(Promise.class);
31
- eventEmitter = Mockito.mock(EventEmitter.class);
32
- uut = new NativeCommandListener(COMMAND_NAME, COMMAND_ID, promise, eventEmitter, mockNow());
33
- }
34
-
35
- @Test
36
- public void onSuccess() {
37
- uut.onSuccess(CHILD_ID);
38
- verify(promise, times(1)).resolve(CHILD_ID);
39
- }
40
-
41
- @Test
42
- public void onSuccess_emitsNavigationEvent() {
43
- uut.onSuccess(CHILD_ID);
44
- verify(eventEmitter, times(1)).emitCommandCompleted(COMMAND_NAME, COMMAND_ID, NOW);
45
- }
46
-
47
- @Test
48
- public void onError() {
49
- uut.onError("something which is wrong");
50
- ArgumentCaptor<Throwable> captor = ArgumentCaptor.forClass(Throwable.class);
51
- verify(promise, times(1)).reject(captor.capture());
52
- assertThat(captor.getValue().getMessage().equals("something which is wrong"));
53
- }
54
-
55
- private Now mockNow() {
56
- Now now = Mockito.mock(Now.class);
57
- when(now.now()).then(i -> NOW);
58
- return now;
59
- }
60
- }
@@ -1,16 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import com.reactnativenavigation.options.Options;
4
- import com.reactnativenavigation.options.params.Text;
5
-
6
- import java.util.ArrayList;
7
-
8
- public class OptionHelper {
9
- public static Options createBottomTabOptions() {
10
- Options options = new Options();
11
- options.topBar.buttons.left = new ArrayList<>();
12
- options.bottomTabOptions.text = new Text("Tab");
13
- options.bottomTabOptions.icon = new Text("http://127.0.0.1/icon.png");
14
- return options;
15
- }
16
- }
@@ -1,26 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import com.reactnativenavigation.*;
4
-
5
- import org.junit.*;
6
-
7
- import static org.assertj.core.api.Java6Assertions.*;
8
-
9
- public class ReflectionUtilsTest extends BaseTest {
10
-
11
- static class Foo {
12
- private String bar = "old value";
13
- }
14
-
15
- @Test
16
- public void setField() throws Exception {
17
- Foo target = new Foo();
18
- ReflectionUtils.setField(target, "bar", "a new value");
19
- assertThat(target.bar).isEqualTo("a new value");
20
- }
21
-
22
- @Test
23
- public void getDeclaredField() throws Exception {
24
- assertThat(ReflectionUtils.getDeclaredField(new Foo(), "bar")).isEqualTo("old value");
25
- }
26
- }
@@ -1,19 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import com.reactnativenavigation.*;
4
-
5
- import org.junit.*;
6
-
7
- import static org.assertj.core.api.Java6Assertions.*;
8
-
9
- public class StringUtilsTest extends BaseTest {
10
- @Test
11
- public void isEqual() throws Exception {
12
- assertThat(StringUtils.isEqual(null, "a")).isFalse();
13
- assertThat(StringUtils.isEqual("a", null)).isFalse();
14
- assertThat(StringUtils.isEqual("a", "b")).isFalse();
15
- assertThat(StringUtils.isEqual("a", "A")).isFalse();
16
- assertThat(StringUtils.isEqual("a", "a")).isTrue();
17
- assertThat(StringUtils.isEqual("", "")).isTrue();
18
- }
19
- }
@@ -1,357 +0,0 @@
1
- package com.reactnativenavigation.utils
2
-
3
- import com.reactnativenavigation.BaseTest
4
- import com.reactnativenavigation.views.stack.topbar.titlebar.DEFAULT_LEFT_MARGIN_PX
5
- import com.reactnativenavigation.views.stack.topbar.titlebar.resolveHorizontalTitleBoundsLimit
6
- import com.reactnativenavigation.views.stack.topbar.titlebar.resolveLeftButtonsBounds
7
- import com.reactnativenavigation.views.stack.topbar.titlebar.resolveRightButtonsBounds
8
- import org.junit.Test
9
- import kotlin.test.assertEquals
10
-
11
- class TitleAndButtonsMeasurerTest : BaseTest() {
12
- private val parentWidth = 1080
13
-
14
- @Test
15
- fun `left buttons should be at parent start`() {
16
- val barWidth = 200
17
- val isRTL = false
18
- val (left, right) = resolveLeftButtonsBounds(parentWidth, barWidth, isRTL)
19
-
20
- assertEquals(0, left)
21
- assertEquals(barWidth, right)
22
- }
23
-
24
- @Test
25
- fun `left buttons should not exceed parent width`() {
26
- val barWidth = parentWidth + 1
27
- val isRTL = false
28
- val (left, right) = resolveLeftButtonsBounds(parentWidth, barWidth, isRTL)
29
-
30
- assertEquals(0, left)
31
- assertEquals(parentWidth, right)
32
- }
33
-
34
- @Test
35
- fun `RTL - left buttons should be at parent end`() {
36
- val barWidth = 200
37
- val isRTL = true
38
- val (left, right) = resolveLeftButtonsBounds(parentWidth, barWidth, isRTL)
39
-
40
- assertEquals(parentWidth - barWidth, left)
41
- assertEquals(parentWidth, right)
42
- }
43
-
44
- @Test
45
- fun `RTL - left buttons should not exceed parent left`() {
46
- val barWidth = parentWidth + 1
47
- val isRTL = true
48
- val (left, right) = resolveLeftButtonsBounds(parentWidth, barWidth, isRTL)
49
-
50
- assertEquals(0, left)
51
- assertEquals(parentWidth, right)
52
- }
53
-
54
- @Test
55
- fun `right buttons should be at parent end`() {
56
- val barWidth = 200
57
- val isRTL = false
58
- val (left, right) = resolveRightButtonsBounds(parentWidth, barWidth, isRTL)
59
-
60
- assertEquals(parentWidth - barWidth, left)
61
- assertEquals(parentWidth, right)
62
- }
63
-
64
- @Test
65
- fun `right buttons should not exceed parent start`() {
66
- val barWidth = parentWidth + 1
67
- val isRTL = false
68
- val (left, right) = resolveRightButtonsBounds(parentWidth, barWidth, isRTL)
69
-
70
- assertEquals(0, left)
71
- assertEquals(parentWidth, right)
72
- }
73
-
74
- @Test
75
- fun `RTL - right buttons should be at parent start`() {
76
- val barWidth = 200
77
- val isRTL = true
78
- val (left, right) = resolveRightButtonsBounds(parentWidth, barWidth, isRTL)
79
-
80
- assertEquals(0, left)
81
- assertEquals(barWidth, right)
82
- }
83
-
84
- @Test
85
- fun `RTL - right buttons should not exceed parent end`() {
86
- val barWidth = parentWidth + 1
87
- val isRTL = true
88
- val (left, right) = resolveRightButtonsBounds(parentWidth, barWidth, isRTL)
89
-
90
- assertEquals(0, left)
91
- assertEquals(parentWidth, right)
92
- }
93
-
94
- @Test
95
- fun `No Buttons - Aligned start - Title should be at default left margin bar width and right margin`() {
96
- val barWidth = 200
97
- val leftButtons = 0
98
- val rightButtons = 0
99
- val isRTL = false
100
- val center = false
101
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
102
-
103
- assertEquals(DEFAULT_LEFT_MARGIN_PX, left)
104
- assertEquals(DEFAULT_LEFT_MARGIN_PX + barWidth + DEFAULT_LEFT_MARGIN_PX, right)
105
- }
106
-
107
- @Test
108
- fun `RTL - No Buttons - Aligned start - Title should be at the end with default margins`() {
109
- val barWidth = 200
110
- val leftButtons = 0
111
- val rightButtons = 0
112
- val isRTL = true
113
- val center = false
114
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
115
-
116
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX - barWidth - DEFAULT_LEFT_MARGIN_PX, left)
117
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX, right)
118
- }
119
-
120
- @Test
121
- fun `RTL - No Buttons - Aligned start - Title should not exceed boundaries`() {
122
- val barWidth = parentWidth + 1
123
- val leftButtons = 0
124
- val rightButtons = 0
125
- val isRTL = true
126
- val center = false
127
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
128
-
129
- assertEquals(DEFAULT_LEFT_MARGIN_PX, left)
130
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX, right)
131
- }
132
-
133
- @Test
134
- fun `No Buttons - Aligned start - Title should not exceed parent boundaries`() {
135
- val barWidth = parentWidth + 1
136
- val leftButtons = 0
137
- val rightButtons = 0
138
- val isRTL = false
139
- val center = false
140
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
141
-
142
- assertEquals(DEFAULT_LEFT_MARGIN_PX, left)
143
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX, right)
144
- }
145
-
146
-
147
- @Test
148
- fun `No Buttons - Aligned center - Title should not exceed parent boundaries`() {
149
- val barWidth = parentWidth + 1
150
- val leftButtons = 0
151
- val rightButtons = 0
152
- val isRTL = false
153
- val center = true
154
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
155
-
156
- assertEquals(0, left)
157
- assertEquals(parentWidth, right)
158
- }
159
-
160
- @Test
161
- fun `No Buttons - Aligned center - Title should have no margin and in center`() {
162
- val barWidth = 200
163
- val leftButtons = 0
164
- val rightButtons = 0
165
- val isRTL = false
166
- val center = true
167
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
168
-
169
- assertEquals(parentWidth / 2 - barWidth / 2, left)
170
- assertEquals(parentWidth / 2 + barWidth / 2, right)
171
- }
172
-
173
- @Test
174
- fun `RTL - No Buttons - Aligned center - Title should have no effect`() {
175
- val barWidth = 200
176
- val leftButtons = 0
177
- val rightButtons = 0
178
- val isRTL = true
179
- val center = true
180
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
181
-
182
- assertEquals(parentWidth / 2 - barWidth / 2, left)
183
- assertEquals(parentWidth / 2 + barWidth / 2, right)
184
- }
185
-
186
- @Test
187
- fun `Left Buttons - Aligned start - Title should be after left buttons with default margins`() {
188
- val barWidth = 200
189
- val leftButtons = 100
190
- val rightButtons = 0
191
- val isRTL = false
192
- val center = false
193
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
194
-
195
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX, left)
196
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX + barWidth + DEFAULT_LEFT_MARGIN_PX, right)
197
- }
198
-
199
- @Test
200
- fun `Left Buttons - Aligned start - Title should not exceed boundaries`() {
201
- val barWidth = parentWidth + 1
202
- val leftButtons = 100
203
- val rightButtons = 0
204
- val isRTL = false
205
- val center = false
206
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
207
-
208
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX, left)
209
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX, right)
210
- }
211
-
212
- @Test
213
- fun `RTL - Left Buttons - Aligned start - Title should be after left (right) buttons with default margins`() {
214
- val barWidth = 200
215
- val leftButtons = 100
216
- val rightButtons = 0
217
- val isRTL = true
218
- val center = false
219
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
220
-
221
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX - leftButtons - barWidth - DEFAULT_LEFT_MARGIN_PX, left)
222
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX - leftButtons, right)
223
- }
224
-
225
- @Test
226
- fun `RTL - Left Buttons - Aligned start - Title should not exceed boundaries`() {
227
- val barWidth = parentWidth + 1
228
- val leftButtons = 100
229
- val rightButtons = 0
230
- val isRTL = true
231
- val center = false
232
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
233
-
234
- assertEquals(DEFAULT_LEFT_MARGIN_PX, left)
235
- assertEquals(parentWidth - leftButtons - DEFAULT_LEFT_MARGIN_PX, right)
236
- }
237
-
238
-
239
- @Test
240
- fun `Left Buttons - Aligned center - Title should be at center`() {
241
- val barWidth = 200
242
- val leftButtons = 100
243
- val rightButtons = 0
244
- val isRTL = false
245
- val center = true
246
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
247
-
248
- assertEquals(parentWidth / 2 - barWidth / 2, left)
249
- assertEquals(parentWidth / 2 + barWidth / 2, right)
250
- }
251
-
252
- @Test
253
- fun `Left Buttons - Aligned center - Title should not exceed boundaries`() {
254
- val parentWidth = 1000
255
- val barWidth = 500
256
- val leftButtons = 300
257
- val rightButtons = 0
258
- val isRTL = false
259
- val center = true
260
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
261
- val expectedOverlap = leftButtons - (parentWidth / 2 - barWidth / 2)
262
- assertEquals(parentWidth / 2 - barWidth / 2 + expectedOverlap, left)
263
- assertEquals(parentWidth / 2 + barWidth / 2 - expectedOverlap, right)
264
- }
265
-
266
- @Test
267
- fun `RTL - Left Buttons - Aligned center - Title should not exceed boundaries`() {
268
- val parentWidth = 1000
269
- val barWidth = 500
270
- val leftButtons = 300
271
- val rightButtons = 0
272
- val isRTL = true
273
- val center = true
274
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
275
- val expectedOverlap = leftButtons - (parentWidth / 2 - barWidth / 2)
276
- assertEquals(parentWidth / 2 - barWidth / 2 + expectedOverlap, left)
277
- assertEquals(parentWidth / 2 + barWidth / 2 - expectedOverlap, right)
278
- }
279
-
280
-
281
- @Test
282
- fun `Left + Right Buttons - Aligned center - Title should not exceed boundaries`() {
283
- val parentWidth = 1000
284
- val barWidth = 500
285
- val leftButtons = 300
286
- val rightButtons = 350
287
- val isRTL = false
288
- val center = true
289
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
290
- assertEquals(leftButtons, left)
291
- assertEquals(parentWidth - rightButtons, right)
292
- }
293
-
294
- @Test
295
- fun `RTL - Left + Right Buttons - Aligned center - Title should not exceed boundaries`() {
296
- val parentWidth = 1000
297
- val barWidth = 500
298
- val leftButtons = 300
299
- val rightButtons = 350
300
- val isRTL = true
301
- val center = true
302
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
303
- assertEquals(rightButtons, left)
304
- assertEquals(parentWidth - leftButtons, right)
305
- }
306
-
307
- @Test
308
- fun `Left + Right Buttons - Aligned start - Title should not exceed boundaries`() {
309
- val parentWidth = 1000
310
- val barWidth = 500
311
- val leftButtons = 300
312
- val rightButtons = 350
313
- val isRTL = false
314
- val center = false
315
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
316
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX, left)
317
- assertEquals(parentWidth - rightButtons - DEFAULT_LEFT_MARGIN_PX, right)
318
- }
319
-
320
- @Test
321
- fun `Left + Right Buttons - Aligned start - Title should'nt take amount of needed width only between buttons only`() {
322
- val barWidth = 100
323
- val leftButtons = 300
324
- val rightButtons = 350
325
- val isRTL = false
326
- val center = false
327
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
328
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX, left)
329
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX + barWidth + DEFAULT_LEFT_MARGIN_PX, right)
330
- }
331
-
332
- @Test
333
- fun `RTL - Left + Right Buttons - Aligned start - Title should not exceed boundaries`() {
334
- val parentWidth = 1000
335
- val barWidth = 500
336
- val leftButtons = 300
337
- val rightButtons = 350
338
- val isRTL = true
339
- val center = false
340
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
341
- assertEquals(rightButtons + DEFAULT_LEFT_MARGIN_PX, left)
342
- assertEquals(parentWidth - leftButtons - DEFAULT_LEFT_MARGIN_PX, right)
343
- }
344
-
345
- @Test
346
- fun `RTL - Left + Right Buttons - Aligned start - Title should take amount of needed width only`() {
347
- val parentWidth = 1000
348
- val barWidth = 100
349
- val leftButtons = 300
350
- val rightButtons = 100
351
- val isRTL = true
352
- val center = false
353
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
354
- assertEquals(parentWidth - leftButtons - DEFAULT_LEFT_MARGIN_PX - barWidth - DEFAULT_LEFT_MARGIN_PX, left)
355
- assertEquals(parentWidth - leftButtons - DEFAULT_LEFT_MARGIN_PX, right)
356
- }
357
- }