Search in sources :

Example 1 with SaveSmartLock

use of com.firebase.ui.auth.util.signincontainer.SaveSmartLock in project FirebaseUI-Android by firebase.

the class CredentialSignInHandlerTest method testSignInSucceeded.

@Test
public void testSignInSucceeded() {
    AppCompatBase mockActivity = mock(AppCompatBase.class);
    ActivityHelper mockActivityHelper = mock(ActivityHelper.class);
    FirebaseUser mockFirebaseUser = TestHelper.makeMockFirebaseUser();
    IdpResponse idpResponse = new IdpResponse(GoogleAuthProvider.PROVIDER_ID, TestConstants.EMAIL);
    SaveSmartLock smartLock = mock(SaveSmartLock.class);
    CredentialSignInHandler credentialSignInHandler = new CredentialSignInHandler(mockActivity, mockActivityHelper, smartLock, RC_ACCOUNT_LINK, idpResponse);
    Task signInTask = Tasks.forResult(new FakeAuthResult(mockFirebaseUser));
    when(mockActivityHelper.getFlowParams()).thenReturn(TestHelper.getFlowParameters(Collections.<String>emptyList()));
    credentialSignInHandler.onComplete(signInTask);
    ArgumentCaptor<SaveSmartLock> smartLockCaptor = ArgumentCaptor.forClass(SaveSmartLock.class);
    ArgumentCaptor<Activity> activityCaptor = ArgumentCaptor.forClass(Activity.class);
    ArgumentCaptor<FirebaseUser> firebaseUserCaptor = ArgumentCaptor.forClass(FirebaseUser.class);
    ArgumentCaptor<IdpResponse> idpResponseCaptor = ArgumentCaptor.forClass(IdpResponse.class);
    verify(mockActivityHelper).saveCredentialsOrFinish(smartLockCaptor.capture(), activityCaptor.capture(), firebaseUserCaptor.capture(), idpResponseCaptor.capture());
    assertEquals(smartLock, smartLockCaptor.getValue());
    assertEquals(mockActivity, activityCaptor.getValue());
    assertEquals(mockFirebaseUser, firebaseUserCaptor.getValue());
    assertEquals(idpResponse.getProviderType(), idpResponseCaptor.getValue().getProviderType());
    assertEquals(idpResponse.getEmail(), idpResponseCaptor.getValue().getEmail());
    assertEquals(idpResponse.getIdpToken(), idpResponseCaptor.getValue().getIdpToken());
    assertEquals(idpResponse.getIdpSecret(), idpResponseCaptor.getValue().getIdpSecret());
}
Also used : Task(com.google.android.gms.tasks.Task) AutoCompleteTask(com.firebase.ui.auth.testhelpers.AutoCompleteTask) AppCompatBase(com.firebase.ui.auth.ui.AppCompatBase) Activity(android.app.Activity) FirebaseUser(com.google.firebase.auth.FirebaseUser) FakeAuthResult(com.firebase.ui.auth.testhelpers.FakeAuthResult) ActivityHelper(com.firebase.ui.auth.ui.ActivityHelper) SaveSmartLock(com.firebase.ui.auth.util.signincontainer.SaveSmartLock) IdpResponse(com.firebase.ui.auth.IdpResponse) Test(org.junit.Test)

Aggregations

Activity (android.app.Activity)1 IdpResponse (com.firebase.ui.auth.IdpResponse)1 AutoCompleteTask (com.firebase.ui.auth.testhelpers.AutoCompleteTask)1 FakeAuthResult (com.firebase.ui.auth.testhelpers.FakeAuthResult)1 ActivityHelper (com.firebase.ui.auth.ui.ActivityHelper)1 AppCompatBase (com.firebase.ui.auth.ui.AppCompatBase)1 SaveSmartLock (com.firebase.ui.auth.util.signincontainer.SaveSmartLock)1 Task (com.google.android.gms.tasks.Task)1 FirebaseUser (com.google.firebase.auth.FirebaseUser)1 Test (org.junit.Test)1