26
26
import com .firebase .ui .auth .test_helpers .TestHelper ;
27
27
import com .firebase .ui .auth .ui .idp .IDPSignInContainerActivity ;
28
28
import com .firebase .ui .auth .util .CredentialsAPI ;
29
+ import com .firebase .ui .auth .util .PlayServicesHelper ;
29
30
import com .google .android .gms .auth .api .credentials .IdentityProviders ;
30
31
import com .google .firebase .FirebaseApp ;
31
32
import com .google .firebase .auth .AuthResult ;
@@ -63,6 +64,8 @@ public class ChooseAccountActivityTest {
63
64
public void setUp () {
64
65
MockitoAnnotations .initMocks (this );
65
66
mFirebaseApp = TestHelper .initializeApp (RuntimeEnvironment .application );
67
+ PlayServicesHelper .sApiAvailability = TestHelper .makeMockGoogleApiAvailability ();
68
+
66
69
when (mCredentialsAPI .isPlayServicesAvailable ()).thenReturn (true );
67
70
when (mCredentialsAPI .isCredentialsAvailable ()).thenReturn (true );
68
71
when (mCredentialsAPI .isAutoSignInAvailable ()).thenReturn (true );
@@ -73,15 +76,17 @@ private Intent createStartIntent() {
73
76
.createSignInIntentBuilder ()
74
77
.setProviders (AuthUI .EMAIL_PROVIDER , AuthUI .GOOGLE_PROVIDER )
75
78
.setIsSmartLockEnabled (true )
76
- .build ();
79
+ .build (RuntimeEnvironment . application );
77
80
}
78
81
79
82
@ Test
80
83
public void testAutoSignInWithSavedUsernameAndPassword_signsIn () {
81
84
Intent startIntent = createStartIntent ();
82
85
ChooseAccountActivity chooseAccountActivity =
83
86
Robolectric .buildActivity (ChooseAccountActivity .class )
84
- .withIntent (createStartIntent ()).create ().get ();
87
+ .withIntent (startIntent )
88
+ .create ()
89
+ .get ();
85
90
86
91
when (mCredentialsAPI .getEmailFromCredential ()).thenReturn (TestConstants .EMAIL );
87
92
when (mCredentialsAPI .getPasswordFromCredential ()).thenReturn (TestConstants .PASSWORD );
@@ -113,7 +118,10 @@ public void testAutoSignInWithSavedIdp_redirectsToIdpSignIn() {
113
118
Intent startIntent = createStartIntent ();
114
119
ChooseAccountActivity chooseAccountActivity =
115
120
Robolectric .buildActivity (ChooseAccountActivity .class )
116
- .withIntent (startIntent ).create ().get ();
121
+ .withIntent (startIntent )
122
+ .create ()
123
+ .get ();
124
+
117
125
when (mCredentialsAPI .getEmailFromCredential ()).thenReturn (TestConstants .EMAIL );
118
126
when (mCredentialsAPI .getPasswordFromCredential ()).thenReturn (null );
119
127
when (mCredentialsAPI .getAccountTypeFromCredential ()).thenReturn (
0 commit comments