Search in sources :

Example 16 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class AuthUITest method testCreatingStartIntent.

@Test
public void testCreatingStartIntent() {
    FlowParameters flowParameters = mAuthUi.createSignInIntentBuilder().setAvailableProviders(Arrays.asList(new IdpConfig.EmailBuilder().build(), new IdpConfig.GoogleBuilder().build(), new IdpConfig.FacebookBuilder().build(), new IdpConfig.AnonymousBuilder().build())).setTosAndPrivacyPolicyUrls(TestConstants.TOS_URL, TestConstants.PRIVACY_URL).build().getParcelableExtra(ExtraConstants.FLOW_PARAMS);
    assertEquals(4, flowParameters.providers.size());
    assertEquals(TestHelper.MOCK_APP.getName(), flowParameters.appName);
    assertEquals(TestConstants.TOS_URL, flowParameters.termsOfServiceUrl);
    assertEquals(TestConstants.PRIVACY_URL, flowParameters.privacyPolicyUrl);
    assertEquals(AuthUI.getDefaultTheme(), flowParameters.themeId);
    assertTrue(flowParameters.shouldShowProviderChoice());
    assertEquals(new IdpConfig.EmailBuilder().build(), flowParameters.getDefaultOrFirstProvider());
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) Test(org.junit.Test)

Example 17 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class AuthUITest method testCustomAuthMethodPickerLayout.

@Test
public void testCustomAuthMethodPickerLayout() {
    // Testing with some random layout res
    AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout.Builder(R.layout.fui_phone_layout).setAnonymousButtonId(123).build();
    FlowParameters flowParameters = mAuthUi.createSignInIntentBuilder().setAuthMethodPickerLayout(customLayout).build().getParcelableExtra(ExtraConstants.FLOW_PARAMS);
    assert flowParameters.authMethodPickerLayout != null;
    assertEquals(customLayout.getMainLayout(), flowParameters.authMethodPickerLayout.getMainLayout());
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) SignInIntentBuilder(com.firebase.ui.auth.AuthUI.SignInIntentBuilder) Test(org.junit.Test)

Example 18 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class EmailLinkSignInHandlerTest method setupAnonymousUpgrade.

private void setupAnonymousUpgrade() {
    // enableAnonymousUpgrade must be set to true
    FlowParameters testParams = TestHelper.getFlowParameters(Collections.singletonList(EmailAuthProvider.PROVIDER_ID), /* enableAnonymousUpgrade */
    true);
    testParams.emailLink = mHandler.getArguments().emailLink;
    mHandler.initializeForTesting(testParams, mMockAuth, null);
    // Mock isAnonymous() to return true so canUpgradeAnonymous will return true
    when(mMockAnonUser.isAnonymous()).thenReturn(true);
    when(mMockAuth.getCurrentUser()).thenReturn(mMockAnonUser);
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters)

Example 19 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class PhoneProviderResponseHandlerTest method setUp.

@Before
public void setUp() {
    TestHelper.initialize();
    MockitoAnnotations.initMocks(this);
    mCredential = PhoneAuthCredential.zzc("sessionInfo", "SmsCode");
    mHandler = new PhoneProviderResponseHandler((Application) ApplicationProvider.getApplicationContext());
    FlowParameters testParams = TestHelper.getFlowParameters(Collections.singletonList(PhoneAuthProvider.PROVIDER_ID));
    mHandler.initializeForTesting(testParams, mMockAuth, null);
}
Also used : PhoneProviderResponseHandler(com.firebase.ui.auth.viewmodel.phone.PhoneProviderResponseHandler) FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) Application(android.app.Application) Before(org.junit.Before)

Example 20 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class AuthUITest method testCreateStartIntent_shouldHaveEmailAsDefaultProvider.

@Test
public void testCreateStartIntent_shouldHaveEmailAsDefaultProvider() {
    FlowParameters flowParameters = mAuthUi.createSignInIntentBuilder().build().getParcelableExtra(ExtraConstants.FLOW_PARAMS);
    assertEquals(1, flowParameters.providers.size());
    assertEquals(EmailAuthProvider.PROVIDER_ID, flowParameters.providers.get(0).getProviderId());
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) Test(org.junit.Test)

Aggregations

FlowParameters (com.firebase.ui.auth.data.model.FlowParameters)27 Before (org.junit.Before)10 Application (android.app.Application)9 Test (org.junit.Test)4 AuthUI (com.firebase.ui.auth.AuthUI)3 OAuthProvider (com.google.firebase.auth.OAuthProvider)3 HashMap (java.util.HashMap)3 TextView (android.widget.TextView)2 FirebaseAuthAnonymousUpgradeException (com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException)2 FirebaseUiException (com.firebase.ui.auth.FirebaseUiException)2 IdpResponse (com.firebase.ui.auth.IdpResponse)2 UserCancellationException (com.firebase.ui.auth.data.model.UserCancellationException)2 SocialProviderResponseHandler (com.firebase.ui.auth.viewmodel.idp.SocialProviderResponseHandler)2 Intent (android.content.Intent)1 ImageView (android.widget.ImageView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 RestrictTo (androidx.annotation.RestrictTo)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 ConstraintLayout (androidx.constraintlayout.widget.ConstraintLayout)1