|
@@ -87,16 +87,9 @@ public class ModalStackTest extends BaseTest {
|
87
|
87
|
public void dismissModal() {
|
88
|
88
|
uut.showModal(modal1, rootController, new CommandListenerAdapter());
|
89
|
89
|
CommandListener listener = new CommandListenerAdapter();
|
90
|
|
- Runnable onModalWillDismiss = spy(new Runnable() {
|
91
|
|
- @Override
|
92
|
|
- public void run() {
|
93
|
|
- assertThat(modal1.getView().getParent()).isNotNull();
|
94
|
|
- }
|
95
|
|
- });
|
96
|
|
- uut.dismissModal(modal1.getId(), onModalWillDismiss, listener);
|
|
90
|
+ uut.dismissModal(modal1.getId(), rootController, listener);
|
97
|
91
|
assertThat(findModal(modal1.getId())).isNull();
|
98
|
|
- verify(onModalWillDismiss, times(1)).run();
|
99
|
|
- verify(presenter, times(1)).dismissModal(modal1, null, listener);
|
|
92
|
+ verify(presenter, times(1)).dismissModal(modal1, rootController, listener);
|
100
|
93
|
}
|
101
|
94
|
|
102
|
95
|
@SuppressWarnings("Convert2Lambda")
|
|
@@ -109,7 +102,7 @@ public class ModalStackTest extends BaseTest {
|
109
|
102
|
|
110
|
103
|
}
|
111
|
104
|
});
|
112
|
|
- uut.dismissModal(MODAL_ID_1, onModalWillDismiss, listener);
|
|
105
|
+ uut.dismissModal(MODAL_ID_1, rootController, listener);
|
113
|
106
|
verify(onModalWillDismiss, times(0)).run();
|
114
|
107
|
verify(listener, times(1)).onError(anyString());
|
115
|
108
|
verifyZeroInteractions(listener);
|
|
@@ -127,7 +120,7 @@ public class ModalStackTest extends BaseTest {
|
127
|
120
|
assertThat(uut.isEmpty()).isTrue();
|
128
|
121
|
}
|
129
|
122
|
});
|
130
|
|
- uut.dismissAllModals(listener, () -> {});
|
|
123
|
+ uut.dismissAllModals(listener, rootController);
|
131
|
124
|
verify(listener, times(1)).onSuccess(anyString());
|
132
|
125
|
verifyZeroInteractions(listener);
|
133
|
126
|
}
|
|
@@ -135,7 +128,7 @@ public class ModalStackTest extends BaseTest {
|
135
|
128
|
@Test
|
136
|
129
|
public void dismissAllModals_rejectIfEmpty() {
|
137
|
130
|
CommandListener spy = spy(new CommandListenerAdapter());
|
138
|
|
- uut.dismissAllModals(spy, () -> {});
|
|
131
|
+ uut.dismissAllModals(spy, rootController);
|
139
|
132
|
verify(spy, times(1)).onError(any());
|
140
|
133
|
}
|
141
|
134
|
|
|
@@ -148,15 +141,8 @@ public class ModalStackTest extends BaseTest {
|
148
|
141
|
ViewGroup view1 = modal1.getView();
|
149
|
142
|
ViewGroup view2 = modal2.getView();
|
150
|
143
|
CommandListener listener = spy(new CommandListenerAdapter());
|
151
|
|
- Runnable onModalWillDismiss = spy(new Runnable() {
|
152
|
|
- @Override
|
153
|
|
- public void run() {
|
154
|
|
-
|
155
|
|
- }
|
156
|
|
- });
|
157
|
|
- uut.dismissAllModals(listener, onModalWillDismiss);
|
158
|
|
- verify(onModalWillDismiss, times(1)).run();
|
159
|
|
- verify(presenter, times(1)).dismissModal(modal2, null, listener);
|
|
144
|
+ uut.dismissAllModals(listener, rootController);
|
|
145
|
+ verify(presenter, times(1)).dismissModal(modal2, rootController, listener);
|
160
|
146
|
verify(animator, times(0)).dismiss(eq(view1), any());
|
161
|
147
|
verify(animator, times(1)).dismiss(eq(view2), any());
|
162
|
148
|
assertThat(uut.size()).isEqualTo(0);
|
|
@@ -167,7 +153,7 @@ public class ModalStackTest extends BaseTest {
|
167
|
153
|
uut.showModal(modal1, rootController, new CommandListenerAdapter());
|
168
|
154
|
uut.showModal(modal2, rootController, new CommandListenerAdapter());
|
169
|
155
|
|
170
|
|
- uut.dismissAllModals(new CommandListenerAdapter(), () -> {});
|
|
156
|
+ uut.dismissAllModals(new CommandListenerAdapter(), rootController);
|
171
|
157
|
|
172
|
158
|
verify(modal1, times(1)).destroy();
|
173
|
159
|
verify(modal1, times(1)).onViewDisappear();
|
|
@@ -179,7 +165,7 @@ public class ModalStackTest extends BaseTest {
|
179
|
165
|
assertThat(uut.isEmpty()).isTrue();
|
180
|
166
|
uut.showModal(modal1, rootController, new CommandListenerAdapter());
|
181
|
167
|
assertThat(uut.isEmpty()).isFalse();
|
182
|
|
- uut.dismissAllModals(new CommandListenerAdapter(), () -> {});
|
|
168
|
+ uut.dismissAllModals(new CommandListenerAdapter(), rootController);
|
183
|
169
|
assertThat(uut.isEmpty()).isTrue();
|
184
|
170
|
}
|
185
|
171
|
|
|
@@ -201,7 +187,7 @@ public class ModalStackTest extends BaseTest {
|
201
|
187
|
|
202
|
188
|
uut.showModal(modal1, rootController, new CommandListenerAdapter());
|
203
|
189
|
uut.showModal(modal2, rootController, new CommandListenerAdapter());
|
204
|
|
- uut.dismissModal(modal2.getId(), () -> {}, new CommandListenerAdapter());
|
|
190
|
+ uut.dismissModal(modal2.getId(), rootController, new CommandListenerAdapter());
|
205
|
191
|
verify(modal1, times(2)).onViewAppeared();
|
206
|
192
|
}
|
207
|
193
|
|
|
@@ -214,7 +200,7 @@ public class ModalStackTest extends BaseTest {
|
214
|
200
|
uut.showModal(modal2, rootController, new CommandListenerAdapter());
|
215
|
201
|
uut.showModal(modal3, rootController, new CommandListenerAdapter());
|
216
|
202
|
|
217
|
|
- uut.dismissModal(modal2.getId(), () -> {}, new CommandListenerAdapter());
|
|
203
|
+ uut.dismissModal(modal2.getId(), rootController, new CommandListenerAdapter());
|
218
|
204
|
assertThat(uut.size()).isEqualTo(2);
|
219
|
205
|
verify(modal2, times(1)).onViewDisappear();
|
220
|
206
|
verify(modal2, times(1)).destroy();
|
|
@@ -224,14 +210,14 @@ public class ModalStackTest extends BaseTest {
|
224
|
210
|
@Test
|
225
|
211
|
public void handleBack_doesNothingIfModalStackIsEmpty() {
|
226
|
212
|
assertThat(uut.isEmpty()).isTrue();
|
227
|
|
- assertThat(uut.handleBack(new CommandListenerAdapter(), () -> {})).isFalse();
|
|
213
|
+ assertThat(uut.handleBack(new CommandListenerAdapter(), rootController)).isFalse();
|
228
|
214
|
}
|
229
|
215
|
|
230
|
216
|
@Test
|
231
|
217
|
public void handleBack_dismissModal() {
|
232
|
218
|
disableDismissModalAnimation(modal1);
|
233
|
219
|
uut.showModal(modal1, rootController, new CommandListenerAdapter());
|
234
|
|
- assertThat(uut.handleBack(new CommandListenerAdapter(), () -> {})).isTrue();
|
|
220
|
+ assertThat(uut.handleBack(new CommandListenerAdapter(), rootController)).isTrue();
|
235
|
221
|
verify(modal1, times(1)).onViewDisappear();
|
236
|
222
|
|
237
|
223
|
}
|