use of com.firebase.ui.auth.ui.accountlink.WelcomeBackPasswordPrompt in project FirebaseUI-Android by firebase.
the class WelcomeBackPasswordPromptTest method testSignInButton_validatesFields.
@Test
public void testSignInButton_validatesFields() {
WelcomeBackPasswordPrompt welcomeBack = createActivity();
Button signIn = (Button) welcomeBack.findViewById(R.id.button_done);
signIn.performClick();
TextInputLayout passwordLayout = (TextInputLayout) welcomeBack.findViewById(R.id.password_layout);
assertEquals(welcomeBack.getString(R.string.required_field), passwordLayout.getError().toString());
// should block and not start a new activity
ShadowActivity.IntentForResult nextIntent = Shadows.shadowOf(welcomeBack).getNextStartedActivityForResult();
assertNull(nextIntent);
}
use of com.firebase.ui.auth.ui.accountlink.WelcomeBackPasswordPrompt in project FirebaseUI-Android by firebase.
the class WelcomeBackPasswordPromptTest method testSignInButton_signsInAndSavesCredentials.
@Test
@Config(shadows = { BaseHelperShadow.class, ActivityHelperShadow.class })
public void testSignInButton_signsInAndSavesCredentials() {
// initialize mocks
new ActivityHelperShadow();
reset(ActivityHelperShadow.sSaveSmartLock);
WelcomeBackPasswordPrompt welcomeBackActivity = createActivity();
EditText passwordField = (EditText) welcomeBackActivity.findViewById(R.id.password);
passwordField.setText(TestConstants.PASSWORD);
FirebaseUser mockFirebaseUser = mock(FirebaseUser.class);
when(ActivityHelperShadow.sFirebaseAuth.signInWithEmailAndPassword(TestConstants.EMAIL, TestConstants.PASSWORD)).thenReturn(new AutoCompleteTask<AuthResult>(new FakeAuthResult(mockFirebaseUser), true, null));
when(mockFirebaseUser.getDisplayName()).thenReturn(TestConstants.NAME);
when(mockFirebaseUser.getEmail()).thenReturn(TestConstants.EMAIL);
when(mockFirebaseUser.getPhotoUrl()).thenReturn(TestConstants.PHOTO_URI);
Button signIn = (Button) welcomeBackActivity.findViewById(R.id.button_done);
signIn.performClick();
verify(ActivityHelperShadow.sFirebaseAuth).signInWithEmailAndPassword(TestConstants.EMAIL, TestConstants.PASSWORD);
verifySmartLockSave(EmailAuthProvider.PROVIDER_ID, TestConstants.EMAIL, TestConstants.PASSWORD);
}
Aggregations