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,446 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.sidemenu;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.content.res.Resources;
|
|
5
|
-
import android.graphics.Path;
|
|
6
|
-
import android.util.TypedValue;
|
|
7
|
-
import android.view.Gravity;
|
|
8
|
-
import android.view.View;
|
|
9
|
-
import android.view.ViewGroup;
|
|
10
|
-
import android.view.ViewGroup.LayoutParams;
|
|
11
|
-
import android.view.Window;
|
|
12
|
-
|
|
13
|
-
import com.reactnativenavigation.BaseTest;
|
|
14
|
-
import com.reactnativenavigation.mocks.SimpleComponentViewController;
|
|
15
|
-
import com.reactnativenavigation.options.Options;
|
|
16
|
-
import com.reactnativenavigation.options.SideMenuOptions;
|
|
17
|
-
import com.reactnativenavigation.options.params.Bool;
|
|
18
|
-
import com.reactnativenavigation.options.params.Number;
|
|
19
|
-
import com.reactnativenavigation.options.params.Text;
|
|
20
|
-
import com.reactnativenavigation.react.CommandListenerAdapter;
|
|
21
|
-
import com.reactnativenavigation.utils.Functions;
|
|
22
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
23
|
-
import com.reactnativenavigation.viewcontrollers.parent.ParentController;
|
|
24
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
25
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
26
|
-
import com.reactnativenavigation.views.sidemenu.SideMenu;
|
|
27
|
-
|
|
28
|
-
import org.jetbrains.annotations.NotNull;
|
|
29
|
-
import org.junit.Test;
|
|
30
|
-
import org.mockito.Mockito;
|
|
31
|
-
|
|
32
|
-
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
33
|
-
import static com.reactnativenavigation.utils.CollectionUtils.*;
|
|
34
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
35
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
36
|
-
import static org.mockito.ArgumentMatchers.eq;
|
|
37
|
-
import static org.mockito.Mockito.mock;
|
|
38
|
-
import static org.mockito.Mockito.never;
|
|
39
|
-
import static org.mockito.Mockito.spy;
|
|
40
|
-
import static org.mockito.Mockito.times;
|
|
41
|
-
import static org.mockito.Mockito.verify;
|
|
42
|
-
import static org.mockito.Mockito.when;
|
|
43
|
-
|
|
44
|
-
@SuppressWarnings("MagicNumber")
|
|
45
|
-
public class SideMenuControllerTest extends BaseTest {
|
|
46
|
-
private SideMenuController uut;
|
|
47
|
-
private Activity activity;
|
|
48
|
-
private ChildControllersRegistry childRegistry;
|
|
49
|
-
private SideMenuPresenter presenter;
|
|
50
|
-
private ViewController<?> left;
|
|
51
|
-
private ViewController<?> right;
|
|
52
|
-
private ViewController<?> center;
|
|
53
|
-
private ViewController<?> child;
|
|
54
|
-
private ParentController<?> parent;
|
|
55
|
-
private Options resolvedOptions;
|
|
56
|
-
|
|
57
|
-
@Override
|
|
58
|
-
public void beforeEach() {
|
|
59
|
-
super.beforeEach();
|
|
60
|
-
activity = createActivity();
|
|
61
|
-
|
|
62
|
-
childRegistry = new ChildControllersRegistry();
|
|
63
|
-
presenter = spy(new SideMenuPresenter());
|
|
64
|
-
child = new SimpleComponentViewController(activity, childRegistry, "child", new Options());
|
|
65
|
-
left = spy(new SimpleComponentViewController(activity, childRegistry, "left", new Options()));
|
|
66
|
-
right = spy(new SimpleComponentViewController(activity, childRegistry, "right", createSideMenuOptions()));
|
|
67
|
-
center = spy(new SimpleComponentViewController(activity, childRegistry, "center", createSideMenuOptions()));
|
|
68
|
-
uut = new SideMenuController(activity, childRegistry, "sideMenu", new Options(), presenter, new Presenter(activity, new Options())) {
|
|
69
|
-
@Override
|
|
70
|
-
public Options resolveCurrentOptions() {
|
|
71
|
-
resolvedOptions = super.resolveCurrentOptions();
|
|
72
|
-
return resolvedOptions;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
uut.setCenterController(center);
|
|
76
|
-
parent = mock(ParentController.class);
|
|
77
|
-
Mockito.when(parent.resolveChildOptions(uut)).thenReturn(Options.EMPTY);
|
|
78
|
-
uut.setParentController(parent);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@NotNull
|
|
82
|
-
private Options createSideMenuOptions() {
|
|
83
|
-
Options options = new Options();
|
|
84
|
-
options.sideMenuRootOptions.left.animate = new Bool(false);
|
|
85
|
-
options.sideMenuRootOptions.right.animate = new Bool(false);
|
|
86
|
-
return options;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@Test
|
|
90
|
-
public void createView_bindView() {
|
|
91
|
-
uut.ensureViewIsCreated();
|
|
92
|
-
SideMenu sideMenu = uut.getSideMenu();
|
|
93
|
-
verify(presenter).bindView(eq(sideMenu));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@Test
|
|
97
|
-
public void applyOptions() {
|
|
98
|
-
Options options = new Options();
|
|
99
|
-
uut.applyOptions(options);
|
|
100
|
-
verify(presenter).applyOptions(options);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@Test
|
|
104
|
-
public void getCurrentChild() {
|
|
105
|
-
setLeftRight(left, right);
|
|
106
|
-
|
|
107
|
-
assertThat(uut.getCurrentChild()).isEqualTo(center);
|
|
108
|
-
|
|
109
|
-
openLeftMenu();
|
|
110
|
-
assertThat(uut.getCurrentChild()).isEqualTo(left);
|
|
111
|
-
|
|
112
|
-
closeLeftMenu();
|
|
113
|
-
openRightMenu();
|
|
114
|
-
assertThat(uut.getCurrentChild()).isEqualTo(right);
|
|
115
|
-
|
|
116
|
-
closeRightMenu();
|
|
117
|
-
assertThat(uut.getCurrentChild()).isEqualTo(center);
|
|
118
|
-
uut.destroy();
|
|
119
|
-
assertThat(uut.getCurrentChild()).isEqualTo(center);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@Test
|
|
123
|
-
public void onViewAppeared() {
|
|
124
|
-
ViewController left = spy(this.left);
|
|
125
|
-
ViewGroup leftView = spy(left.getView());
|
|
126
|
-
when(left.findController(leftView)).thenReturn(left);
|
|
127
|
-
Mockito.doReturn(leftView).when(left).getView();
|
|
128
|
-
|
|
129
|
-
ViewController right = spy(this.right);
|
|
130
|
-
ViewGroup rightView = spy(right.getView());
|
|
131
|
-
when(right.findController(rightView)).thenReturn(right);
|
|
132
|
-
Mockito.doReturn(rightView).when(right).getView();
|
|
133
|
-
|
|
134
|
-
setLeftRight(left, right);
|
|
135
|
-
|
|
136
|
-
uut.onViewWillAppear();
|
|
137
|
-
verify(leftView).requestLayout();
|
|
138
|
-
verify(rightView).requestLayout();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@Test
|
|
142
|
-
public void applyChildOptions() {
|
|
143
|
-
uut.applyChildOptions(new Options(), child);
|
|
144
|
-
verify(presenter).applyChildOptions(eq(resolvedOptions));
|
|
145
|
-
verify(parent).applyChildOptions(uut.options, child);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
@Test
|
|
149
|
-
public void mergeOptions_openLeftSideMenu() {
|
|
150
|
-
uut.setLeftController(new SimpleComponentViewController(activity, childRegistry, "left", new Options()));
|
|
151
|
-
|
|
152
|
-
Options options = new Options();
|
|
153
|
-
options.sideMenuRootOptions.left.visible = new Bool(true);
|
|
154
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.LEFT)).isFalse();
|
|
155
|
-
uut.mergeOptions(options);
|
|
156
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.LEFT)).isTrue();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
@Test
|
|
160
|
-
public void mergeOptions_openRightSideMenu() {
|
|
161
|
-
uut.setRightController(new SimpleComponentViewController(activity, childRegistry, "right", new Options()));
|
|
162
|
-
|
|
163
|
-
Options options = new Options();
|
|
164
|
-
options.sideMenuRootOptions.right.visible = new Bool(true);
|
|
165
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.RIGHT)).isFalse();
|
|
166
|
-
uut.mergeOptions(options);
|
|
167
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.RIGHT)).isTrue();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
@Test
|
|
171
|
-
public void mergeOptions_optionsAreClearedAfterMerge() {
|
|
172
|
-
Options initialOptions = uut.options;
|
|
173
|
-
Options options = new Options();
|
|
174
|
-
uut.mergeOptions(options);
|
|
175
|
-
assertThat(uut.options.sideMenuRootOptions).isNotEqualTo(initialOptions.sideMenuRootOptions);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@Test
|
|
179
|
-
public void mergeChildOptions() {
|
|
180
|
-
Options options = new Options();
|
|
181
|
-
uut.mergeChildOptions(options, child);
|
|
182
|
-
verify(presenter).mergeOptions(options.sideMenuRootOptions);
|
|
183
|
-
verify(parent).mergeChildOptions(options, child);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
@Test
|
|
187
|
-
public void resolveCurrentOptions_centerOptionsAreMergedEvenIfDrawerIsOpen() {
|
|
188
|
-
uut.setLeftController(left);
|
|
189
|
-
center.options.topBar.title.text = new Text("Center");
|
|
190
|
-
assertThat(uut.resolveCurrentOptions().topBar.title.text.hasValue()).isTrue();
|
|
191
|
-
|
|
192
|
-
openLeftMenu();
|
|
193
|
-
assertThat(uut.resolveCurrentOptions().topBar.title.text.hasValue()).isTrue();
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
@Test
|
|
197
|
-
public void mergeChildOptions_lockModeIsUpdatedInInitialOptions() {
|
|
198
|
-
setLeftRight(left, right);
|
|
199
|
-
|
|
200
|
-
Options leftDisabled = new Options();
|
|
201
|
-
leftDisabled.sideMenuRootOptions.left.enabled = new Bool(false);
|
|
202
|
-
left.mergeOptions(leftDisabled);
|
|
203
|
-
assertThat(uut.resolveCurrentOptions().sideMenuRootOptions.left.enabled.get()).isFalse();
|
|
204
|
-
|
|
205
|
-
Options rightVisible = new Options();
|
|
206
|
-
rightVisible.sideMenuRootOptions.right.visible = new Bool(true);
|
|
207
|
-
right.mergeOptions(rightVisible);
|
|
208
|
-
assertThat(uut.resolveCurrentOptions().sideMenuRootOptions.left.enabled.get()).isFalse();
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
@Test
|
|
212
|
-
public void setLeftController_matchesParentByDefault() {
|
|
213
|
-
SideMenuOptions options = new SideMenuOptions();
|
|
214
|
-
assertThat(options.width.hasValue()).isFalse();
|
|
215
|
-
assertThat(options.height.hasValue()).isFalse();
|
|
216
|
-
uut.options.sideMenuRootOptions.left = options;
|
|
217
|
-
|
|
218
|
-
SimpleComponentViewController componentViewController = new SimpleComponentViewController(activity, childRegistry, "left", new Options());
|
|
219
|
-
uut.setLeftController(componentViewController);
|
|
220
|
-
|
|
221
|
-
LayoutParams params = componentViewController.getView().getLayoutParams();
|
|
222
|
-
assertThat(params.width).isEqualTo(MATCH_PARENT);
|
|
223
|
-
assertThat(params.height).isEqualTo(MATCH_PARENT);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
@Test
|
|
227
|
-
public void setLeftController_setHeightAndWidthWithOptions() {
|
|
228
|
-
SideMenuOptions options = new SideMenuOptions();
|
|
229
|
-
options.height = new Number(100);
|
|
230
|
-
options.width = new Number(200);
|
|
231
|
-
uut.options.sideMenuRootOptions.left = options;
|
|
232
|
-
|
|
233
|
-
SimpleComponentViewController componentViewController = new SimpleComponentViewController(activity, childRegistry, "left", new Options());
|
|
234
|
-
uut.setLeftController(componentViewController);
|
|
235
|
-
|
|
236
|
-
int heightInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, Resources.getSystem().getDisplayMetrics());
|
|
237
|
-
int widthInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, Resources.getSystem().getDisplayMetrics());
|
|
238
|
-
|
|
239
|
-
LayoutParams params = componentViewController.getView().getLayoutParams();
|
|
240
|
-
assertThat(params.width).isEqualTo(widthInDp);
|
|
241
|
-
assertThat(params.height).isEqualTo(heightInDp);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
@Test
|
|
245
|
-
public void setRightController_matchesParentByDefault() {
|
|
246
|
-
SideMenuOptions options = new SideMenuOptions();
|
|
247
|
-
assertThat(options.width.hasValue()).isFalse();
|
|
248
|
-
assertThat(options.height.hasValue()).isFalse();
|
|
249
|
-
uut.options.sideMenuRootOptions.left = options;
|
|
250
|
-
|
|
251
|
-
SimpleComponentViewController componentViewController = new SimpleComponentViewController(activity, childRegistry, "right", new Options());
|
|
252
|
-
uut.setRightController(componentViewController);
|
|
253
|
-
|
|
254
|
-
LayoutParams params = componentViewController.getView().getLayoutParams();
|
|
255
|
-
assertThat(params.width).isEqualTo(MATCH_PARENT);
|
|
256
|
-
assertThat(params.height).isEqualTo(MATCH_PARENT);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
@Test
|
|
260
|
-
public void setRightController_setHeightAndWidthWithOptions() {
|
|
261
|
-
SideMenuOptions options = new SideMenuOptions();
|
|
262
|
-
options.height = new Number(100);
|
|
263
|
-
options.width = new Number(200);
|
|
264
|
-
uut.options.sideMenuRootOptions.left = options;
|
|
265
|
-
|
|
266
|
-
SimpleComponentViewController componentViewController = new SimpleComponentViewController(activity, childRegistry, "left", new Options());
|
|
267
|
-
uut.setLeftController(componentViewController);
|
|
268
|
-
|
|
269
|
-
int heightInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, Resources.getSystem().getDisplayMetrics());
|
|
270
|
-
int widthInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, Resources.getSystem().getDisplayMetrics());
|
|
271
|
-
|
|
272
|
-
LayoutParams params = componentViewController.getView().getLayoutParams();
|
|
273
|
-
assertThat(params.width).isEqualTo(widthInDp);
|
|
274
|
-
assertThat(params.height).isEqualTo(heightInDp);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
@Test
|
|
278
|
-
public void handleBack_closesLeftMenu() {
|
|
279
|
-
uut.setLeftController(left);
|
|
280
|
-
assertThat(uut.handleBack(new CommandListenerAdapter())).isFalse();
|
|
281
|
-
verify(center, times(1)).handleBack(any());
|
|
282
|
-
|
|
283
|
-
openLeftMenu();
|
|
284
|
-
assertThat(uut.handleBack(new CommandListenerAdapter())).isTrue();
|
|
285
|
-
verify(center, times(1)).handleBack(any());
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
@Test
|
|
289
|
-
public void handleBack_closesRightMenu() {
|
|
290
|
-
uut.setRightController(right);
|
|
291
|
-
assertThat(uut.handleBack(new CommandListenerAdapter())).isFalse();
|
|
292
|
-
verify(center, times(1)).handleBack(any());
|
|
293
|
-
|
|
294
|
-
openRightMenu();
|
|
295
|
-
assertThat(uut.handleBack(new CommandListenerAdapter())).isTrue();
|
|
296
|
-
verify(center, times(1)).handleBack(any());
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
@Test
|
|
300
|
-
public void leftMenuOpen_visibilityEventsAreEmitted() {
|
|
301
|
-
uut.setLeftController(left);
|
|
302
|
-
activity.setContentView(uut.getView());
|
|
303
|
-
|
|
304
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.LEFT)).isFalse();
|
|
305
|
-
verify(left, never()).onViewWillAppear();
|
|
306
|
-
|
|
307
|
-
openLeftMenu();
|
|
308
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.LEFT)).isTrue();
|
|
309
|
-
verify(left).onViewDidAppear();
|
|
310
|
-
|
|
311
|
-
closeLeftMenu();
|
|
312
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.LEFT)).isFalse();
|
|
313
|
-
verify(left).onViewDisappear();
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
@Test
|
|
317
|
-
public void rightMenuOpen_visibilityEventsAreEmitted() {
|
|
318
|
-
uut.setRightController(right);
|
|
319
|
-
activity.setContentView(uut.getView());
|
|
320
|
-
|
|
321
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.RIGHT)).isFalse();
|
|
322
|
-
verify(right, never()).onViewWillAppear();
|
|
323
|
-
|
|
324
|
-
openRightMenu();
|
|
325
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.RIGHT)).isTrue();
|
|
326
|
-
verify(right).onViewDidAppear();
|
|
327
|
-
|
|
328
|
-
closeRightMenu();
|
|
329
|
-
assertThat(uut.getView().isDrawerOpen(Gravity.RIGHT)).isFalse();
|
|
330
|
-
verify(right).onViewDisappear();
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
@Test
|
|
334
|
-
public void onDrawerOpened_drawerOpenedWIthSwipe_visibilityIsUpdated() {
|
|
335
|
-
uut.setLeftController(left);
|
|
336
|
-
uut.setRightController(right);
|
|
337
|
-
uut.ensureViewIsCreated();
|
|
338
|
-
|
|
339
|
-
openDrawerAndAssertVisibility(right, (side) -> side.resolveCurrentOptions().sideMenuRootOptions.right);
|
|
340
|
-
closeDrawerAndAssertVisibility(right, (side) -> side.resolveCurrentOptions().sideMenuRootOptions.right);
|
|
341
|
-
|
|
342
|
-
openDrawerAndAssertVisibility(left, (side) -> side.resolveCurrentOptions().sideMenuRootOptions.left);
|
|
343
|
-
closeDrawerAndAssertVisibility(left, (side) -> side.resolveCurrentOptions().sideMenuRootOptions.left);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
@Test
|
|
347
|
-
public void onDrawerSlide_componentDidAppearIsEmittedWhenDrawerIsFullyOpened() {
|
|
348
|
-
uut.setLeftController(left);
|
|
349
|
-
uut.setRightController(right);
|
|
350
|
-
uut.ensureViewIsCreated();
|
|
351
|
-
|
|
352
|
-
uut.onDrawerSlide(left.getView(),0.1f);
|
|
353
|
-
uut.onDrawerSlide(right.getView(),0.1f);
|
|
354
|
-
|
|
355
|
-
verify(left, times(0)).onViewDidAppear();
|
|
356
|
-
verify(right, times(0)).onViewDidAppear();
|
|
357
|
-
|
|
358
|
-
uut.onDrawerSlide(left.getView(),1);
|
|
359
|
-
uut.onDrawerSlide(right.getView(),1);
|
|
360
|
-
|
|
361
|
-
verify(left).onViewDidAppear();
|
|
362
|
-
verify(right).onViewDidAppear();
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
@Test
|
|
366
|
-
public void applyTopInsets_delegatesToChildren() {
|
|
367
|
-
setLeftRight(spy(left), spy(right));
|
|
368
|
-
uut.applyTopInset();
|
|
369
|
-
forEach(uut.getChildControllers(), c -> verify(c).applyTopInset());
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
@Test
|
|
373
|
-
public void onMeasureChild_topInsetsAreApplied() {
|
|
374
|
-
setLeftRight(spy(left), spy(right));
|
|
375
|
-
idleMainLooper();
|
|
376
|
-
uut.applyTopInset();
|
|
377
|
-
forEach(uut.getChildControllers(), c -> verify(c).applyTopInset());
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
private void openDrawerAndAssertVisibility(ViewController<?> side, Functions.FuncR1<ViewController<?>, SideMenuOptions> opt) {
|
|
381
|
-
Options options = new Options();
|
|
382
|
-
(side == left ? options.sideMenuRootOptions.left : options.sideMenuRootOptions.right).visible = new Bool(true);
|
|
383
|
-
uut.mergeOptions(options);
|
|
384
|
-
assertThat(uut.getView().isDrawerOpen(getGravity(side))).isTrue();
|
|
385
|
-
assertThat(opt.run(side).visible.isFalseOrUndefined()).isTrue();
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
private void closeDrawerAndAssertVisibility(ViewController<?> side, Functions.FuncR1<ViewController<?>, SideMenuOptions> opt) {
|
|
389
|
-
Options options = new Options();
|
|
390
|
-
(side == left ? options.sideMenuRootOptions.left : options.sideMenuRootOptions.right).visible = new Bool(false);
|
|
391
|
-
uut.mergeOptions(options);
|
|
392
|
-
assertThat(uut.getView().isDrawerOpen(getGravity(side))).isFalse();
|
|
393
|
-
assertThat(opt.run(side).visible.isTrue()).isFalse();
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
private int getGravity(ViewController<?> side) {
|
|
397
|
-
return side == left ? Gravity.LEFT : Gravity.RIGHT;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
private void openLeftMenu() {
|
|
401
|
-
Options options = new Options();
|
|
402
|
-
options.sideMenuRootOptions.left.visible = new Bool(true);
|
|
403
|
-
options.sideMenuRootOptions.left.animate = new Bool(false);
|
|
404
|
-
uut.mergeOptions(options);
|
|
405
|
-
uut.onDrawerSlide(left.getView(), 1);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
private void openRightMenu() {
|
|
409
|
-
Options options = new Options();
|
|
410
|
-
options.sideMenuRootOptions.right.visible = new Bool(true);
|
|
411
|
-
options.sideMenuRootOptions.right.animate = new Bool(false);
|
|
412
|
-
uut.mergeOptions(options);
|
|
413
|
-
uut.onDrawerSlide(right.getView(), 1);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
private void closeLeftMenu() {
|
|
417
|
-
Options options = new Options();
|
|
418
|
-
options.sideMenuRootOptions.left.visible = new Bool(false);
|
|
419
|
-
options.sideMenuRootOptions.left.animate = new Bool(false);
|
|
420
|
-
uut.mergeOptions(options);
|
|
421
|
-
uut.onDrawerSlide(left.getView(), 0);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
private void closeRightMenu() {
|
|
425
|
-
Options options = new Options();
|
|
426
|
-
options.sideMenuRootOptions.right.visible = new Bool(false);
|
|
427
|
-
options.sideMenuRootOptions.right.animate = new Bool(false);
|
|
428
|
-
uut.mergeOptions(options);
|
|
429
|
-
uut.onDrawerSlide(right.getView(), 0);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
private Activity createActivity() {
|
|
433
|
-
Activity activity = spy(newActivity());
|
|
434
|
-
Window window = mock(Window.class);
|
|
435
|
-
when(window.getDecorView()).thenReturn(mock(View.class));
|
|
436
|
-
when(activity.getWindow()).thenReturn(window);
|
|
437
|
-
return activity;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
private void setLeftRight(ViewController<?> left, ViewController<?> right) {
|
|
441
|
-
uut.setLeftController(left);
|
|
442
|
-
uut.setRightController(right);
|
|
443
|
-
left.setParentController(uut);
|
|
444
|
-
right.setParentController(uut);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.stack;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
|
|
5
|
-
import com.reactnativenavigation.BaseTest;
|
|
6
|
-
import com.reactnativenavigation.TestUtils;
|
|
7
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.BackButtonHelper;
|
|
8
|
-
import com.reactnativenavigation.mocks.SimpleViewController;
|
|
9
|
-
import com.reactnativenavigation.options.Options;
|
|
10
|
-
import com.reactnativenavigation.options.params.Bool;
|
|
11
|
-
import com.reactnativenavigation.react.CommandListenerAdapter;
|
|
12
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildController;
|
|
13
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
14
|
-
|
|
15
|
-
import org.junit.Test;
|
|
16
|
-
import org.mockito.ArgumentCaptor;
|
|
17
|
-
|
|
18
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
19
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
20
|
-
import static org.mockito.Mockito.spy;
|
|
21
|
-
import static org.mockito.Mockito.times;
|
|
22
|
-
import static org.mockito.Mockito.verify;
|
|
23
|
-
|
|
24
|
-
public class BackButtonHelperTest extends BaseTest {
|
|
25
|
-
private BackButtonHelper uut;
|
|
26
|
-
private StackController stack;
|
|
27
|
-
private ChildController<?> child1;
|
|
28
|
-
private ChildController<?> child2;
|
|
29
|
-
|
|
30
|
-
@Override
|
|
31
|
-
public void beforeEach() {
|
|
32
|
-
uut = new BackButtonHelper();
|
|
33
|
-
Activity activity = newActivity();
|
|
34
|
-
ChildControllersRegistry childRegistry = new ChildControllersRegistry();
|
|
35
|
-
stack = TestUtils.newStackController(activity)
|
|
36
|
-
.setChildRegistry(childRegistry)
|
|
37
|
-
.setBackButtonHelper(uut)
|
|
38
|
-
.build();
|
|
39
|
-
child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
|
|
40
|
-
child2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
|
|
41
|
-
stack.ensureViewIsCreated();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Test
|
|
45
|
-
public void addToChild() {
|
|
46
|
-
uut.addToPushedChild(child1);
|
|
47
|
-
verify(child1).mergeOptions(any());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Test
|
|
51
|
-
public void addToChild_addsIfStackContainsMoreThenOneChild() {
|
|
52
|
-
disablePushAnimation(child1, child2);
|
|
53
|
-
stack.push(child1, new CommandListenerAdapter());
|
|
54
|
-
stack.push(child2, new CommandListenerAdapter());
|
|
55
|
-
|
|
56
|
-
ArgumentCaptor<Options> optionWithBackButton = ArgumentCaptor.forClass(Options.class);
|
|
57
|
-
verify(child2, times(1)).mergeOptions(optionWithBackButton.capture());
|
|
58
|
-
assertThat(optionWithBackButton.getValue().topBar.buttons.back.visible.get()).isTrue();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@Test
|
|
62
|
-
public void addToChild_doesNotAddIfBackButtonHidden() {
|
|
63
|
-
disablePushAnimation(child1, child2);
|
|
64
|
-
stack.push(child1, new CommandListenerAdapter());
|
|
65
|
-
child2.options.topBar.buttons.back.visible = new Bool(false);
|
|
66
|
-
stack.push(child2, new CommandListenerAdapter());
|
|
67
|
-
|
|
68
|
-
verify(child2, times(0)).mergeOptions(any());
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@Test
|
|
72
|
-
public void clear() {
|
|
73
|
-
child1.options.topBar.buttons.back.visible = new Bool(true);
|
|
74
|
-
uut.clear(child1);
|
|
75
|
-
assertThat(child1.options.topBar.buttons.back.visible.get()).isFalse();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.viewcontrollers.stack;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.view.View;
|
|
5
|
-
import android.view.ViewGroup;
|
|
6
|
-
|
|
7
|
-
import com.reactnativenavigation.BaseTest;
|
|
8
|
-
import com.reactnativenavigation.TestUtils;
|
|
9
|
-
import com.reactnativenavigation.mocks.SimpleViewController;
|
|
10
|
-
import com.reactnativenavigation.options.FabOptions;
|
|
11
|
-
import com.reactnativenavigation.options.Options;
|
|
12
|
-
import com.reactnativenavigation.options.params.Text;
|
|
13
|
-
import com.reactnativenavigation.react.CommandListenerAdapter;
|
|
14
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
15
|
-
import com.reactnativenavigation.views.stack.fab.Fab;
|
|
16
|
-
import com.reactnativenavigation.views.stack.fab.FabMenu;
|
|
17
|
-
import com.reactnativenavigation.views.stack.StackLayout;
|
|
18
|
-
|
|
19
|
-
import org.junit.Test;
|
|
20
|
-
|
|
21
|
-
import androidx.annotation.NonNull;
|
|
22
|
-
|
|
23
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
24
|
-
|
|
25
|
-
public class FloatingActionButtonTest extends BaseTest {
|
|
26
|
-
|
|
27
|
-
private final static int CHILD_FAB_COUNT = 3;
|
|
28
|
-
|
|
29
|
-
private StackController stackController;
|
|
30
|
-
private SimpleViewController childFab;
|
|
31
|
-
private SimpleViewController childNoFab;
|
|
32
|
-
private Activity activity;
|
|
33
|
-
private ChildControllersRegistry childRegistry;
|
|
34
|
-
|
|
35
|
-
@Override
|
|
36
|
-
public void beforeEach() {
|
|
37
|
-
super.beforeEach();
|
|
38
|
-
activity = newActivity();
|
|
39
|
-
childRegistry = new ChildControllersRegistry();
|
|
40
|
-
stackController = TestUtils.newStackController(activity)
|
|
41
|
-
.setFabPresenter(createFabPresenter())
|
|
42
|
-
.build();
|
|
43
|
-
stackController.ensureViewIsCreated();
|
|
44
|
-
Options options = getOptionsWithFab();
|
|
45
|
-
childFab = new SimpleViewController(activity, childRegistry, "child1", options);
|
|
46
|
-
childNoFab = new SimpleViewController(activity, childRegistry, "child2", new Options());
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@NonNull
|
|
50
|
-
private Options getOptionsWithFab() {
|
|
51
|
-
Options options = new Options();
|
|
52
|
-
FabOptions fabOptions = new FabOptions();
|
|
53
|
-
fabOptions.id = new Text("FAB");
|
|
54
|
-
options.fabOptions = fabOptions;
|
|
55
|
-
return options;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@NonNull
|
|
59
|
-
private Options getOptionsWithFabActions() {
|
|
60
|
-
Options options = new Options();
|
|
61
|
-
FabOptions fabOptions = new FabOptions();
|
|
62
|
-
fabOptions.id = new Text("FAB");
|
|
63
|
-
for (int i = 0; i < CHILD_FAB_COUNT; i++) {
|
|
64
|
-
FabOptions childOptions = new FabOptions();
|
|
65
|
-
childOptions.id = new Text("fab" + i);
|
|
66
|
-
fabOptions.actionsArray.add(childOptions);
|
|
67
|
-
}
|
|
68
|
-
options.fabOptions = fabOptions;
|
|
69
|
-
return options;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private boolean hasFab() {
|
|
73
|
-
StackLayout stackLayout = stackController.getStackLayout();
|
|
74
|
-
for (int i = 0; i < stackLayout.getChildCount(); i++) {
|
|
75
|
-
if (stackLayout.getChildAt(i) instanceof Fab) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
if (stackLayout.getChildAt(i) instanceof FabMenu) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@Test
|
|
86
|
-
public void showOnPush() {
|
|
87
|
-
stackController.push(childFab, new CommandListenerAdapter());
|
|
88
|
-
childFab.onViewWillAppear();
|
|
89
|
-
assertThat(hasFab()).isTrue();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@Test
|
|
93
|
-
public void hideOnPush() {
|
|
94
|
-
stackController.push(childFab, new CommandListenerAdapter());
|
|
95
|
-
childFab.onViewWillAppear();
|
|
96
|
-
assertThat(hasFab()).isTrue();
|
|
97
|
-
stackController.push(childNoFab, new CommandListenerAdapter());
|
|
98
|
-
childNoFab.onViewWillAppear();
|
|
99
|
-
assertThat(hasFab()).isFalse();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@Test
|
|
103
|
-
public void hideOnPop() {
|
|
104
|
-
disablePushAnimation(childNoFab, childFab);
|
|
105
|
-
stackController.push(childNoFab, new CommandListenerAdapter());
|
|
106
|
-
stackController.push(childFab, new CommandListenerAdapter());
|
|
107
|
-
childFab.onViewWillAppear();
|
|
108
|
-
assertThat(hasFab()).isTrue();
|
|
109
|
-
stackController.pop(Options.EMPTY, new CommandListenerAdapter());
|
|
110
|
-
childNoFab.onViewWillAppear();
|
|
111
|
-
assertThat(hasFab()).isFalse();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
@Test
|
|
115
|
-
public void showOnPop() {
|
|
116
|
-
disablePushAnimation(childFab, childNoFab);
|
|
117
|
-
stackController.push(childFab, new CommandListenerAdapter());
|
|
118
|
-
stackController.push(childNoFab, new CommandListenerAdapter());
|
|
119
|
-
childNoFab.onViewWillAppear();
|
|
120
|
-
assertThat(hasFab()).isFalse();
|
|
121
|
-
stackController.pop(Options.EMPTY, new CommandListenerAdapter());
|
|
122
|
-
childFab.onViewWillAppear();
|
|
123
|
-
assertThat(hasFab()).isTrue();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@Test
|
|
127
|
-
public void hasChildren() {
|
|
128
|
-
childFab = new SimpleViewController(activity, childRegistry, "child1", getOptionsWithFabActions());
|
|
129
|
-
stackController.push(childFab, new CommandListenerAdapter());
|
|
130
|
-
childFab.onViewWillAppear();
|
|
131
|
-
assertThat(hasFab()).isTrue();
|
|
132
|
-
assertThat(containsActions()).isTrue();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private boolean containsActions() {
|
|
136
|
-
StackLayout stackLayout = stackController.getStackLayout();
|
|
137
|
-
for (int i = 0; i < stackLayout.getChildCount(); i++) {
|
|
138
|
-
View child = stackLayout.getChildAt(i);
|
|
139
|
-
if (child instanceof FabMenu) {
|
|
140
|
-
return ((ViewGroup) child).getChildCount() == CHILD_FAB_COUNT + 2;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
private FabPresenter createFabPresenter() {
|
|
147
|
-
return new FabPresenter() {
|
|
148
|
-
@Override
|
|
149
|
-
public void animateHide(Runnable onAnimationEnd) {
|
|
150
|
-
onAnimationEnd.run();
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
}
|