|
@@ -72,19 +72,35 @@ public class ModalStackTest2 extends BaseTest {
|
72
|
72
|
assertThat(findModal(MODAL_ID_1)).isNotNull();
|
73
|
73
|
}
|
74
|
74
|
|
|
75
|
+ @SuppressWarnings("Convert2Lambda")
|
75
|
76
|
@Test
|
76
|
77
|
public void dismissModal() {
|
77
|
78
|
uut.showModal(modal1, new CommandListenerAdapter());
|
78
|
79
|
CommandListener listener = new CommandListenerAdapter();
|
79
|
|
- uut.dismissModal(modal1.getId(), listener);
|
|
80
|
+ Runnable onModalWillDismiss = spy(new Runnable() {
|
|
81
|
+ @Override
|
|
82
|
+ public void run() {
|
|
83
|
+ assertThat(modal1.getView().getParent()).isNotNull();
|
|
84
|
+ }
|
|
85
|
+ });
|
|
86
|
+ uut.dismissModal(modal1.getId(), onModalWillDismiss, listener);
|
80
|
87
|
assertThat(findModal(modal1.getId())).isNull();
|
|
88
|
+ verify(onModalWillDismiss, times(1)).run();
|
81
|
89
|
verify(presenter, times(1)).dismissModal(modal1, null, listener);
|
82
|
90
|
}
|
83
|
91
|
|
|
92
|
+ @SuppressWarnings("Convert2Lambda")
|
84
|
93
|
@Test
|
85
|
94
|
public void dismissModal_rejectIfModalNotFound() {
|
86
|
95
|
CommandListener listener = spy(new CommandListenerAdapter());
|
87
|
|
- uut.dismissModal(MODAL_ID_1, listener);
|
|
96
|
+ Runnable onModalWillDismiss = spy(new Runnable() {
|
|
97
|
+ @Override
|
|
98
|
+ public void run() {
|
|
99
|
+
|
|
100
|
+ }
|
|
101
|
+ });
|
|
102
|
+ uut.dismissModal(MODAL_ID_1, onModalWillDismiss, listener);
|
|
103
|
+ verify(onModalWillDismiss, times(0)).run();
|
88
|
104
|
verify(listener, times(1)).onError(anyString());
|
89
|
105
|
verifyZeroInteractions(listener);
|
90
|
106
|
}
|
|
@@ -101,7 +117,7 @@ public class ModalStackTest2 extends BaseTest {
|
101
|
117
|
assertThat(uut.isEmpty()).isTrue();
|
102
|
118
|
}
|
103
|
119
|
});
|
104
|
|
- uut.dismissAllModals(listener);
|
|
120
|
+ uut.dismissAllModals(listener, () -> {});
|
105
|
121
|
verify(listener, times(1)).onSuccess(anyString());
|
106
|
122
|
verifyZeroInteractions(listener);
|
107
|
123
|
}
|
|
@@ -109,10 +125,11 @@ public class ModalStackTest2 extends BaseTest {
|
109
|
125
|
@Test
|
110
|
126
|
public void dismissAllModals_rejectIfEmpty() {
|
111
|
127
|
CommandListener spy = spy(new CommandListenerAdapter());
|
112
|
|
- uut.dismissAllModals(spy);
|
|
128
|
+ uut.dismissAllModals(spy, () -> {});
|
113
|
129
|
verify(spy, times(1)).onError(any());
|
114
|
130
|
}
|
115
|
131
|
|
|
132
|
+ @SuppressWarnings("Convert2Lambda")
|
116
|
133
|
@Test
|
117
|
134
|
public void dismissAllModals_onlyTopModalIsAnimated() {
|
118
|
135
|
uut.showModal(modal1, new CommandListenerAdapter());
|
|
@@ -121,8 +138,14 @@ public class ModalStackTest2 extends BaseTest {
|
121
|
138
|
ViewGroup view1 = modal1.getView();
|
122
|
139
|
ViewGroup view2 = modal2.getView();
|
123
|
140
|
CommandListener listener = spy(new CommandListenerAdapter());
|
124
|
|
- uut.dismissAllModals(listener);
|
|
141
|
+ Runnable onModalWillDismiss = spy(new Runnable() {
|
|
142
|
+ @Override
|
|
143
|
+ public void run() {
|
125
|
144
|
|
|
145
|
+ }
|
|
146
|
+ });
|
|
147
|
+ uut.dismissAllModals(listener, onModalWillDismiss);
|
|
148
|
+ verify(onModalWillDismiss, times(1)).run();
|
126
|
149
|
verify(presenter, times(1)).dismissModal(modal2, null, listener);
|
127
|
150
|
verify(animator, times(0)).dismiss(eq(view1), any());
|
128
|
151
|
verify(animator, times(1)).dismiss(eq(view2), any());
|
|
@@ -134,7 +157,7 @@ public class ModalStackTest2 extends BaseTest {
|
134
|
157
|
uut.showModal(modal1, new CommandListenerAdapter());
|
135
|
158
|
uut.showModal(modal2, new CommandListenerAdapter());
|
136
|
159
|
|
137
|
|
- uut.dismissAllModals(new CommandListenerAdapter());
|
|
160
|
+ uut.dismissAllModals(new CommandListenerAdapter(), () -> {});
|
138
|
161
|
|
139
|
162
|
verify(modal1, times(1)).destroy();
|
140
|
163
|
verify(modal1, times(1)).onViewDisappear();
|
|
@@ -146,7 +169,7 @@ public class ModalStackTest2 extends BaseTest {
|
146
|
169
|
assertThat(uut.isEmpty()).isTrue();
|
147
|
170
|
uut.showModal(modal1, new CommandListenerAdapter());
|
148
|
171
|
assertThat(uut.isEmpty()).isFalse();
|
149
|
|
- uut.dismissAllModals(new CommandListenerAdapter());
|
|
172
|
+ uut.dismissAllModals(new CommandListenerAdapter(), () -> {});
|
150
|
173
|
assertThat(uut.isEmpty()).isTrue();
|
151
|
174
|
}
|
152
|
175
|
|
|
@@ -168,7 +191,7 @@ public class ModalStackTest2 extends BaseTest {
|
168
|
191
|
|
169
|
192
|
uut.showModal(modal1, new CommandListenerAdapter());
|
170
|
193
|
uut.showModal(modal2, new CommandListenerAdapter());
|
171
|
|
- uut.dismissModal(modal2.getId(), new CommandListenerAdapter());
|
|
194
|
+ uut.dismissModal(modal2.getId(), () -> {}, new CommandListenerAdapter());
|
172
|
195
|
verify(modal1, times(2)).onViewAppeared();
|
173
|
196
|
}
|
174
|
197
|
|
|
@@ -181,7 +204,7 @@ public class ModalStackTest2 extends BaseTest {
|
181
|
204
|
uut.showModal(modal2, new CommandListenerAdapter());
|
182
|
205
|
uut.showModal(modal3, new CommandListenerAdapter());
|
183
|
206
|
|
184
|
|
- uut.dismissModal(modal2.getId(), new CommandListenerAdapter());
|
|
207
|
+ uut.dismissModal(modal2.getId(), () -> {}, new CommandListenerAdapter());
|
185
|
208
|
assertThat(uut.size()).isEqualTo(2);
|
186
|
209
|
verify(modal2, times(1)).onViewDisappear();
|
187
|
210
|
verify(modal2, times(1)).destroy();
|