Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Side by Side Diff: chrome/browser/sync/profile_sync_service_autofill_unittest.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 ASSERT_TRUE(task.success()); 783 ASSERT_TRUE(task.success());
784 784
785 AutofillEntry added_entry(MakeAutofillEntry("added", "entry", 1)); 785 AutofillEntry added_entry(MakeAutofillEntry("added", "entry", 1));
786 std::vector<base::Time> timestamps(added_entry.timestamps()); 786 std::vector<base::Time> timestamps(added_entry.timestamps());
787 787
788 EXPECT_CALL(web_database_, GetAutofillTimestamps(_, _, _)). 788 EXPECT_CALL(web_database_, GetAutofillTimestamps(_, _, _)).
789 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 789 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
790 790
791 AutofillChangeList changes; 791 AutofillChangeList changes;
792 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); 792 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key()));
793 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 793 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
794 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED, 794 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED,
795 Source<WebDataService>(web_data_service_.get()), 795 Source<WebDataService>(web_data_service_.get()),
796 Details<AutofillChangeList>(&changes)); 796 Details<AutofillChangeList>(&changes));
797 797
798 std::vector<AutofillEntry> new_sync_entries; 798 std::vector<AutofillEntry> new_sync_entries;
799 std::vector<AutoFillProfile> new_sync_profiles; 799 std::vector<AutoFillProfile> new_sync_profiles;
800 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 800 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
801 &new_sync_profiles)); 801 &new_sync_profiles));
802 ASSERT_EQ(1U, new_sync_entries.size()); 802 ASSERT_EQ(1U, new_sync_entries.size());
803 EXPECT_TRUE(added_entry == new_sync_entries[0]); 803 EXPECT_TRUE(added_entry == new_sync_entries[0]);
804 } 804 }
805 805
806 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { 806 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) {
807 EXPECT_CALL(web_database_, GetAllAutofillEntries(_)).WillOnce(Return(true)); 807 EXPECT_CALL(web_database_, GetAllAutofillEntries(_)).WillOnce(Return(true));
808 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)).WillOnce(Return(true)); 808 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)).WillOnce(Return(true));
809 EXPECT_CALL(*personal_data_manager_, Refresh()); 809 EXPECT_CALL(*personal_data_manager_, Refresh());
810 SetIdleChangeProcessorExpectations(); 810 SetIdleChangeProcessorExpectations();
811 CreateRootTask task(this, syncable::AUTOFILL); 811 CreateRootTask task(this, syncable::AUTOFILL);
812 StartSyncService(&task, false); 812 StartSyncService(&task, false);
813 ASSERT_TRUE(task.success()); 813 ASSERT_TRUE(task.success());
814 814
815 AutoFillProfile added_profile(string16(), 0); 815 AutoFillProfile added_profile(string16(), 0);
816 autofill_test::SetProfileInfo(&added_profile, 816 autofill_test::SetProfileInfo(&added_profile,
817 "Billing", "Josephine", "Alicia", "Saenz", 817 "Billing", "Josephine", "Alicia", "Saenz",
818 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 818 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
819 "32801", "US", "19482937549", "13502849239"); 819 "32801", "US", "19482937549", "13502849239");
820 820
821 AutofillProfileChange change(AutofillProfileChange::ADD, 821 AutofillProfileChange change(AutofillProfileChange::ADD,
822 added_profile.Label(), &added_profile, string16()); 822 added_profile.Label(), &added_profile, string16());
823 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 823 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
824 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, 824 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED,
825 Source<WebDataService>(web_data_service_.get()), 825 Source<WebDataService>(web_data_service_.get()),
826 Details<AutofillProfileChange>(&change)); 826 Details<AutofillProfileChange>(&change));
827 827
828 std::vector<AutofillEntry> new_sync_entries; 828 std::vector<AutofillEntry> new_sync_entries;
829 std::vector<AutoFillProfile> new_sync_profiles; 829 std::vector<AutoFillProfile> new_sync_profiles;
830 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 830 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
831 &new_sync_profiles)); 831 &new_sync_profiles));
832 ASSERT_EQ(1U, new_sync_profiles.size()); 832 ASSERT_EQ(1U, new_sync_profiles.size());
833 // TODO(dhollowa): Replace with |AutoFillProfile::Compare|. 833 // TODO(dhollowa): Replace with |AutoFillProfile::Compare|.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 865
866 AutofillProfileChange change(AutofillProfileChange::ADD, 866 AutofillProfileChange change(AutofillProfileChange::ADD,
867 added_profile.Label(), &added_profile, string16()); 867 added_profile.Label(), &added_profile, string16());
868 868
869 AutoFillProfile relabelled_profile; 869 AutoFillProfile relabelled_profile;
870 EXPECT_CALL(web_database_, UpdateAutoFillProfile( 870 EXPECT_CALL(web_database_, UpdateAutoFillProfile(
871 ProfileMatchesExceptLabel(added_profile))). 871 ProfileMatchesExceptLabel(added_profile))).
872 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true))); 872 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true)));
873 EXPECT_CALL(*personal_data_manager_, Refresh()); 873 EXPECT_CALL(*personal_data_manager_, Refresh());
874 874
875 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 875 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
876 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, 876 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED,
877 Source<WebDataService>(web_data_service_.get()), 877 Source<WebDataService>(web_data_service_.get()),
878 Details<AutofillProfileChange>(&change)); 878 Details<AutofillProfileChange>(&change));
879 879
880 std::vector<AutofillEntry> new_sync_entries; 880 std::vector<AutofillEntry> new_sync_entries;
881 std::vector<AutoFillProfile> new_sync_profiles; 881 std::vector<AutoFillProfile> new_sync_profiles;
882 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 882 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
883 &new_sync_profiles)); 883 &new_sync_profiles));
884 ASSERT_EQ(2U, new_sync_profiles.size()); 884 ASSERT_EQ(2U, new_sync_profiles.size());
885 sync_profile.set_unique_id(0); // The sync DB doesn't store IDs. 885 sync_profile.set_unique_id(0); // The sync DB doesn't store IDs.
(...skipping 18 matching lines...) Expand all
904 904
905 AutofillEntry updated_entry(MakeAutofillEntry("my", "entry", 1, 2)); 905 AutofillEntry updated_entry(MakeAutofillEntry("my", "entry", 1, 2));
906 std::vector<base::Time> timestamps(updated_entry.timestamps()); 906 std::vector<base::Time> timestamps(updated_entry.timestamps());
907 907
908 EXPECT_CALL(web_database_, GetAutofillTimestamps(_, _, _)). 908 EXPECT_CALL(web_database_, GetAutofillTimestamps(_, _, _)).
909 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 909 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
910 910
911 AutofillChangeList changes; 911 AutofillChangeList changes;
912 changes.push_back(AutofillChange(AutofillChange::UPDATE, 912 changes.push_back(AutofillChange(AutofillChange::UPDATE,
913 updated_entry.key())); 913 updated_entry.key()));
914 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 914 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
915 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED, 915 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED,
916 Source<WebDataService>(web_data_service_.get()), 916 Source<WebDataService>(web_data_service_.get()),
917 Details<AutofillChangeList>(&changes)); 917 Details<AutofillChangeList>(&changes));
918 918
919 std::vector<AutofillEntry> new_sync_entries; 919 std::vector<AutofillEntry> new_sync_entries;
920 std::vector<AutoFillProfile> new_sync_profiles; 920 std::vector<AutoFillProfile> new_sync_profiles;
921 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 921 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
922 &new_sync_profiles)); 922 &new_sync_profiles));
923 ASSERT_EQ(1U, new_sync_entries.size()); 923 ASSERT_EQ(1U, new_sync_entries.size());
924 EXPECT_TRUE(updated_entry == new_sync_entries[0]); 924 EXPECT_TRUE(updated_entry == new_sync_entries[0]);
(...skipping 18 matching lines...) Expand all
943 943
944 AutoFillProfile update_profile(string16(), 0); 944 AutoFillProfile update_profile(string16(), 0);
945 autofill_test::SetProfileInfo(&update_profile, 945 autofill_test::SetProfileInfo(&update_profile,
946 "Billing", "Changin'", "Mah", "Namez", 946 "Billing", "Changin'", "Mah", "Namez",
947 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 947 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
948 "32801", "US", "19482937549", "13502849239"); 948 "32801", "US", "19482937549", "13502849239");
949 949
950 AutofillProfileChange change(AutofillProfileChange::UPDATE, 950 AutofillProfileChange change(AutofillProfileChange::UPDATE,
951 update_profile.Label(), &update_profile, 951 update_profile.Label(), &update_profile,
952 ASCIIToUTF16("Billing")); 952 ASCIIToUTF16("Billing"));
953 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 953 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
954 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, 954 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED,
955 Source<WebDataService>(web_data_service_.get()), 955 Source<WebDataService>(web_data_service_.get()),
956 Details<AutofillProfileChange>(&change)); 956 Details<AutofillProfileChange>(&change));
957 957
958 std::vector<AutofillEntry> new_sync_entries; 958 std::vector<AutofillEntry> new_sync_entries;
959 std::vector<AutoFillProfile> new_sync_profiles; 959 std::vector<AutoFillProfile> new_sync_profiles;
960 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 960 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
961 &new_sync_profiles)); 961 &new_sync_profiles));
962 ASSERT_EQ(1U, new_sync_profiles.size()); 962 ASSERT_EQ(1U, new_sync_profiles.size());
963 // TODO(dhollowa): Replace with |AutoFillProfile::Compare|. 963 // TODO(dhollowa): Replace with |AutoFillProfile::Compare|.
(...skipping 19 matching lines...) Expand all
983 983
984 AutoFillProfile update_profile(string16(), 0); 984 AutoFillProfile update_profile(string16(), 0);
985 autofill_test::SetProfileInfo(&update_profile, 985 autofill_test::SetProfileInfo(&update_profile,
986 "TRYIN 2 FOOL U", "Josephine", "Alicia", "Saenz", 986 "TRYIN 2 FOOL U", "Josephine", "Alicia", "Saenz",
987 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 987 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
988 "32801", "US", "19482937549", "13502849239"); 988 "32801", "US", "19482937549", "13502849239");
989 989
990 AutofillProfileChange change(AutofillProfileChange::UPDATE, 990 AutofillProfileChange change(AutofillProfileChange::UPDATE,
991 update_profile.Label(), &update_profile, 991 update_profile.Label(), &update_profile,
992 ASCIIToUTF16("Billing")); 992 ASCIIToUTF16("Billing"));
993 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 993 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
994 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, 994 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED,
995 Source<WebDataService>(web_data_service_.get()), 995 Source<WebDataService>(web_data_service_.get()),
996 Details<AutofillProfileChange>(&change)); 996 Details<AutofillProfileChange>(&change));
997 997
998 std::vector<AutofillEntry> new_sync_entries; 998 std::vector<AutofillEntry> new_sync_entries;
999 std::vector<AutoFillProfile> new_sync_profiles; 999 std::vector<AutoFillProfile> new_sync_profiles;
1000 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1000 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1001 &new_sync_profiles)); 1001 &new_sync_profiles));
1002 ASSERT_EQ(1U, new_sync_profiles.size()); 1002 ASSERT_EQ(1U, new_sync_profiles.size());
1003 // TODO(dhollowa): Replace with |AutoFillProfile::Compare|. 1003 // TODO(dhollowa): Replace with |AutoFillProfile::Compare|.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1042
1043 AutoFillProfile relabelled_profile; 1043 AutoFillProfile relabelled_profile;
1044 EXPECT_CALL(web_database_, UpdateAutoFillProfile( 1044 EXPECT_CALL(web_database_, UpdateAutoFillProfile(
1045 ProfileMatchesExceptLabel(josephine_update))). 1045 ProfileMatchesExceptLabel(josephine_update))).
1046 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true))); 1046 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true)));
1047 EXPECT_CALL(*personal_data_manager_, Refresh()); 1047 EXPECT_CALL(*personal_data_manager_, Refresh());
1048 1048
1049 AutofillProfileChange change(AutofillProfileChange::UPDATE, 1049 AutofillProfileChange change(AutofillProfileChange::UPDATE,
1050 josephine_update.Label(), &josephine_update, 1050 josephine_update.Label(), &josephine_update,
1051 josephine.Label()); 1051 josephine.Label());
1052 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 1052 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
1053 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, 1053 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED,
1054 Source<WebDataService>(web_data_service_.get()), 1054 Source<WebDataService>(web_data_service_.get()),
1055 Details<AutofillProfileChange>(&change)); 1055 Details<AutofillProfileChange>(&change));
1056 MessageLoop::current()->RunAllPending(); // Run the Refresh task. 1056 MessageLoop::current()->RunAllPending(); // Run the Refresh task.
1057 Mock::VerifyAndClearExpectations(&web_database_); 1057 Mock::VerifyAndClearExpectations(&web_database_);
1058 1058
1059 std::vector<AutofillEntry> new_sync_entries; 1059 std::vector<AutofillEntry> new_sync_entries;
1060 std::vector<AutoFillProfile> new_sync_profiles; 1060 std::vector<AutoFillProfile> new_sync_profiles;
1061 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1061 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1062 &new_sync_profiles)); 1062 &new_sync_profiles));
(...skipping 17 matching lines...) Expand all
1080 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 1080 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true)));
1081 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)).WillOnce(Return(true)); 1081 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)).WillOnce(Return(true));
1082 EXPECT_CALL(*personal_data_manager_, Refresh()); 1082 EXPECT_CALL(*personal_data_manager_, Refresh());
1083 CreateRootTask task(this, syncable::AUTOFILL); 1083 CreateRootTask task(this, syncable::AUTOFILL);
1084 StartSyncService(&task, false); 1084 StartSyncService(&task, false);
1085 ASSERT_TRUE(task.success()); 1085 ASSERT_TRUE(task.success());
1086 1086
1087 AutofillChangeList changes; 1087 AutofillChangeList changes;
1088 changes.push_back(AutofillChange(AutofillChange::REMOVE, 1088 changes.push_back(AutofillChange(AutofillChange::REMOVE,
1089 original_entry.key())); 1089 original_entry.key()));
1090 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 1090 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
1091 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED, 1091 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED,
1092 Source<WebDataService>(web_data_service_.get()), 1092 Source<WebDataService>(web_data_service_.get()),
1093 Details<AutofillChangeList>(&changes)); 1093 Details<AutofillChangeList>(&changes));
1094 1094
1095 std::vector<AutofillEntry> new_sync_entries; 1095 std::vector<AutofillEntry> new_sync_entries;
1096 std::vector<AutoFillProfile> new_sync_profiles; 1096 std::vector<AutoFillProfile> new_sync_profiles;
1097 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1097 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1098 &new_sync_profiles)); 1098 &new_sync_profiles));
1099 ASSERT_EQ(0U, new_sync_entries.size()); 1099 ASSERT_EQ(0U, new_sync_entries.size());
1100 } 1100 }
(...skipping 19 matching lines...) Expand all
1120 std::vector<AutofillEntry> sync_entries; 1120 std::vector<AutofillEntry> sync_entries;
1121 std::vector<AutoFillProfile> sync_profiles; 1121 std::vector<AutoFillProfile> sync_profiles;
1122 sync_profiles.push_back(sync_profile); 1122 sync_profiles.push_back(sync_profile);
1123 AddAutofillEntriesTask task(this, sync_entries, sync_profiles); 1123 AddAutofillEntriesTask task(this, sync_entries, sync_profiles);
1124 EXPECT_CALL(*personal_data_manager_, Refresh()); 1124 EXPECT_CALL(*personal_data_manager_, Refresh());
1125 StartSyncService(&task, false); 1125 StartSyncService(&task, false);
1126 ASSERT_TRUE(task.success()); 1126 ASSERT_TRUE(task.success());
1127 1127
1128 AutofillProfileChange change(AutofillProfileChange::REMOVE, 1128 AutofillProfileChange change(AutofillProfileChange::REMOVE,
1129 sync_profile.Label(), NULL, string16()); 1129 sync_profile.Label(), NULL, string16());
1130 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 1130 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
1131 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, 1131 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED,
1132 Source<WebDataService>(web_data_service_.get()), 1132 Source<WebDataService>(web_data_service_.get()),
1133 Details<AutofillProfileChange>(&change)); 1133 Details<AutofillProfileChange>(&change));
1134 1134
1135 std::vector<AutofillEntry> new_sync_entries; 1135 std::vector<AutofillEntry> new_sync_entries;
1136 std::vector<AutoFillProfile> new_sync_profiles; 1136 std::vector<AutoFillProfile> new_sync_profiles;
1137 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1137 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1138 &new_sync_profiles)); 1138 &new_sync_profiles));
1139 ASSERT_EQ(0U, new_sync_entries.size()); 1139 ASSERT_EQ(0U, new_sync_entries.size());
1140 } 1140 }
1141 1141
1142 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeError) { 1142 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeError) {
1143 EXPECT_CALL(web_database_, GetAllAutofillEntries(_)).WillOnce(Return(true)); 1143 EXPECT_CALL(web_database_, GetAllAutofillEntries(_)).WillOnce(Return(true));
1144 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)).WillOnce(Return(true)); 1144 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)).WillOnce(Return(true));
1145 EXPECT_CALL(*personal_data_manager_, Refresh()); 1145 EXPECT_CALL(*personal_data_manager_, Refresh());
1146 CreateRootTask task(this, syncable::AUTOFILL); 1146 CreateRootTask task(this, syncable::AUTOFILL);
1147 StartSyncService(&task, false); 1147 StartSyncService(&task, false);
1148 ASSERT_TRUE(task.success()); 1148 ASSERT_TRUE(task.success());
1149 1149
1150 // Inject an evil entry into the sync db to conflict with the same 1150 // Inject an evil entry into the sync db to conflict with the same
1151 // entry added by the user. 1151 // entry added by the user.
1152 AutofillEntry evil_entry(MakeAutofillEntry("evil", "entry", 1)); 1152 AutofillEntry evil_entry(MakeAutofillEntry("evil", "entry", 1));
1153 ASSERT_TRUE(AddAutofillSyncNode(evil_entry)); 1153 ASSERT_TRUE(AddAutofillSyncNode(evil_entry));
1154 1154
1155 AutofillChangeList changes; 1155 AutofillChangeList changes;
1156 changes.push_back(AutofillChange(AutofillChange::ADD, 1156 changes.push_back(AutofillChange(AutofillChange::ADD,
1157 evil_entry.key())); 1157 evil_entry.key()));
1158 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); 1158 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
1159 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED, 1159 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED,
1160 Source<WebDataService>(web_data_service_.get()), 1160 Source<WebDataService>(web_data_service_.get()),
1161 Details<AutofillChangeList>(&changes)); 1161 Details<AutofillChangeList>(&changes));
1162 1162
1163 // Wait for the PPS to shut everything down and signal us. 1163 // Wait for the PPS to shut everything down and signal us.
1164 ProfileSyncServiceObserverMock observer; 1164 ProfileSyncServiceObserverMock observer;
1165 service_->AddObserver(&observer); 1165 service_->AddObserver(&observer);
1166 EXPECT_CALL(observer, OnStateChanged()).WillOnce(QuitUIMessageLoop()); 1166 EXPECT_CALL(observer, OnStateChanged()).WillOnce(QuitUIMessageLoop());
1167 MessageLoop::current()->Run(); 1167 MessageLoop::current()->Run();
1168 EXPECT_TRUE(service_->unrecoverable_error_detected()); 1168 EXPECT_TRUE(service_->unrecoverable_error_detected());
(...skipping 11 matching lines...) Expand all
1180 EXPECT_CALL(web_database_, UpdateAutofillEntries(_)). 1180 EXPECT_CALL(web_database_, UpdateAutofillEntries(_)).
1181 WillRepeatedly(Return(true)); 1181 WillRepeatedly(Return(true));
1182 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); 1182 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3);
1183 CreateRootTask task(this, syncable::AUTOFILL); 1183 CreateRootTask task(this, syncable::AUTOFILL);
1184 StartSyncService(&task, false); 1184 StartSyncService(&task, false);
1185 ASSERT_TRUE(task.success()); 1185 ASSERT_TRUE(task.success());
1186 1186
1187 // (true, false) means we have to reset after |Signal|, init to unsignaled. 1187 // (true, false) means we have to reset after |Signal|, init to unsignaled.
1188 scoped_ptr<WaitableEvent> wait_for_start(new WaitableEvent(true, false)); 1188 scoped_ptr<WaitableEvent> wait_for_start(new WaitableEvent(true, false));
1189 scoped_ptr<WaitableEvent> wait_for_syncapi(new WaitableEvent(true, false)); 1189 scoped_ptr<WaitableEvent> wait_for_syncapi(new WaitableEvent(true, false));
1190 scoped_refptr<FakeServerUpdater> updater = new FakeServerUpdater( 1190 scoped_refptr<FakeServerUpdater> updater(new FakeServerUpdater(
1191 service_.get(), &wait_for_start, &wait_for_syncapi); 1191 service_.get(), &wait_for_start, &wait_for_syncapi));
1192 1192
1193 // This server side update will stall waiting for CommitWaiter. 1193 // This server side update will stall waiting for CommitWaiter.
1194 updater->CreateNewEntry(MakeAutofillEntry("server", "entry", 1)); 1194 updater->CreateNewEntry(MakeAutofillEntry("server", "entry", 1));
1195 wait_for_start->Wait(); 1195 wait_for_start->Wait();
1196 1196
1197 AutofillEntry syncapi_entry(MakeAutofillEntry("syncapi", "entry", 2)); 1197 AutofillEntry syncapi_entry(MakeAutofillEntry("syncapi", "entry", 2));
1198 ASSERT_TRUE(AddAutofillSyncNode(syncapi_entry)); 1198 ASSERT_TRUE(AddAutofillSyncNode(syncapi_entry));
1199 VLOG(1) << "Syncapi update finished."; 1199 VLOG(1) << "Syncapi update finished.";
1200 1200
1201 // If we reach here, it means syncapi succeeded and we didn't deadlock. Yay! 1201 // If we reach here, it means syncapi succeeded and we didn't deadlock. Yay!
1202 // Signal FakeServerUpdater that it can complete. 1202 // Signal FakeServerUpdater that it can complete.
1203 wait_for_syncapi->Signal(); 1203 wait_for_syncapi->Signal();
1204 1204
1205 // Make another entry to ensure nothing broke afterwards and wait for finish 1205 // Make another entry to ensure nothing broke afterwards and wait for finish
1206 // to clean up. 1206 // to clean up.
1207 updater->CreateNewEntryAndWait(MakeAutofillEntry("server2", "entry2", 3)); 1207 updater->CreateNewEntryAndWait(MakeAutofillEntry("server2", "entry2", 3));
1208 1208
1209 std::vector<AutofillEntry> sync_entries; 1209 std::vector<AutofillEntry> sync_entries;
1210 std::vector<AutoFillProfile> sync_profiles; 1210 std::vector<AutoFillProfile> sync_profiles;
1211 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1211 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1212 EXPECT_EQ(3U, sync_entries.size()); 1212 EXPECT_EQ(3U, sync_entries.size());
1213 EXPECT_EQ(0U, sync_profiles.size()); 1213 EXPECT_EQ(0U, sync_profiles.size());
1214 for (size_t i = 0; i < sync_entries.size(); i++) { 1214 for (size_t i = 0; i < sync_entries.size(); i++) {
1215 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1215 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1216 << ", " << sync_entries[i].key().value(); 1216 << ", " << sync_entries[i].key().value();
1217 } 1217 }
1218 } 1218 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/history_model_worker.cc ('k') | chrome/browser/sync/profile_sync_service_typed_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698