@@ -671,6 +671,78 @@ TEST_F(FirebaseAuthTest, TestUpdateUserProfile) {
671
671
DeleteUser ();
672
672
}
673
673
674
+ TEST_F (FirebaseAuthTest, TestUpdateUserProfileNull) {
675
+ std::string email = GenerateEmailAddress ();
676
+ firebase::Future<firebase::auth::AuthResult> create_user =
677
+ auth_->CreateUserWithEmailAndPassword (email.c_str (), kTestPassword );
678
+ WaitForCompletion (create_user, " CreateUserWithEmailAndPassword" );
679
+ EXPECT_TRUE (auth_->current_user ().is_valid ());
680
+ // Set some user profile properties.
681
+ firebase::auth::User user = create_user.result ()->user ;
682
+ const char kDisplayName [] = " Hello World" ;
683
+ const char kPhotoUrl [] = " http://example.com/image.jpg" ;
684
+ firebase::auth::User::UserProfile user_profile;
685
+ user_profile.display_name = kDisplayName ;
686
+ user_profile.photo_url = kPhotoUrl ;
687
+ firebase::Future<void > update_profile = user.UpdateUserProfile (user_profile);
688
+ WaitForCompletion (update_profile, " UpdateUserProfile" );
689
+ user = auth_->current_user ();
690
+ EXPECT_EQ (user.display_name (), kDisplayName );
691
+ EXPECT_EQ (user.photo_url (), kPhotoUrl );
692
+ firebase::auth::User::UserProfile user_profile_null;
693
+ user_profile_null.display_name = kDisplayName ;
694
+ user_profile_null.photo_url = null;
695
+ firebase::Future<void > update_profile_null = user.UpdateUserProfile (user_profile_null);
696
+ WaitForCompletion (user_profile_null, " UpdateUserProfileNull" );
697
+ user = auth_->current_user ();
698
+ EXPECT_EQ (user.display_name (), kDisplayName );
699
+ EXPECT_EQ (user.photo_url (), null);
700
+ SignOut ();
701
+ WaitForCompletion (
702
+ auth_->SignInWithEmailAndPassword (email.c_str (), kTestPassword ),
703
+ " SignInWithEmailAndPassword" );
704
+ user = auth_->current_user ();
705
+ EXPECT_EQ (user.display_name (), kDisplayName );
706
+ EXPECT_EQ (user.photo_url (), null);
707
+ DeleteUser ();
708
+ }
709
+
710
+ TEST_F (FirebaseAuthTest, TestUpdateUserProfileEmpty) {
711
+ std::string email = GenerateEmailAddress ();
712
+ firebase::Future<firebase::auth::AuthResult> create_user =
713
+ auth_->CreateUserWithEmailAndPassword (email.c_str (), kTestPassword );
714
+ WaitForCompletion (create_user, " CreateUserWithEmailAndPassword" );
715
+ EXPECT_TRUE (auth_->current_user ().is_valid ());
716
+ // Set some user profile properties.
717
+ firebase::auth::User user = create_user.result ()->user ;
718
+ const char kDisplayName [] = " Hello World" ;
719
+ const char kPhotoUrl [] = " http://example.com/image.jpg" ;
720
+ firebase::auth::User::UserProfile user_profile;
721
+ user_profile.display_name = kDisplayName ;
722
+ user_profile.photo_url = kPhotoUrl ;
723
+ firebase::Future<void > update_profile = user.UpdateUserProfile (user_profile);
724
+ WaitForCompletion (update_profile, " UpdateUserProfile" );
725
+ user = auth_->current_user ();
726
+ EXPECT_EQ (user.display_name (), kDisplayName );
727
+ EXPECT_EQ (user.photo_url (), kPhotoUrl );
728
+ firebase::auth::User::UserProfile user_profile_null;
729
+ user_profile_null.display_name = kDisplayName ;
730
+ user_profile_null.photo_url = " " ;
731
+ firebase::Future<void > update_profile_null = user.UpdateUserProfile (user_profile_null);
732
+ WaitForCompletion (user_profile_null, " UpdateUserProfileEmpty" );
733
+ user = auth_->current_user ();
734
+ EXPECT_EQ (user.display_name (), kDisplayName );
735
+ EXPECT_EQ (user.photo_url (), " " );
736
+ SignOut ();
737
+ WaitForCompletion (
738
+ auth_->SignInWithEmailAndPassword (email.c_str (), kTestPassword ),
739
+ " SignInWithEmailAndPassword" );
740
+ user = auth_->current_user ();
741
+ EXPECT_EQ (user.display_name (), kDisplayName );
742
+ EXPECT_EQ (user.photo_url (), " " );
743
+ DeleteUser ();
744
+ }
745
+
674
746
TEST_F (FirebaseAuthTest, TestUpdateEmailAndPassword) {
675
747
std::string email = GenerateEmailAddress ();
676
748
WaitForCompletion (
0 commit comments