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,319 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.modal;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.os.Looper;
|
|
5
|
-
import android.widget.FrameLayout;
|
|
6
|
-
|
|
7
|
-
import com.reactnativenavigation.BaseTest;
|
|
8
|
-
import com.reactnativenavigation.mocks.SimpleViewController;
|
|
9
|
-
import com.reactnativenavigation.options.TransitionAnimationOptionsKt;
|
|
10
|
-
import com.reactnativenavigation.options.TransitionAnimationOptionsTestKt;
|
|
11
|
-
import com.reactnativenavigation.options.ModalPresentationStyle;
|
|
12
|
-
import com.reactnativenavigation.options.Options;
|
|
13
|
-
import com.reactnativenavigation.options.params.Bool;
|
|
14
|
-
import com.reactnativenavigation.react.CommandListener;
|
|
15
|
-
import com.reactnativenavigation.react.CommandListenerAdapter;
|
|
16
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildController;
|
|
17
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
18
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
19
|
-
|
|
20
|
-
import org.json.JSONException;
|
|
21
|
-
import org.json.JSONObject;
|
|
22
|
-
import org.junit.Test;
|
|
23
|
-
import org.mockito.InOrder;
|
|
24
|
-
import org.mockito.Mockito;
|
|
25
|
-
import org.robolectric.Shadows;
|
|
26
|
-
|
|
27
|
-
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
28
|
-
|
|
29
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
30
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
31
|
-
import static org.mockito.ArgumentMatchers.eq;
|
|
32
|
-
import static org.mockito.Mockito.inOrder;
|
|
33
|
-
import static org.mockito.Mockito.never;
|
|
34
|
-
import static org.mockito.Mockito.spy;
|
|
35
|
-
import static org.mockito.Mockito.times;
|
|
36
|
-
import static org.mockito.Mockito.verify;
|
|
37
|
-
import static org.mockito.Mockito.verifyNoInteractions;
|
|
38
|
-
|
|
39
|
-
public class ModalPresenterTest extends BaseTest {
|
|
40
|
-
private static final String MODAL_ID_1 = "modalId1";
|
|
41
|
-
private static final String MODAL_ID_2 = "modalId2";
|
|
42
|
-
|
|
43
|
-
private ChildController<?> modal1;
|
|
44
|
-
private ChildController<?> modal2;
|
|
45
|
-
private ModalPresenter uut;
|
|
46
|
-
private ModalAnimator animator;
|
|
47
|
-
private ViewController<?> root;
|
|
48
|
-
private CoordinatorLayout modalsLayout;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
@Override
|
|
52
|
-
public void beforeEach() {
|
|
53
|
-
super.beforeEach();
|
|
54
|
-
Activity activity = newActivity();
|
|
55
|
-
ChildControllersRegistry childRegistry = new ChildControllersRegistry();
|
|
56
|
-
|
|
57
|
-
root = spy(new SimpleViewController(activity, childRegistry, "root", new Options()));
|
|
58
|
-
FrameLayout contentLayout = new FrameLayout(activity);
|
|
59
|
-
FrameLayout rootLayout = new FrameLayout(activity);
|
|
60
|
-
rootLayout.addView(root.getView());
|
|
61
|
-
modalsLayout = new CoordinatorLayout(activity);
|
|
62
|
-
contentLayout.addView(rootLayout);
|
|
63
|
-
contentLayout.addView(modalsLayout);
|
|
64
|
-
activity.setContentView(contentLayout);
|
|
65
|
-
|
|
66
|
-
animator = spy(new ModalAnimator(activity));
|
|
67
|
-
uut = new ModalPresenter(animator);
|
|
68
|
-
uut.setModalsLayout(modalsLayout);
|
|
69
|
-
uut.setRootLayout(rootLayout);
|
|
70
|
-
modal1 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_1, new Options()));
|
|
71
|
-
modal2 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_2, new Options()));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@Test
|
|
75
|
-
public void showModal() {
|
|
76
|
-
Options defaultOptions = new Options();
|
|
77
|
-
uut.setDefaultOptions(defaultOptions);
|
|
78
|
-
disableShowModalAnimation(modal1);
|
|
79
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
80
|
-
verify(modal1).setWaitForRender(any());
|
|
81
|
-
assertThat(modal1.getView().getFitsSystemWindows()).isTrue();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@Test
|
|
85
|
-
public void showModal_noAnimation() {
|
|
86
|
-
disableShowModalAnimation(modal1);
|
|
87
|
-
CommandListener listener = spy(new CommandListenerAdapter() {
|
|
88
|
-
@Override
|
|
89
|
-
public void onSuccess(String childId) {
|
|
90
|
-
Shadows.shadowOf(Looper.getMainLooper()).idle();
|
|
91
|
-
assertThat(modal1.getView().getParent()).isEqualTo(modalsLayout);
|
|
92
|
-
verify(modal1).onViewWillAppear();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
uut.showModal(modal1, root, listener);
|
|
96
|
-
verify(animator, never()).show(
|
|
97
|
-
eq(modal1),
|
|
98
|
-
eq(root),
|
|
99
|
-
eq(modal1.options.animations.showModal),
|
|
100
|
-
any()
|
|
101
|
-
);
|
|
102
|
-
verify(listener).onSuccess(MODAL_ID_1);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@Test
|
|
106
|
-
public void showModal_resolvesDefaultOptions() throws JSONException {
|
|
107
|
-
Options defaultOptions = new Options();
|
|
108
|
-
JSONObject disabledShowModalAnimation = TransitionAnimationOptionsTestKt.newModalAnimationJson(false);
|
|
109
|
-
defaultOptions.animations.showModal = TransitionAnimationOptionsKt.parseTransitionAnimationOptions(disabledShowModalAnimation);
|
|
110
|
-
uut.setDefaultOptions(defaultOptions);
|
|
111
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
112
|
-
verifyNoInteractions(animator);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@Test
|
|
116
|
-
public void showModal_previousModalIsRemovedFromHierarchy() {
|
|
117
|
-
uut.showModal(modal1, root, new CommandListenerAdapter() {
|
|
118
|
-
@Override
|
|
119
|
-
public void onSuccess(String childId) {
|
|
120
|
-
uut.showModal(modal2, modal1, new CommandListenerAdapter() {
|
|
121
|
-
@Override
|
|
122
|
-
public void onSuccess(String childId) {
|
|
123
|
-
idleMainLooper();
|
|
124
|
-
assertThat(modal1.getView().getParent()).isNull();
|
|
125
|
-
verify(modal1).onViewDisappear();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
assertThat(modal1.getView().getParent()).isEqualTo(modal2.getView().getParent());
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@Test
|
|
134
|
-
public void showModal_overCurrentContext_previousModalIsNotRemovedFromHierarchy() {
|
|
135
|
-
Options options = new Options();
|
|
136
|
-
options.modal.presentationStyle = ModalPresentationStyle.OverCurrentContext;
|
|
137
|
-
uut.setDefaultOptions(options);
|
|
138
|
-
disableShowModalAnimation(modal1);
|
|
139
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
140
|
-
verify(root, times(0)).detachView();
|
|
141
|
-
verify(root, times(0)).onViewDisappear();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
@Test
|
|
145
|
-
public void showModal_animatesByDefault() {
|
|
146
|
-
uut.showModal(modal1, root, new CommandListenerAdapter() {
|
|
147
|
-
@Override
|
|
148
|
-
public void onSuccess(String childId) {
|
|
149
|
-
verify(animator).show(
|
|
150
|
-
eq(modal1),
|
|
151
|
-
eq(root),
|
|
152
|
-
any(),
|
|
153
|
-
any()
|
|
154
|
-
);
|
|
155
|
-
assertThat(animator.isRunning()).isFalse();
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
assertThat(animator.isRunning()).isTrue();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
@Test
|
|
162
|
-
public void showModal_waitForRender() {
|
|
163
|
-
modal1.options.animations.showModal.setWaitForRender(new Bool(true));
|
|
164
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
165
|
-
verify(modal1).addOnAppearedListener(any());
|
|
166
|
-
verifyNoInteractions(animator);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
@Test
|
|
170
|
-
public void showModal_rejectIfContentIsNull() {
|
|
171
|
-
uut.setModalsLayout(null);
|
|
172
|
-
CommandListenerAdapter listener = Mockito.mock(CommandListenerAdapter.class);
|
|
173
|
-
uut.showModal(modal1, modal2, listener);
|
|
174
|
-
verify(listener).onError(any());
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@Test
|
|
178
|
-
public void showModal_onViewDidAppearIsInvokedBeforeViewDisappear() {
|
|
179
|
-
disableShowModalAnimation(modal1);
|
|
180
|
-
root.onViewWillAppear();
|
|
181
|
-
|
|
182
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
183
|
-
idleMainLooper();
|
|
184
|
-
InOrder inOrder = inOrder(modal1, root);
|
|
185
|
-
inOrder.verify(modal1).onViewDidAppear();
|
|
186
|
-
inOrder.verify(root).onViewDisappear();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
@Test
|
|
190
|
-
public void dismissModal_animatesByDefault() {
|
|
191
|
-
disableShowModalAnimation(modal1);
|
|
192
|
-
|
|
193
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
194
|
-
uut.dismissModal(modal1, root, root, new CommandListenerAdapter() {
|
|
195
|
-
@Override
|
|
196
|
-
public void onSuccess(String childId) {
|
|
197
|
-
post(() -> {
|
|
198
|
-
verify(modal1).onViewDisappear();
|
|
199
|
-
verify(modal1).destroy();
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
verify(animator).dismiss(eq(root), eq(modal1), any(), any());
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
@Test
|
|
208
|
-
public void dismissModal_previousViewIsAddedAtIndex0() {
|
|
209
|
-
disableShowModalAnimation(modal1);
|
|
210
|
-
FrameLayout spy = spy(new FrameLayout(newActivity()));
|
|
211
|
-
uut.setRootLayout(spy);
|
|
212
|
-
|
|
213
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
214
|
-
idleMainLooper();
|
|
215
|
-
uut.dismissModal(modal1, root, root, new CommandListenerAdapter());
|
|
216
|
-
|
|
217
|
-
verify(spy).addView(root.getView(), 0);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
@Test
|
|
221
|
-
public void dismissModal_noAnimation() {
|
|
222
|
-
disableModalAnimations(modal1);
|
|
223
|
-
|
|
224
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
225
|
-
Shadows.shadowOf(Looper.getMainLooper()).idle();
|
|
226
|
-
uut.dismissModal(modal1, root, root, new CommandListenerAdapter());
|
|
227
|
-
verify(modal1).onViewDisappear();
|
|
228
|
-
verify(modal1).destroy();
|
|
229
|
-
verify(animator, never()).dismiss(eq(root), any(), eq(modal1.options.animations.dismissModal), any());
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
@Test
|
|
233
|
-
public void dismissModal_previousModalIsAddedBackToHierarchy() {
|
|
234
|
-
disableShowModalAnimation(modal1, modal2);
|
|
235
|
-
|
|
236
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
237
|
-
idleMainLooper();
|
|
238
|
-
assertThat(modal1.getView().getParent()).isNotNull();
|
|
239
|
-
verify(modal1).onViewWillAppear();
|
|
240
|
-
|
|
241
|
-
uut.showModal(modal2, modal1, new CommandListenerAdapter());
|
|
242
|
-
idleMainLooper();
|
|
243
|
-
assertThat(modal1.getView().getParent()).isNull();
|
|
244
|
-
|
|
245
|
-
Shadows.shadowOf(Looper.getMainLooper()).idle();
|
|
246
|
-
uut.dismissModal(modal2, modal1, root, new CommandListenerAdapter());
|
|
247
|
-
assertThat(modal1.getView().getParent()).isNotNull();
|
|
248
|
-
idleMainLooper();
|
|
249
|
-
verify(modal1, times(2)).onViewWillAppear();
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
@Test
|
|
253
|
-
public void dismissModal_previousControllerIsNotAddedIfDismissedModalIsNotTop() {
|
|
254
|
-
disableShowModalAnimation(modal1, modal2);
|
|
255
|
-
disableDismissModalAnimation(modal1, modal2);
|
|
256
|
-
|
|
257
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
258
|
-
uut.showModal(modal2, modal1, new CommandListenerAdapter());
|
|
259
|
-
idleMainLooper();
|
|
260
|
-
assertThat(modal1.getView().getParent()).isNull();
|
|
261
|
-
assertThat(root.getView().getParent()).isNull();
|
|
262
|
-
|
|
263
|
-
uut.dismissModal(modal1, null, root, new CommandListenerAdapter());
|
|
264
|
-
assertThat(root.getView().getParent()).isNull();
|
|
265
|
-
|
|
266
|
-
uut.dismissModal(modal2, root, root, new CommandListenerAdapter());
|
|
267
|
-
assertThat(root.getView().getParent()).isNotNull();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
@Test
|
|
271
|
-
public void dismissModal_previousViewIsNotDetachedIfOverCurrentContext() {
|
|
272
|
-
modal1.options.modal.presentationStyle = ModalPresentationStyle.OverCurrentContext;
|
|
273
|
-
disableShowModalAnimation(modal1, modal2);
|
|
274
|
-
|
|
275
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
276
|
-
assertThat(root.getView().getParent()).isNotNull();
|
|
277
|
-
verify(root, times(0)).onViewDisappear();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
@Test
|
|
281
|
-
public void dismissModal_rejectIfContentIsNull() {
|
|
282
|
-
uut.setModalsLayout(null);
|
|
283
|
-
CommandListenerAdapter listener = Mockito.mock(CommandListenerAdapter.class);
|
|
284
|
-
uut.dismissModal(modal1, root, root, listener);
|
|
285
|
-
verify(listener).onError(any());
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
@Test
|
|
289
|
-
public void dismissModal_successIsReportedBeforeViewIsDestroyed() {
|
|
290
|
-
disableModalAnimations(modal1);
|
|
291
|
-
CommandListenerAdapter listener = Mockito.mock(CommandListenerAdapter.class);
|
|
292
|
-
ViewController<?> modal = spy(modal1);
|
|
293
|
-
InOrder inOrder = inOrder(listener, modal);
|
|
294
|
-
|
|
295
|
-
uut.showModal(modal, root, new CommandListenerAdapter());
|
|
296
|
-
|
|
297
|
-
uut.dismissModal(modal, root, root, listener);
|
|
298
|
-
inOrder.verify(listener).onSuccess(modal.getId());
|
|
299
|
-
inOrder.verify(modal).destroy();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
@Test
|
|
303
|
-
public void dismissModal_modalsLayoutIfHiddenIsAllModalsAreDismissed() {
|
|
304
|
-
disableShowModalAnimation(modal1, modal2);
|
|
305
|
-
disableDismissModalAnimation(modal1, modal2);
|
|
306
|
-
|
|
307
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
308
|
-
assertVisible(modalsLayout);
|
|
309
|
-
uut.showModal(modal2, modal1, new CommandListenerAdapter());
|
|
310
|
-
assertVisible(modalsLayout);
|
|
311
|
-
|
|
312
|
-
uut.dismissModal(modal2, modal1, root, new CommandListenerAdapter());
|
|
313
|
-
assertVisible(modalsLayout);
|
|
314
|
-
uut.dismissModal(modal1, root, root, new CommandListenerAdapter());
|
|
315
|
-
assertGone(modalsLayout);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.modal;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.widget.FrameLayout;
|
|
5
|
-
|
|
6
|
-
import com.reactnativenavigation.BaseTest;
|
|
7
|
-
import com.reactnativenavigation.TestUtils;
|
|
8
|
-
import com.reactnativenavigation.mocks.SimpleViewController;
|
|
9
|
-
import com.reactnativenavigation.options.Options;
|
|
10
|
-
import com.reactnativenavigation.react.CommandListener;
|
|
11
|
-
import com.reactnativenavigation.react.CommandListenerAdapter;
|
|
12
|
-
import com.reactnativenavigation.react.events.EventEmitter;
|
|
13
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
14
|
-
import com.reactnativenavigation.viewcontrollers.stack.StackController;
|
|
15
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
16
|
-
import com.reactnativenavigation.options.TransitionAnimationOptions;
|
|
17
|
-
import org.junit.Test;
|
|
18
|
-
import org.mockito.Mockito;
|
|
19
|
-
|
|
20
|
-
import java.util.EmptyStackException;
|
|
21
|
-
|
|
22
|
-
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
23
|
-
|
|
24
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
25
|
-
import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
|
|
26
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
27
|
-
import static org.mockito.ArgumentMatchers.anyString;
|
|
28
|
-
import static org.mockito.ArgumentMatchers.eq;
|
|
29
|
-
import static org.mockito.Mockito.never;
|
|
30
|
-
import static org.mockito.Mockito.spy;
|
|
31
|
-
import static org.mockito.Mockito.times;
|
|
32
|
-
import static org.mockito.Mockito.verify;
|
|
33
|
-
import static org.mockito.Mockito.verifyNoInteractions;
|
|
34
|
-
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
|
35
|
-
import static org.mockito.Mockito.when;
|
|
36
|
-
|
|
37
|
-
public class ModalStackTest extends BaseTest {
|
|
38
|
-
private static final String MODAL_ID_1 = "modalId1";
|
|
39
|
-
private static final String MODAL_ID_2 = "modalId2";
|
|
40
|
-
private static final String MODAL_ID_3 = "modalId3";
|
|
41
|
-
private static final String MODAL_ID_4 = "modalId4";
|
|
42
|
-
|
|
43
|
-
private ModalStack uut;
|
|
44
|
-
private ViewController<?> modal1;
|
|
45
|
-
private ViewController<?> modal2;
|
|
46
|
-
private ViewController<?> modal3;
|
|
47
|
-
private ViewController<?> modal4;
|
|
48
|
-
private StackController stack;
|
|
49
|
-
private Activity activity;
|
|
50
|
-
private ChildControllersRegistry childRegistry;
|
|
51
|
-
private ModalPresenter presenter;
|
|
52
|
-
private ModalAnimator animator;
|
|
53
|
-
private ViewController<?> root;
|
|
54
|
-
private EventEmitter emitter;
|
|
55
|
-
|
|
56
|
-
@Override
|
|
57
|
-
public void beforeEach() {
|
|
58
|
-
super.beforeEach();
|
|
59
|
-
activity = newActivity();
|
|
60
|
-
childRegistry = new ChildControllersRegistry();
|
|
61
|
-
root = new SimpleViewController(activity, childRegistry, "root", new Options());
|
|
62
|
-
|
|
63
|
-
FrameLayout rootLayout = new FrameLayout(activity);
|
|
64
|
-
CoordinatorLayout modalsLayout = new CoordinatorLayout(activity);
|
|
65
|
-
FrameLayout contentLayout = new FrameLayout(activity);
|
|
66
|
-
contentLayout.addView(rootLayout);
|
|
67
|
-
contentLayout.addView(modalsLayout);
|
|
68
|
-
activity.setContentView(contentLayout);
|
|
69
|
-
|
|
70
|
-
animator = spy(new ModalAnimatorMock(activity));
|
|
71
|
-
presenter = spy(new ModalPresenter(animator));
|
|
72
|
-
uut = new ModalStack(activity, presenter);
|
|
73
|
-
uut.setModalsLayout(modalsLayout);
|
|
74
|
-
uut.setRootLayout(rootLayout);
|
|
75
|
-
emitter = Mockito.mock(EventEmitter.class);
|
|
76
|
-
uut.setEventEmitter(emitter);
|
|
77
|
-
modal1 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_1, new Options()));
|
|
78
|
-
modal2 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_2, new Options()));
|
|
79
|
-
modal3 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_3, new Options()));
|
|
80
|
-
modal4 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_4, new Options()));
|
|
81
|
-
stack = TestUtils.newStackController(activity)
|
|
82
|
-
.setChildren(modal4)
|
|
83
|
-
.build();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@Test
|
|
87
|
-
public void showModal_DidAppearEventShouldBeCallled(){
|
|
88
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
89
|
-
uut.showModal(modal1, root, listener);
|
|
90
|
-
verify(listener).onSuccess(modal1.getId());
|
|
91
|
-
idleMainLooper();
|
|
92
|
-
verify(modal1).onViewDidAppear();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@Test
|
|
96
|
-
public void modalRefIsSaved() {
|
|
97
|
-
disableShowModalAnimation(modal1);
|
|
98
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
99
|
-
uut.showModal(modal1, root, listener);
|
|
100
|
-
verify(listener, times(1)).onSuccess(modal1.getId());
|
|
101
|
-
assertThat(findModal(MODAL_ID_1)).isNotNull();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
@Test
|
|
105
|
-
public void showModal() {
|
|
106
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
107
|
-
uut.showModal(modal1, root, listener);
|
|
108
|
-
idleMainLooper();
|
|
109
|
-
verify(listener).onSuccess(modal1.getId());
|
|
110
|
-
verify(modal1).onViewDidAppear();
|
|
111
|
-
assertThat(uut.size()).isOne();
|
|
112
|
-
verify(presenter).showModal(eq(modal1), eq(root), any());
|
|
113
|
-
assertThat(findModal(MODAL_ID_1)).isNotNull();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@Test
|
|
117
|
-
public void showModal_canShowModalBeforeRootIsSet() {
|
|
118
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
119
|
-
uut.showModal(modal1, null, listener);
|
|
120
|
-
verify(listener).onSuccess(modal1.getId());
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@Test
|
|
124
|
-
public void dismissModal() {
|
|
125
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
126
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
127
|
-
uut.dismissModal(modal1.getId(), root, listener);
|
|
128
|
-
assertThat(findModal(modal1.getId())).isNull();
|
|
129
|
-
verify(presenter).dismissModal(eq(modal1), eq(root), eq(root), any());
|
|
130
|
-
verify(listener).onSuccess(modal1.getId());
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@Test
|
|
134
|
-
public void dismissModal_listenerAndEmitterAreInvokedWithRootViewControllerId() {
|
|
135
|
-
uut.showModal(stack, root, new CommandListenerAdapter());
|
|
136
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
137
|
-
uut.dismissModal(modal4.getId(), root, listener);
|
|
138
|
-
verify(listener).onSuccess(stack.getId());
|
|
139
|
-
verify(emitter).emitModalDismissed(stack.getId(), modal4.getCurrentComponentName(), 1);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
@SuppressWarnings("Convert2Lambda")
|
|
143
|
-
@Test
|
|
144
|
-
public void dismissModal_rejectIfModalNotFound() {
|
|
145
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
146
|
-
Runnable onModalWillDismiss = spy(new Runnable() {
|
|
147
|
-
@Override
|
|
148
|
-
public void run() {
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
uut.dismissModal(MODAL_ID_1, root, listener);
|
|
153
|
-
verify(onModalWillDismiss, times(0)).run();
|
|
154
|
-
verify(listener, times(1)).onError(anyString());
|
|
155
|
-
verifyNoMoreInteractions(listener);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
@Test
|
|
159
|
-
public void dismissModal_dismissDeepModal() {
|
|
160
|
-
disableShowModalAnimation(modal1, modal2, modal3);
|
|
161
|
-
disableDismissModalAnimation(modal1, modal2, modal3);
|
|
162
|
-
|
|
163
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
164
|
-
uut.showModal(modal2, root, new CommandListenerAdapter());
|
|
165
|
-
uut.showModal(modal3, root, new CommandListenerAdapter());
|
|
166
|
-
|
|
167
|
-
assertThat(root.getView().getParent()).isNull();
|
|
168
|
-
uut.dismissModal(modal1.getId(), root, new CommandListenerAdapter());
|
|
169
|
-
assertThat(root.getView().getParent()).isNull();
|
|
170
|
-
|
|
171
|
-
uut.dismissModal(modal3.getId(), root, new CommandListenerAdapter());
|
|
172
|
-
uut.dismissModal(modal2.getId(), root, new CommandListenerAdapter());
|
|
173
|
-
assertThat(root.getView().getParent()).isNotNull();
|
|
174
|
-
assertThat(root.getView().isShown()).isTrue();
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@Test
|
|
178
|
-
public void dismissAllModals() {
|
|
179
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
180
|
-
uut.showModal(modal2, root, new CommandListenerAdapter());
|
|
181
|
-
CommandListener listener = spy(new CommandListenerAdapter() {
|
|
182
|
-
@Override
|
|
183
|
-
public void onSuccess(String childId) {
|
|
184
|
-
assertThat(findModal(modal1.getId())).isNull();
|
|
185
|
-
assertThat(findModal(modal2.getId())).isNull();
|
|
186
|
-
assertThat(uut.isEmpty()).isTrue();
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
uut.dismissAllModals(root, Options.EMPTY, listener);
|
|
190
|
-
verify(listener, times(1)).onSuccess(anyString());
|
|
191
|
-
verifyNoMoreInteractions(listener);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
@Test
|
|
195
|
-
public void dismissAllModal_resolvesPromiseSuccessfullyWhenCalledBeforeRootIsSet() {
|
|
196
|
-
CommandListenerAdapter spy = spy(new CommandListenerAdapter());
|
|
197
|
-
uut.dismissAllModals(null, Options.EMPTY, spy);
|
|
198
|
-
verify(spy).onSuccess("");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
@Test
|
|
202
|
-
public void dismissAllModals_resolveSuccessfullyIfEmpty() {
|
|
203
|
-
CommandListener spy = spy(new CommandListenerAdapter());
|
|
204
|
-
uut.dismissAllModals(root, Options.EMPTY, spy);
|
|
205
|
-
verify(spy, times(1)).onSuccess(root.getId());
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
@Test
|
|
209
|
-
public void dismissAllModals_optionsAreMergedOnTopModal() {
|
|
210
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
211
|
-
uut.showModal(modal2, root, new CommandListenerAdapter());
|
|
212
|
-
uut.showModal(modal3, root, new CommandListenerAdapter());
|
|
213
|
-
|
|
214
|
-
Options mergeOptions = new Options();
|
|
215
|
-
uut.dismissAllModals(root, mergeOptions, new CommandListenerAdapter());
|
|
216
|
-
verify(modal3).mergeOptions(mergeOptions);
|
|
217
|
-
verify(modal1, times(0)).mergeOptions(mergeOptions);
|
|
218
|
-
verify(modal2, times(0)).mergeOptions(mergeOptions);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
@Test
|
|
222
|
-
public void dismissAllModals_onlyTopModalIsAnimated() {
|
|
223
|
-
modal2 = spy(modal2);
|
|
224
|
-
Options defaultOptions = new Options();
|
|
225
|
-
uut.setDefaultOptions(defaultOptions);
|
|
226
|
-
Options resolvedOptions = new Options();
|
|
227
|
-
when(modal2.resolveCurrentOptions(defaultOptions)).then(invocation -> resolvedOptions);
|
|
228
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
229
|
-
uut.showModal(modal2, root, new CommandListenerAdapter());
|
|
230
|
-
|
|
231
|
-
CommandListener listener = spy(new CommandListenerAdapter());
|
|
232
|
-
uut.dismissAllModals(root, Options.EMPTY, listener);
|
|
233
|
-
verify(presenter).dismissModal(eq(modal2), eq(root), eq(root), any());
|
|
234
|
-
verify(listener).onSuccess(modal2.getId());
|
|
235
|
-
verify(animator, never()).dismiss(eq(modal1), eq(modal2), eq(modal1.options.animations.dismissModal), any());
|
|
236
|
-
verify(animator).dismiss(eq(root), eq(modal2), eq(resolvedOptions.animations.dismissModal), any());
|
|
237
|
-
assertThat(uut.size()).isEqualTo(0);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@Test
|
|
241
|
-
public void dismissAllModals_bottomModalsAreDestroyed() {
|
|
242
|
-
disableModalAnimations(modal1, modal2);
|
|
243
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
244
|
-
idleMainLooper();
|
|
245
|
-
uut.showModal(modal2, root, new CommandListenerAdapter());
|
|
246
|
-
|
|
247
|
-
uut.dismissAllModals(root, Options.EMPTY, new CommandListenerAdapter());
|
|
248
|
-
|
|
249
|
-
verify(modal1).destroy();
|
|
250
|
-
verify(modal1).onViewDisappear();
|
|
251
|
-
assertThat(uut.size()).isEqualTo(0);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
@Test
|
|
255
|
-
public void isEmpty() {
|
|
256
|
-
assertThat(uut.isEmpty()).isTrue();
|
|
257
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
258
|
-
assertThat(uut.isEmpty()).isFalse();
|
|
259
|
-
uut.dismissAllModals(root, Options.EMPTY, new CommandListenerAdapter());
|
|
260
|
-
assertThat(uut.isEmpty()).isTrue();
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
@Test
|
|
264
|
-
public void peek() {
|
|
265
|
-
assertThat(uut.isEmpty()).isTrue();
|
|
266
|
-
assertThatThrownBy(() -> uut.peek()).isInstanceOf(EmptyStackException.class);
|
|
267
|
-
uut.showModal(modal1, root, new CommandListenerAdapter() {
|
|
268
|
-
@Override
|
|
269
|
-
public void onSuccess(String childId) {
|
|
270
|
-
assertThat(uut.peek()).isEqualTo(modal1);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
@Test
|
|
276
|
-
public void onDismiss_onViewAppearedInvokedOnPreviousModal() {
|
|
277
|
-
disableShowModalAnimation(modal1, modal2);
|
|
278
|
-
|
|
279
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
280
|
-
idleMainLooper();
|
|
281
|
-
uut.showModal(modal2, root, new CommandListenerAdapter());
|
|
282
|
-
idleMainLooper();
|
|
283
|
-
uut.dismissModal(modal2.getId(), root, new CommandListenerAdapter());
|
|
284
|
-
idleMainLooper();
|
|
285
|
-
verify(modal1, times(2)).onViewWillAppear();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
@Test
|
|
289
|
-
public void onDismiss_dismissModalInTheMiddleOfStack() {
|
|
290
|
-
disableShowModalAnimation(modal1, modal2, modal3);
|
|
291
|
-
disableDismissModalAnimation(modal1, modal2, modal3);
|
|
292
|
-
|
|
293
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
294
|
-
uut.showModal(modal2, root, new CommandListenerAdapter());
|
|
295
|
-
idleMainLooper();
|
|
296
|
-
uut.showModal(modal3, root, new CommandListenerAdapter());
|
|
297
|
-
|
|
298
|
-
uut.dismissModal(modal2.getId(), root, new CommandListenerAdapter());
|
|
299
|
-
idleMainLooper();
|
|
300
|
-
assertThat(uut.size()).isEqualTo(2);
|
|
301
|
-
verify(modal2).onViewDisappear();
|
|
302
|
-
verify(modal2).destroy();
|
|
303
|
-
assertThat(modal1.getView().getParent()).isNull();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
@Test
|
|
307
|
-
public void handleBack_doesNothingIfModalStackIsEmpty() {
|
|
308
|
-
assertThat(uut.isEmpty()).isTrue();
|
|
309
|
-
assertThat(uut.handleBack(new CommandListenerAdapter(), root)).isFalse();
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
@Test
|
|
313
|
-
public void handleBack_dismissModal() {
|
|
314
|
-
disableDismissModalAnimation(modal1);
|
|
315
|
-
uut.showModal(modal1, root, new CommandListenerAdapter());
|
|
316
|
-
idleMainLooper();
|
|
317
|
-
assertThat(uut.handleBack(new CommandListenerAdapter(), root)).isTrue();
|
|
318
|
-
verify(modal1).onViewDisappear();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
@Test
|
|
322
|
-
public void handleBack_ViewControllerTakesPrecedenceOverModal() {
|
|
323
|
-
ViewController<?> backHandlingModal = spy(new SimpleViewController(activity, childRegistry, "stack", new Options()){
|
|
324
|
-
@Override
|
|
325
|
-
public boolean handleBack(CommandListener listener) {
|
|
326
|
-
return true;
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
uut.showModal(backHandlingModal, root, new CommandListenerAdapter());
|
|
330
|
-
|
|
331
|
-
root.getView().getViewTreeObserver().dispatchOnGlobalLayout();
|
|
332
|
-
|
|
333
|
-
assertThat(uut.handleBack(new CommandListenerAdapter(), any())).isTrue();
|
|
334
|
-
verify(backHandlingModal, times(1)).handleBack(any());
|
|
335
|
-
verify(backHandlingModal, times(0)).onViewDisappear();
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
@Test
|
|
339
|
-
public void setDefaultOptions() {
|
|
340
|
-
Options defaultOptions = new Options();
|
|
341
|
-
uut.setDefaultOptions(defaultOptions);
|
|
342
|
-
verify(presenter).setDefaultOptions(defaultOptions);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
@Test
|
|
346
|
-
public void destroy() {
|
|
347
|
-
showModalsWithoutAnimation(modal1, modal2);
|
|
348
|
-
uut.destroy();
|
|
349
|
-
verify(modal1).destroy();
|
|
350
|
-
verify(modal2).destroy();
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
private ViewController<?> findModal(String id) {
|
|
354
|
-
return uut.findControllerById(id);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
private void showModalsWithoutAnimation(ViewController<?>... modals) {
|
|
358
|
-
for (ViewController<?> modal : modals) {
|
|
359
|
-
showModalWithoutAnimation(modal);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
private void showModalWithoutAnimation(ViewController<?> modal) {
|
|
364
|
-
disableShowModalAnimation(modal);
|
|
365
|
-
uut.showModal(modal, root, new CommandListenerAdapter());
|
|
366
|
-
}
|
|
367
|
-
}
|