2
2
3
3
import android .app .Activity ;
4
4
import android .app .Application ;
5
+ import android .os .Looper ;
5
6
6
7
import com .firebase .ui .auth .AuthUI ;
7
8
import com .firebase .ui .auth .ErrorCodes ;
38
39
import org .mockito .Mock ;
39
40
import org .mockito .MockitoAnnotations ;
40
41
import org .robolectric .RobolectricTestRunner ;
42
+ import org .robolectric .annotation .LooperMode ;
41
43
42
44
import java .util .Arrays ;
43
45
import java .util .Collections ;
51
53
import static org .mockito .Mockito .inOrder ;
52
54
import static org .mockito .Mockito .verify ;
53
55
import static org .mockito .Mockito .when ;
56
+ import static org .robolectric .Shadows .shadowOf ;
54
57
55
58
/**
56
59
* Unit tests for {@link CredentialManagerHandler}.
57
60
*/
58
61
@ RunWith (RobolectricTestRunner .class )
62
+ @ LooperMode (LooperMode .Mode .PAUSED )
59
63
public class SocialProviderResponseHandlerTest {
60
64
@ Mock FirebaseAuth mMockAuth ;
61
65
@ Mock FirebaseUser mUser ;
@@ -87,6 +91,7 @@ public void testSignInIdp_success() {
87
91
.build ();
88
92
89
93
mHandler .startSignIn (response );
94
+ shadowOf (Looper .getMainLooper ()).idle ();
90
95
91
96
verify (mMockAuth ).signInWithCredential (any (AuthCredential .class ));
92
97
@@ -132,6 +137,7 @@ public void testSignInIdp_disabled() {
132
137
.setToken (TestConstants .TOKEN )
133
138
.build ();
134
139
mHandler .startSignIn (response );
140
+ shadowOf (Looper .getMainLooper ()).idle ();
135
141
136
142
verify (mResultObserver ).onChanged (
137
143
argThat (ResourceMatchers .isFailureWithCode (ErrorCodes .ERROR_USER_DISABLED )));
@@ -155,6 +161,7 @@ public void testSignInIdp_resolution() {
155
161
.build ();
156
162
157
163
mHandler .startSignIn (response );
164
+ shadowOf (Looper .getMainLooper ()).idle ();
158
165
159
166
verify (mMockAuth ).signInWithCredential (any (AuthCredential .class ));
160
167
verify (mMockAuth ).fetchSignInMethodsForEmail (any (String .class ));
@@ -192,6 +199,7 @@ public void testSignInIdp_anonymousUserUpgradeEnabledAndNewUser_expectSuccess()
192
199
.build ();
193
200
194
201
mHandler .startSignIn (response );
202
+ shadowOf (Looper .getMainLooper ()).idle ();
195
203
196
204
verify (mMockAuth .getCurrentUser ()).linkWithCredential (any (AuthCredential .class ));
197
205
@@ -225,6 +233,7 @@ public void testSignInIdp_anonymousUserUpgradeEnabledAndExistingUserWithSameIdp_
225
233
.build ();
226
234
227
235
mHandler .startSignIn (response );
236
+ shadowOf (Looper .getMainLooper ()).idle ();
228
237
229
238
verify (mMockAuth .getCurrentUser ()).linkWithCredential (any (AuthCredential .class ));
230
239
@@ -264,6 +273,7 @@ public void testSignInIdp_anonymousUserUpgradeEnabledAndExistingIdpUserWithDiffe
264
273
.build ();
265
274
266
275
mHandler .startSignIn (response );
276
+ shadowOf (Looper .getMainLooper ()).idle ();
267
277
268
278
verify (mMockAuth .getCurrentUser ()).linkWithCredential (any (AuthCredential .class ));
269
279
@@ -308,6 +318,7 @@ public void testSignInIdp_anonymousUserUpgradeEnabledAndExistingPasswordUserWith
308
318
.build ();
309
319
310
320
mHandler .startSignIn (response );
321
+ shadowOf (Looper .getMainLooper ()).idle ();
311
322
312
323
verify (mMockAuth .getCurrentUser ()).linkWithCredential (any (AuthCredential .class ));
313
324
0 commit comments