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
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.stack;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.view.MenuItem;
|
|
5
|
-
|
|
6
|
-
import com.reactnativenavigation.BaseTest;
|
|
7
|
-
import com.reactnativenavigation.mocks.ImageLoaderMock;
|
|
8
|
-
import com.reactnativenavigation.mocks.TitleBarButtonCreatorMock;
|
|
9
|
-
import com.reactnativenavigation.options.ButtonOptions;
|
|
10
|
-
import com.reactnativenavigation.options.params.Text;
|
|
11
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController;
|
|
12
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter;
|
|
13
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver;
|
|
14
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar;
|
|
15
|
-
|
|
16
|
-
import org.junit.Test;
|
|
17
|
-
import org.mockito.Mockito;
|
|
18
|
-
|
|
19
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
20
|
-
|
|
21
|
-
public class TitleBarButtonControllerTest extends BaseTest {
|
|
22
|
-
private ButtonController uut;
|
|
23
|
-
private ButtonBar titleBar;
|
|
24
|
-
|
|
25
|
-
@Override
|
|
26
|
-
public void beforeEach() {
|
|
27
|
-
Activity activity = newActivity();
|
|
28
|
-
titleBar = new ButtonBar(activity);
|
|
29
|
-
|
|
30
|
-
ButtonOptions button = createComponentButton();
|
|
31
|
-
uut = new ButtonController(
|
|
32
|
-
activity,
|
|
33
|
-
new ButtonPresenter(activity, button, new IconResolver(activity, ImageLoaderMock.mock())),
|
|
34
|
-
button,
|
|
35
|
-
new TitleBarButtonCreatorMock(),
|
|
36
|
-
Mockito.mock(ButtonController.OnClickListener.class)
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Test
|
|
41
|
-
public void addToMenu_componentButtonIsNotRecreatedIfAlreadyAddedWithSameOrder() {
|
|
42
|
-
uut.addToMenu(titleBar, 0);
|
|
43
|
-
MenuItem first = titleBar.getButton(0);
|
|
44
|
-
|
|
45
|
-
uut.addToMenu(titleBar, 0);
|
|
46
|
-
MenuItem second = titleBar.getButton(0);
|
|
47
|
-
assertThat(first).isEqualTo(second);
|
|
48
|
-
|
|
49
|
-
uut.addToMenu(titleBar, 1);
|
|
50
|
-
MenuItem third = titleBar.getButton(0);
|
|
51
|
-
assertThat(third).isNotEqualTo(second);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private ButtonOptions createComponentButton() {
|
|
55
|
-
ButtonOptions componentButton = new ButtonOptions();
|
|
56
|
-
componentButton.id = "customBtn";
|
|
57
|
-
componentButton.component.name = new Text("com.rnn.customBtn");
|
|
58
|
-
componentButton.component.componentId = new Text("component4");
|
|
59
|
-
return componentButton;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.stack;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
|
|
5
|
-
import com.reactnativenavigation.BaseTest;
|
|
6
|
-
import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
|
|
7
|
-
import com.reactnativenavigation.options.ComponentOptions;
|
|
8
|
-
import com.reactnativenavigation.options.params.Text;
|
|
9
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.title.TitleBarReactViewController;
|
|
10
|
-
|
|
11
|
-
import org.junit.Test;
|
|
12
|
-
|
|
13
|
-
import static org.mockito.Mockito.spy;
|
|
14
|
-
import static org.mockito.Mockito.verify;
|
|
15
|
-
|
|
16
|
-
public class TitleBarReactViewControllerTest extends BaseTest {
|
|
17
|
-
|
|
18
|
-
private TitleBarReactViewController uut;
|
|
19
|
-
private TitleBarReactViewCreatorMock viewCreator;
|
|
20
|
-
private Activity activity;
|
|
21
|
-
private ComponentOptions component;
|
|
22
|
-
|
|
23
|
-
@Override
|
|
24
|
-
public void beforeEach() {
|
|
25
|
-
viewCreator = spy(new TitleBarReactViewCreatorMock());
|
|
26
|
-
activity = newActivity();
|
|
27
|
-
component = createComponent();
|
|
28
|
-
uut = new TitleBarReactViewController(activity, viewCreator, component);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@Test
|
|
32
|
-
public void createView() {
|
|
33
|
-
uut.createView();
|
|
34
|
-
verify(viewCreator).create(activity, component.componentId.get(), component.name.get());
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private ComponentOptions createComponent() {
|
|
38
|
-
ComponentOptions component = new ComponentOptions();
|
|
39
|
-
component.componentId = new Text("compId");
|
|
40
|
-
component.name = new Text("compName");
|
|
41
|
-
return component;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.stack;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.graphics.Color;
|
|
5
|
-
import android.view.MenuItem;
|
|
6
|
-
|
|
7
|
-
import com.reactnativenavigation.BaseTest;
|
|
8
|
-
import com.reactnativenavigation.TestUtils;
|
|
9
|
-
import com.reactnativenavigation.fakes.IconResolverFake;
|
|
10
|
-
import com.reactnativenavigation.mocks.ImageLoaderMock;
|
|
11
|
-
import com.reactnativenavigation.mocks.TitleBarButtonCreatorMock;
|
|
12
|
-
import com.reactnativenavigation.options.params.Bool;
|
|
13
|
-
import com.reactnativenavigation.options.ButtonOptions;
|
|
14
|
-
import com.reactnativenavigation.options.params.Colour;
|
|
15
|
-
import com.reactnativenavigation.options.params.NullText;
|
|
16
|
-
import com.reactnativenavigation.options.params.Number;
|
|
17
|
-
import com.reactnativenavigation.options.params.ThemeColour;
|
|
18
|
-
import com.reactnativenavigation.options.params.Text;
|
|
19
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter;
|
|
20
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController;
|
|
21
|
-
import com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar;
|
|
22
|
-
|
|
23
|
-
import org.junit.Test;
|
|
24
|
-
|
|
25
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
26
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
27
|
-
import static org.mockito.ArgumentMatchers.anyInt;
|
|
28
|
-
import static org.mockito.ArgumentMatchers.eq;
|
|
29
|
-
import static org.mockito.Mockito.spy;
|
|
30
|
-
import static org.mockito.Mockito.times;
|
|
31
|
-
import static org.mockito.Mockito.verify;
|
|
32
|
-
|
|
33
|
-
@SuppressWarnings("MagicNumber")
|
|
34
|
-
public class TopBarButtonControllerTest extends BaseTest {
|
|
35
|
-
|
|
36
|
-
private ButtonController uut;
|
|
37
|
-
private StackController stackController;
|
|
38
|
-
private ButtonOptions button;
|
|
39
|
-
private ButtonPresenter optionsPresenter;
|
|
40
|
-
|
|
41
|
-
@Override
|
|
42
|
-
public void beforeEach() {
|
|
43
|
-
button = new ButtonOptions();
|
|
44
|
-
final Activity activity = newActivity();
|
|
45
|
-
|
|
46
|
-
TitleBarButtonCreatorMock buttonCreatorMock = new TitleBarButtonCreatorMock();
|
|
47
|
-
stackController = spy(TestUtils.newStackController(activity).build());
|
|
48
|
-
stackController.getView().layout(0, 0, 1080, 1920);
|
|
49
|
-
stackController.getTopBar().layout(0, 0, 1080, 200);
|
|
50
|
-
getTitleBar().layout(0, 0, 1080, 200);
|
|
51
|
-
|
|
52
|
-
optionsPresenter = spy(new ButtonPresenter(activity, button, new IconResolverFake(activity, ImageLoaderMock.mock())));
|
|
53
|
-
uut = new ButtonController(activity, optionsPresenter, button, buttonCreatorMock, (buttonId) -> {
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
stackController.ensureViewIsCreated();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@Test
|
|
60
|
-
public void buttonDoesNotClearStackOptionsOnAppear() {
|
|
61
|
-
setReactComponentButton();
|
|
62
|
-
uut.ensureViewIsCreated();
|
|
63
|
-
uut.onViewWillAppear();
|
|
64
|
-
verify(stackController, times(0)).clearOptions();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@Test
|
|
68
|
-
public void setIconColor_enabled() {
|
|
69
|
-
setIconButton(true);
|
|
70
|
-
uut.addToMenu(getTitleBar(), 0);
|
|
71
|
-
|
|
72
|
-
assertThat(getTitleBar().getMenu().size()).isOne();
|
|
73
|
-
verify(optionsPresenter).tint(any(), eq(Color.RED));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@Test
|
|
77
|
-
public void setIconColor_disabled() {
|
|
78
|
-
setIconButton(false);
|
|
79
|
-
uut.addToMenu(getTitleBar(), 0);
|
|
80
|
-
|
|
81
|
-
verify(optionsPresenter).tint(any(), eq(Color.LTGRAY));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@Test
|
|
85
|
-
public void setIconColor_disabledColor() {
|
|
86
|
-
setIconButton(false);
|
|
87
|
-
button.disabledColor = new ThemeColour(new Colour(Color.BLACK), new Colour(Color.BLACK));
|
|
88
|
-
uut.addToMenu(getTitleBar(), 0);
|
|
89
|
-
|
|
90
|
-
verify(optionsPresenter).tint(any(), eq(Color.BLACK));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@Test
|
|
94
|
-
public void disableIconTint() {
|
|
95
|
-
setIconButton(false);
|
|
96
|
-
button.disableIconTint = new Bool(true);
|
|
97
|
-
uut.addToMenu(getTitleBar(), 0);
|
|
98
|
-
verify(optionsPresenter, times(0)).tint(any(), anyInt());
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private ButtonBar getTitleBar() {
|
|
102
|
-
return stackController.getTopBar().getRightButtonBar();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private void setIconButton(boolean enabled) {
|
|
106
|
-
button.id = "btn1";
|
|
107
|
-
button.icon = new Text("someIcon");
|
|
108
|
-
button.color = new ThemeColour(new Colour(Color.RED),new Colour(Color.RED));
|
|
109
|
-
button.component.name = new NullText();
|
|
110
|
-
button.component.componentId = new NullText();
|
|
111
|
-
button.enabled = new Bool(enabled);
|
|
112
|
-
button.showAsAction = new Number(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private void setReactComponentButton() {
|
|
116
|
-
button.id = "btnId";
|
|
117
|
-
button.component.name = new Text("com.example.customBtn");
|
|
118
|
-
button.component.componentId = new Text("component666");
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.stack
|
|
2
|
-
|
|
3
|
-
import android.animation.AnimatorSet
|
|
4
|
-
import android.app.Activity
|
|
5
|
-
import android.content.Context
|
|
6
|
-
import android.view.View
|
|
7
|
-
import org.mockito.kotlin.*
|
|
8
|
-
import com.reactnativenavigation.BaseTest
|
|
9
|
-
import com.reactnativenavigation.fakes.IconResolverFake
|
|
10
|
-
import com.reactnativenavigation.mocks.TitleBarButtonCreatorMock
|
|
11
|
-
import com.reactnativenavigation.options.BackButton
|
|
12
|
-
import com.reactnativenavigation.options.ButtonOptions
|
|
13
|
-
import com.reactnativenavigation.options.ComponentOptions
|
|
14
|
-
import com.reactnativenavigation.options.Options
|
|
15
|
-
import com.reactnativenavigation.options.params.Bool
|
|
16
|
-
import com.reactnativenavigation.options.params.Text
|
|
17
|
-
import com.reactnativenavigation.react.Constants
|
|
18
|
-
import com.reactnativenavigation.react.ReactView
|
|
19
|
-
import com.reactnativenavigation.utils.TitleBarHelper
|
|
20
|
-
import com.reactnativenavigation.utils.resetViewProperties
|
|
21
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarAnimator
|
|
22
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController
|
|
23
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController
|
|
24
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter
|
|
25
|
-
import com.reactnativenavigation.views.stack.StackLayout
|
|
26
|
-
import com.reactnativenavigation.views.stack.topbar.TopBar
|
|
27
|
-
import org.assertj.core.api.Java6Assertions.assertThat
|
|
28
|
-
import org.junit.Test
|
|
29
|
-
|
|
30
|
-
class TopBarControllerTest : BaseTest() {
|
|
31
|
-
private lateinit var uut: TopBarController
|
|
32
|
-
private lateinit var activity: Activity
|
|
33
|
-
private lateinit var leftButton: ButtonOptions
|
|
34
|
-
private lateinit var backButton: BackButton
|
|
35
|
-
private lateinit var textButton1: ButtonOptions
|
|
36
|
-
private lateinit var textButton2: ButtonOptions
|
|
37
|
-
private lateinit var componentButton: ButtonOptions
|
|
38
|
-
private lateinit var animator: TopBarAnimator
|
|
39
|
-
private lateinit var leftButtonControllers: MutableMap<String,ButtonController>
|
|
40
|
-
private lateinit var rightButtonControllers: MutableMap<String,ButtonController>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
private val topBar: View
|
|
44
|
-
get() = uut.view
|
|
45
|
-
|
|
46
|
-
override fun beforeEach() {
|
|
47
|
-
leftButtonControllers= mutableMapOf()
|
|
48
|
-
rightButtonControllers= mutableMapOf()
|
|
49
|
-
activity = newActivity()
|
|
50
|
-
animator = spy(TopBarAnimator())
|
|
51
|
-
uut = createTopBarController()
|
|
52
|
-
val stack = mock<StackLayout>()
|
|
53
|
-
uut.createView(activity, stack)
|
|
54
|
-
createButtons()
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@Test
|
|
58
|
-
fun setButton_setsTextButton() {
|
|
59
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf(textButton1)){
|
|
60
|
-
createButtonController(it)
|
|
61
|
-
}
|
|
62
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf(leftButton)){
|
|
63
|
-
createButtonController(it)
|
|
64
|
-
}
|
|
65
|
-
assertThat(uut.getRightButton(0).title.toString()).isEqualTo(textButton1.text.get())
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@Test
|
|
69
|
-
fun setButton_setsCustomButton() {
|
|
70
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf(leftButton)){
|
|
71
|
-
createButtonController(it)
|
|
72
|
-
}
|
|
73
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf(componentButton)){
|
|
74
|
-
createButtonController(it)
|
|
75
|
-
}
|
|
76
|
-
val btnView = uut.getRightButton(0).actionView as ReactView
|
|
77
|
-
assertThat(btnView.componentName).isEqualTo(componentButton.component.name.get())
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@Test
|
|
81
|
-
fun applyRightButtons_emptyButtonsListClearsRightButtons() {
|
|
82
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf(leftButton)){
|
|
83
|
-
createButtonController(it)
|
|
84
|
-
}
|
|
85
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf(componentButton, textButton1)){
|
|
86
|
-
createButtonController(it)
|
|
87
|
-
}
|
|
88
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf(leftButton)){
|
|
89
|
-
createButtonController(it)
|
|
90
|
-
}
|
|
91
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf()){
|
|
92
|
-
createButtonController(it)
|
|
93
|
-
}
|
|
94
|
-
assertThat(uut.rightButtonCount).isEqualTo(0)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@Test
|
|
98
|
-
fun applyRightButtons_previousButtonsAreCleared() {
|
|
99
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf(textButton1, componentButton)){
|
|
100
|
-
createButtonController(it)
|
|
101
|
-
}
|
|
102
|
-
assertThat(uut.rightButtonCount).isEqualTo(2)
|
|
103
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf(textButton2)){
|
|
104
|
-
createButtonController(it)
|
|
105
|
-
}
|
|
106
|
-
assertThat(uut.rightButtonCount).isEqualTo(1)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@Test
|
|
110
|
-
fun applyRightButtons_buttonsAreAddedInReversedOrderToMatchOrderOnIOs() {
|
|
111
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf(leftButton)){
|
|
112
|
-
createButtonController(it)
|
|
113
|
-
}
|
|
114
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf(textButton1, componentButton)){
|
|
115
|
-
createButtonController(it)
|
|
116
|
-
}
|
|
117
|
-
assertThat(uut.getRightButton(1).title.toString()).isEqualTo(textButton1.text.get())
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
@Test
|
|
121
|
-
fun applyRightButtons_componentButtonIsReapplied() {
|
|
122
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf( componentButton)){
|
|
123
|
-
createButtonController(it)
|
|
124
|
-
}
|
|
125
|
-
assertThat(uut.getRightButton(0).itemId).isEqualTo(componentButton.intId)
|
|
126
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf( textButton1)){
|
|
127
|
-
createButtonController(it)
|
|
128
|
-
}
|
|
129
|
-
assertThat(uut.getRightButton(0).itemId).isEqualTo(textButton1.intId)
|
|
130
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf( componentButton)){
|
|
131
|
-
createButtonController(it)
|
|
132
|
-
}
|
|
133
|
-
assertThat(uut.getRightButton(0).itemId).isEqualTo(componentButton.intId)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@Test
|
|
137
|
-
fun mergeRightButtonsOptions_componentButtonIsNotAddedIfAlreadyAddedToMenu() {
|
|
138
|
-
val controllers = mutableMapOf<String,ButtonController>()
|
|
139
|
-
uut.applyRightButtonsOptions(controllers, listOf(componentButton)){
|
|
140
|
-
createButtonController(it)
|
|
141
|
-
}
|
|
142
|
-
verify(controllers[componentButton.id]!!, times(1)).addToMenu(any(), any())
|
|
143
|
-
uut.mergeRightButtonsOptions(controllers, listOf(componentButton.copy())){
|
|
144
|
-
createButtonController(it)
|
|
145
|
-
}
|
|
146
|
-
verify(controllers[componentButton.id]!!, times(1)).addToMenu(any(), any())
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@Test
|
|
150
|
-
fun setLeftButtons_emptyButtonsListClearsLeftButton() {
|
|
151
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf(leftButton)){
|
|
152
|
-
createButtonController(it)
|
|
153
|
-
}
|
|
154
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf( componentButton)){
|
|
155
|
-
createButtonController(it)
|
|
156
|
-
}
|
|
157
|
-
assertThat(uut.leftButtonCount).isNotZero()
|
|
158
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf()){
|
|
159
|
-
createButtonController(it)
|
|
160
|
-
}
|
|
161
|
-
uut.applyRightButtonsOptions(rightButtonControllers, listOf( textButton1)){
|
|
162
|
-
createButtonController(it)
|
|
163
|
-
}
|
|
164
|
-
assertThat(uut.leftButtonCount).isZero()
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@Test
|
|
168
|
-
fun setLeftButtons_clearsBackButton() {
|
|
169
|
-
uut.view.setBackButton(TitleBarHelper.createButtonController(activity, backButton))
|
|
170
|
-
assertThat(uut.view.navigationIcon).isNotNull()
|
|
171
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf(leftButton)){
|
|
172
|
-
createButtonController(it)
|
|
173
|
-
}
|
|
174
|
-
assertThat(uut.view.navigationIcon).isNull()
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@Test
|
|
178
|
-
fun setLeftButtons_emptyButtonsListClearsBackButton() {
|
|
179
|
-
uut.view.setBackButton(TitleBarHelper.createButtonController(activity, backButton))
|
|
180
|
-
assertThat(uut.view.navigationIcon).isNotNull()
|
|
181
|
-
uut.applyLeftButtonsOptions(leftButtonControllers, listOf()){
|
|
182
|
-
createButtonController(it)
|
|
183
|
-
}
|
|
184
|
-
assertThat(uut.view.navigationIcon).isNull()
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
@Test
|
|
188
|
-
fun mergeLeftButtons_clearsBackButton() {
|
|
189
|
-
val controllers = mutableMapOf<String,ButtonController>()
|
|
190
|
-
uut.view.setBackButton(TitleBarHelper.createButtonController(activity, backButton))
|
|
191
|
-
assertThat(uut.view.navigationIcon).isNotNull()
|
|
192
|
-
uut.mergeLeftButtonsOptions(controllers, listOf(leftButton)){
|
|
193
|
-
createButtonController(it)
|
|
194
|
-
}
|
|
195
|
-
assertThat(uut.view.navigationIcon).isNull()
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
@Test
|
|
199
|
-
fun mergeLeftButtons_emptyButtonsListClearsBackButton() {
|
|
200
|
-
val controllers = mutableMapOf<String,ButtonController>()
|
|
201
|
-
|
|
202
|
-
uut.view.setBackButton(TitleBarHelper.createButtonController(activity, backButton))
|
|
203
|
-
assertThat(uut.view.navigationIcon).isNotNull()
|
|
204
|
-
uut.applyLeftButtonsOptions(controllers, listOf(leftButton)){
|
|
205
|
-
createButtonController(it)
|
|
206
|
-
}
|
|
207
|
-
uut.mergeLeftButtonsOptions(controllers, emptyList()){
|
|
208
|
-
createButtonController(it)
|
|
209
|
-
}
|
|
210
|
-
assertThat(uut.view.navigationIcon).isNull()
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
@Test
|
|
214
|
-
fun show() {
|
|
215
|
-
uut.hide()
|
|
216
|
-
assertGone(topBar)
|
|
217
|
-
|
|
218
|
-
uut.show()
|
|
219
|
-
verify(topBar).resetViewProperties()
|
|
220
|
-
assertVisible(topBar)
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
@Test
|
|
224
|
-
fun getPushAnimation_returnsNullIfAnimateFalse() {
|
|
225
|
-
val appearing = Options()
|
|
226
|
-
appearing.topBar.animate = Bool(false)
|
|
227
|
-
assertThat(uut.getPushAnimation(appearing)).isNull()
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
@Test
|
|
231
|
-
fun getPushAnimation_delegatesToAnimator() {
|
|
232
|
-
val someAnimator = AnimatorSet()
|
|
233
|
-
val options = Options.EMPTY
|
|
234
|
-
doReturn(someAnimator).whenever(animator).getPushAnimation(
|
|
235
|
-
options.animations.push.topBar,
|
|
236
|
-
options.topBar.visible,
|
|
237
|
-
0f
|
|
238
|
-
)
|
|
239
|
-
val result = uut.getPushAnimation(options)
|
|
240
|
-
assertThat(result).isEqualTo(someAnimator)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
@Test
|
|
244
|
-
fun getPopAnimation_returnsNullIfAnimateFalse() {
|
|
245
|
-
val appearing = Options()
|
|
246
|
-
val disappearing = Options()
|
|
247
|
-
disappearing.topBar.animate = Bool(false)
|
|
248
|
-
assertThat(uut.getPopAnimation(appearing, disappearing)).isNull()
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
@Test
|
|
252
|
-
fun getPopAnimation_delegatesToAnimator() {
|
|
253
|
-
val someAnimator = AnimatorSet()
|
|
254
|
-
val appearing = Options.EMPTY
|
|
255
|
-
val disappearing = Options.EMPTY
|
|
256
|
-
doReturn(someAnimator).whenever(animator).getPopAnimation(
|
|
257
|
-
disappearing.animations.pop.topBar,
|
|
258
|
-
appearing.topBar.visible,
|
|
259
|
-
0f
|
|
260
|
-
)
|
|
261
|
-
val result = uut.getPopAnimation(appearing, disappearing)
|
|
262
|
-
assertThat(result).isEqualTo(someAnimator)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
@Test
|
|
266
|
-
fun getSetStackRootAnimation_returnsNullIfAnimateFalse() {
|
|
267
|
-
val appearing = Options()
|
|
268
|
-
appearing.topBar.animate = Bool(false)
|
|
269
|
-
assertThat(uut.getSetStackRootAnimation(appearing)).isNull()
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
@Test
|
|
273
|
-
fun getSetStackRootAnimation_delegatesToAnimator() {
|
|
274
|
-
val someAnimator = AnimatorSet()
|
|
275
|
-
val options = Options.EMPTY
|
|
276
|
-
doReturn(someAnimator).whenever(animator).getSetStackRootAnimation(
|
|
277
|
-
options.animations.setStackRoot.topBar,
|
|
278
|
-
options.topBar.visible,
|
|
279
|
-
0f
|
|
280
|
-
)
|
|
281
|
-
val result = uut.getSetStackRootAnimation(options)
|
|
282
|
-
assertThat(result).isEqualTo(someAnimator)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
@Test
|
|
286
|
-
fun `mergeRightButtons - should add buttons`(){
|
|
287
|
-
val controllers = spy(LinkedHashMap<String,ButtonController>())
|
|
288
|
-
val controller = spy(ButtonController(activity, ButtonPresenter(activity, textButton1, IconResolverFake(activity)),
|
|
289
|
-
textButton1, TitleBarButtonCreatorMock(), object : ButtonController.OnClickListener {
|
|
290
|
-
override fun onPress(button: ButtonOptions) {
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
}))
|
|
295
|
-
uut.mergeRightButtonsOptions(controllers, listOf(textButton1)) {
|
|
296
|
-
controller
|
|
297
|
-
}
|
|
298
|
-
assertThat(uut.rightButtonCount).isEqualTo(1)
|
|
299
|
-
verify(controllers, never()).remove(any())
|
|
300
|
-
assertThat(controllers[textButton1.id]).isEqualTo(controller)
|
|
301
|
-
}
|
|
302
|
-
@Test
|
|
303
|
-
fun `mergeRightOptions - should destroy all buttons that was removed`(){
|
|
304
|
-
val componentButton2 = componentButton.copy()
|
|
305
|
-
componentButton2.component = ComponentOptions().apply {
|
|
306
|
-
this.name = componentButton.component.name
|
|
307
|
-
this.componentId = Text("CustomNewComponent")
|
|
308
|
-
}
|
|
309
|
-
uut.mergeRightButtonsOptions(rightButtonControllers, listOf(textButton1, textButton2, componentButton)) {
|
|
310
|
-
createButtonController(it)
|
|
311
|
-
}
|
|
312
|
-
val removedControllers = mutableMapOf<String, ButtonController>().apply {
|
|
313
|
-
putAll(rightButtonControllers)
|
|
314
|
-
}
|
|
315
|
-
uut.mergeRightButtonsOptions(rightButtonControllers, listOf(componentButton2)) {
|
|
316
|
-
createButtonController(it)
|
|
317
|
-
}
|
|
318
|
-
verify(removedControllers[textButton1.id]!!, times(1)).destroy()
|
|
319
|
-
verify(removedControllers[textButton2.id]!!, times(1)).destroy()
|
|
320
|
-
verify(removedControllers[componentButton.id]!!, times(1)).destroy()
|
|
321
|
-
}
|
|
322
|
-
@Test
|
|
323
|
-
fun `mergeRightButtons - should remove all and re-add buttons in case of reorder, without destroy`(){
|
|
324
|
-
uut.mergeRightButtonsOptions(rightButtonControllers, listOf(textButton1, textButton2)) {
|
|
325
|
-
createButtonController(it)
|
|
326
|
-
}
|
|
327
|
-
assertThat(uut.getRightButton(1).itemId ).isEqualTo(textButton1.intId)
|
|
328
|
-
assertThat(uut.getRightButton(0).itemId ).isEqualTo(textButton2.intId)
|
|
329
|
-
val removedControllers = mutableMapOf<String, ButtonController>().apply { putAll(rightButtonControllers) }
|
|
330
|
-
uut.mergeRightButtonsOptions(rightButtonControllers, listOf(textButton2.copy(), textButton1.copy())) {
|
|
331
|
-
createButtonController(it)
|
|
332
|
-
}
|
|
333
|
-
assertThat(uut.getRightButton(1).itemId ).isEqualTo(textButton2.intId)
|
|
334
|
-
assertThat(uut.getRightButton(0).itemId ).isEqualTo(textButton1.intId)
|
|
335
|
-
|
|
336
|
-
verify(removedControllers[textButton1.id]!!, never()).destroy()
|
|
337
|
-
verify(removedControllers[textButton2.id]!!, never()).destroy()
|
|
338
|
-
|
|
339
|
-
verify(rightButtonControllers[textButton1.id]!!, times(2)).addToMenu(any(), any())
|
|
340
|
-
verify(rightButtonControllers[textButton2.id]!!, times(2)).addToMenu(any(), any())
|
|
341
|
-
}
|
|
342
|
-
@Test
|
|
343
|
-
fun `mergeRightButtons - should rebuild menu when adding menu items, existing should not be destroyed`(){
|
|
344
|
-
val controllers = spy(LinkedHashMap<String,ButtonController>())
|
|
345
|
-
uut.mergeRightButtonsOptions(controllers, listOf(textButton1)) {
|
|
346
|
-
createButtonController(it)
|
|
347
|
-
}
|
|
348
|
-
assertThat(uut.rightButtonCount).isEqualTo(1)
|
|
349
|
-
|
|
350
|
-
uut.mergeRightButtonsOptions(controllers, listOf(textButton1, textButton2)) {
|
|
351
|
-
createButtonController(it)
|
|
352
|
-
}
|
|
353
|
-
assertThat(uut.rightButtonCount).isEqualTo(2)
|
|
354
|
-
verify(controllers, never()).remove(any())
|
|
355
|
-
verify(controllers[textButton1.id]!!, times(2)).addToMenu(any(), any())
|
|
356
|
-
}
|
|
357
|
-
@Test
|
|
358
|
-
fun `mergeRightButtons - should modify changed buttons`(){
|
|
359
|
-
val controllers = spy(LinkedHashMap<String,ButtonController>())
|
|
360
|
-
uut.mergeRightButtonsOptions(controllers, listOf(textButton1.apply {
|
|
361
|
-
this.enabled = Bool(true)
|
|
362
|
-
})) {
|
|
363
|
-
createButtonController(it)
|
|
364
|
-
}
|
|
365
|
-
assertThat(uut.rightButtonCount).isEqualTo(1)
|
|
366
|
-
verify(controllers[textButton1.id]!!, times(1)).addToMenu(any(), any())
|
|
367
|
-
|
|
368
|
-
uut.mergeRightButtonsOptions(controllers, listOf(textButton1.copy().apply { this.enabled= Bool(false) })) {
|
|
369
|
-
createButtonController(it)
|
|
370
|
-
}
|
|
371
|
-
verify(controllers, never()).remove(any())
|
|
372
|
-
verify(controllers[textButton1.id]!!, times(1)).mergeButtonOptions(any(), any())
|
|
373
|
-
verify(controllers[textButton1.id]!!, times(1)).addToMenu(any(), any())
|
|
374
|
-
verify(controllers[textButton1.id]!!, never()).destroy()
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
@Test
|
|
378
|
-
fun `mergeRightButtons - reorder of same menu items should rebuild menu, not view recreation`(){
|
|
379
|
-
val controllers = spy(LinkedHashMap<String,ButtonController>())
|
|
380
|
-
uut.mergeRightButtonsOptions(controllers, listOf(textButton1, textButton2)) {
|
|
381
|
-
createButtonController(it)
|
|
382
|
-
}
|
|
383
|
-
assertThat(uut.rightButtonCount).isEqualTo(2)
|
|
384
|
-
verify(controllers[textButton1.id]!!, times(1)).addToMenu(any(), any())
|
|
385
|
-
verify(controllers[textButton2.id]!!, times(1)).addToMenu(any(), any())
|
|
386
|
-
|
|
387
|
-
uut.mergeRightButtonsOptions(controllers, listOf(textButton2.copy(), textButton1.copy())) {
|
|
388
|
-
createButtonController(it)
|
|
389
|
-
}
|
|
390
|
-
verify(controllers[textButton1.id]!!, never()).mergeButtonOptions(any(), any())
|
|
391
|
-
verify(controllers[textButton2.id]!!, never()).mergeButtonOptions(any(), any())
|
|
392
|
-
verify(controllers[textButton1.id]!!, times(2)).addToMenu(any(), any())
|
|
393
|
-
verify(controllers[textButton2.id]!!, times(2)).addToMenu(any(), any())
|
|
394
|
-
verify(controllers[textButton1.id]!!, never()).destroy()
|
|
395
|
-
verify(controllers[textButton2.id]!!, never()).destroy()
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
private fun createButtonController(it: ButtonOptions) =
|
|
399
|
-
spy(ButtonController(activity, ButtonPresenter(activity, it, IconResolverFake(activity)),
|
|
400
|
-
it, TitleBarButtonCreatorMock(), object : ButtonController.OnClickListener {
|
|
401
|
-
override fun onPress(button: ButtonOptions) {
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
}))
|
|
406
|
-
|
|
407
|
-
private fun createButtons() {
|
|
408
|
-
leftButton = ButtonOptions()
|
|
409
|
-
leftButton.id = Constants.BACK_BUTTON_ID
|
|
410
|
-
backButton = BackButton.parse(activity, null)
|
|
411
|
-
textButton1 = createTextButton("1")
|
|
412
|
-
textButton2 = createTextButton("2")
|
|
413
|
-
componentButton = ButtonOptions()
|
|
414
|
-
componentButton.id = "customBtn"
|
|
415
|
-
componentButton.component.name = Text("com.rnn.customBtn")
|
|
416
|
-
componentButton.component.componentId = Text("component4")
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
private fun createTextButton(id: String): ButtonOptions {
|
|
420
|
-
val button = ButtonOptions()
|
|
421
|
-
button.id = id
|
|
422
|
-
button.text = Text("txt$id")
|
|
423
|
-
return button
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
private fun createTopBarController() = spy(object : TopBarController(animator) {
|
|
427
|
-
override fun createTopBar(context: Context, stackLayout: StackLayout): TopBar {
|
|
428
|
-
return spy(super.createTopBar(context, stackLayout))
|
|
429
|
-
}
|
|
430
|
-
})
|
|
431
|
-
|
|
432
|
-
}
|