|
@@ -4,7 +4,7 @@ import android.app.Activity;
|
4
|
4
|
import android.view.ViewGroup;
|
5
|
5
|
import android.widget.FrameLayout;
|
6
|
6
|
|
7
|
|
-import com.reactnativenavigation.BaseTest;
|
|
7
|
+import com.reactnativenavigation.*;
|
8
|
8
|
import com.reactnativenavigation.anim.ModalAnimator;
|
9
|
9
|
import com.reactnativenavigation.mocks.SimpleViewController;
|
10
|
10
|
import com.reactnativenavigation.parse.Options;
|
|
@@ -13,6 +13,7 @@ import com.reactnativenavigation.utils.CommandListener;
|
13
|
13
|
import com.reactnativenavigation.utils.CommandListenerAdapter;
|
14
|
14
|
import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
|
15
|
15
|
import com.reactnativenavigation.viewcontrollers.ViewController;
|
|
16
|
+import com.reactnativenavigation.viewcontrollers.stack.*;
|
16
|
17
|
|
17
|
18
|
import org.junit.Test;
|
18
|
19
|
import org.mockito.Mockito;
|
|
@@ -34,16 +35,20 @@ public class ModalStackTest extends BaseTest {
|
34
|
35
|
private static final String MODAL_ID_1 = "modalId1";
|
35
|
36
|
private static final String MODAL_ID_2 = "modalId2";
|
36
|
37
|
private static final String MODAL_ID_3 = "modalId3";
|
|
38
|
+ private static final String MODAL_ID_4 = "modalId4";
|
37
|
39
|
|
38
|
40
|
private ModalStack uut;
|
39
|
41
|
private ViewController modal1;
|
40
|
42
|
private ViewController modal2;
|
41
|
43
|
private ViewController modal3;
|
|
44
|
+ private ViewController modal4;
|
|
45
|
+ private StackController stack;
|
42
|
46
|
private Activity activity;
|
43
|
47
|
private ChildControllersRegistry childRegistry;
|
44
|
48
|
private ModalPresenter presenter;
|
45
|
49
|
private ModalAnimator animator;
|
46
|
50
|
private ViewController root;
|
|
51
|
+ private EventEmitter emitter;
|
47
|
52
|
|
48
|
53
|
@Override
|
49
|
54
|
public void beforeEach() {
|
|
@@ -63,10 +68,15 @@ public class ModalStackTest extends BaseTest {
|
63
|
68
|
uut = new ModalStack(presenter);
|
64
|
69
|
uut.setModalsLayout(modalsLayout);
|
65
|
70
|
uut.setRootLayout(rootLayout);
|
66
|
|
- uut.setEventEmitter(Mockito.mock(EventEmitter.class));
|
|
71
|
+ emitter = Mockito.mock(EventEmitter.class);
|
|
72
|
+ uut.setEventEmitter(emitter);
|
67
|
73
|
modal1 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_1, new Options()));
|
68
|
74
|
modal2 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_2, new Options()));
|
69
|
75
|
modal3 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_3, new Options()));
|
|
76
|
+ modal4 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_4, new Options()));
|
|
77
|
+ stack = TestUtils.newStackController(activity)
|
|
78
|
+ .setChildren(modal4)
|
|
79
|
+ .build();
|
70
|
80
|
}
|
71
|
81
|
|
72
|
82
|
@Test
|
|
@@ -99,6 +109,15 @@ public class ModalStackTest extends BaseTest {
|
99
|
109
|
verify(listener).onSuccess(modal1.getId());
|
100
|
110
|
}
|
101
|
111
|
|
|
112
|
+ @Test
|
|
113
|
+ public void dismissModal_listenerAndEmitterAreInvokedWithGivenId() {
|
|
114
|
+ uut.showModal(stack, root, new CommandListenerAdapter());
|
|
115
|
+ CommandListener listener = spy(new CommandListenerAdapter());
|
|
116
|
+ uut.dismissModal(modal4.getId(), root, listener);
|
|
117
|
+ verify(listener).onSuccess(modal4.getId());
|
|
118
|
+ verify(emitter).emitModalDismissed(modal4.getId(), 1);
|
|
119
|
+ }
|
|
120
|
+
|
102
|
121
|
@SuppressWarnings("Convert2Lambda")
|
103
|
122
|
@Test
|
104
|
123
|
public void dismissModal_rejectIfModalNotFound() {
|