|
@@ -2,9 +2,9 @@ package com.reactnativenavigation.viewcontrollers.sidemenu;
|
2
|
2
|
|
3
|
3
|
import android.app.Activity;
|
4
|
4
|
import android.content.res.Resources;
|
5
|
|
-import android.view.ViewGroup.LayoutParams;
|
6
|
5
|
import android.util.TypedValue;
|
7
|
6
|
import android.view.Gravity;
|
|
7
|
+import android.view.ViewGroup.LayoutParams;
|
8
|
8
|
|
9
|
9
|
import com.reactnativenavigation.BaseTest;
|
10
|
10
|
import com.reactnativenavigation.mocks.SimpleComponentViewController;
|
|
@@ -21,7 +21,9 @@ import org.junit.Test;
|
21
|
21
|
|
22
|
22
|
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
23
|
23
|
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
24
|
+import static org.mockito.ArgumentMatchers.any;
|
24
|
25
|
import static org.mockito.Mockito.spy;
|
|
26
|
+import static org.mockito.Mockito.times;
|
25
|
27
|
import static org.mockito.Mockito.verify;
|
26
|
28
|
|
27
|
29
|
@SuppressWarnings("MagicNumber")
|
|
@@ -30,13 +32,20 @@ public class SideMenuControllerTest extends BaseTest {
|
30
|
32
|
private Activity activity;
|
31
|
33
|
private ChildControllersRegistry childRegistry;
|
32
|
34
|
private SideMenuOptionsPresenter presenter;
|
|
35
|
+ private SimpleComponentViewController left;
|
|
36
|
+ private SimpleComponentViewController right;
|
|
37
|
+ private SimpleComponentViewController center;
|
33
|
38
|
|
34
|
39
|
@Override
|
35
|
40
|
public void beforeEach() {
|
36
|
41
|
activity = newActivity();
|
37
|
42
|
childRegistry = new ChildControllersRegistry();
|
38
|
43
|
presenter = spy(new SideMenuOptionsPresenter());
|
|
44
|
+ left = new SimpleComponentViewController(activity, childRegistry, "left", new Options());
|
|
45
|
+ right = new SimpleComponentViewController(activity, childRegistry, "right", new Options());
|
|
46
|
+ center = spy(new SimpleComponentViewController(activity, childRegistry, "center", new Options()));
|
39
|
47
|
uut = new SideMenuController(activity, childRegistry, "sideMenu", new Options(), presenter, new OptionsPresenter(activity, new Options()));
|
|
48
|
+ uut.setCenterController(center);
|
40
|
49
|
}
|
41
|
50
|
|
42
|
51
|
@Test
|
|
@@ -140,19 +149,23 @@ public class SideMenuControllerTest extends BaseTest {
|
140
|
149
|
|
141
|
150
|
@Test
|
142
|
151
|
public void handleBack_closesLeftMenu() {
|
143
|
|
- uut.setLeftController(new SimpleComponentViewController(activity, childRegistry, "left", new Options()));
|
|
152
|
+ uut.setLeftController(left);
|
144
|
153
|
assertThat(uut.handleBack(new CommandListenerAdapter())).isFalse();
|
|
154
|
+ verify(center, times(1)).handleBack(any());
|
145
|
155
|
|
146
|
156
|
uut.mergeOptions(SideMenuTestHelper.LEFT_OPEN);
|
147
|
157
|
assertThat(uut.handleBack(new CommandListenerAdapter())).isTrue();
|
|
158
|
+ verify(center, times(1)).handleBack(any());
|
148
|
159
|
}
|
149
|
160
|
|
150
|
161
|
@Test
|
151
|
162
|
public void handleBack_closesRightMenu() {
|
152
|
|
- uut.setRightController(new SimpleComponentViewController(activity, childRegistry, "right", new Options()));
|
|
163
|
+ uut.setRightController(right);
|
153
|
164
|
assertThat(uut.handleBack(new CommandListenerAdapter())).isFalse();
|
|
165
|
+ verify(center, times(1)).handleBack(any());
|
154
|
166
|
|
155
|
167
|
uut.mergeOptions(SideMenuTestHelper.RIGHT_OPEN);
|
156
|
168
|
assertThat(uut.handleBack(new CommandListenerAdapter())).isTrue();
|
|
169
|
+ verify(center, times(1)).handleBack(any());
|
157
|
170
|
}
|
158
|
171
|
}
|