| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 using testing::Invoke; | 90 using testing::Invoke; |
| 91 using testing::Mock; | 91 using testing::Mock; |
| 92 using testing::Return; | 92 using testing::Return; |
| 93 using testing::SaveArg; | 93 using testing::SaveArg; |
| 94 using testing::SetArgumentPointee; | 94 using testing::SetArgumentPointee; |
| 95 | 95 |
| 96 namespace syncable { | 96 namespace syncable { |
| 97 class Id; | 97 class Id; |
| 98 } | 98 } |
| 99 | 99 |
| 100 class HistoryService; |
| 101 |
| 100 class AutofillTableMock : public AutofillTable { | 102 class AutofillTableMock : public AutofillTable { |
| 101 public: | 103 public: |
| 102 AutofillTableMock() : AutofillTable(NULL, NULL) {} | 104 AutofillTableMock() : AutofillTable(NULL, NULL) {} |
| 103 MOCK_METHOD2(RemoveFormElement, | 105 MOCK_METHOD2(RemoveFormElement, |
| 104 bool(const string16& name, const string16& value)); // NOLINT | 106 bool(const string16& name, const string16& value)); // NOLINT |
| 105 MOCK_METHOD1(GetAllAutofillEntries, | 107 MOCK_METHOD1(GetAllAutofillEntries, |
| 106 bool(std::vector<AutofillEntry>* entries)); // NOLINT | 108 bool(std::vector<AutofillEntry>* entries)); // NOLINT |
| 107 MOCK_METHOD3(GetAutofillTimestamps, | 109 MOCK_METHOD3(GetAutofillTimestamps, |
| 108 bool(const string16& name, // NOLINT | 110 bool(const string16& name, // NOLINT |
| 109 const string16& value, | 111 const string16& value, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 126 : autofill_table_(autofill_table) {} | 128 : autofill_table_(autofill_table) {} |
| 127 | 129 |
| 128 virtual AutofillTable* GetAutofillTable() OVERRIDE { | 130 virtual AutofillTable* GetAutofillTable() OVERRIDE { |
| 129 return autofill_table_; | 131 return autofill_table_; |
| 130 } | 132 } |
| 131 | 133 |
| 132 private: | 134 private: |
| 133 AutofillTable* autofill_table_; | 135 AutofillTable* autofill_table_; |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 | |
| 137 class ProfileSyncServiceAutofillTest; | 138 class ProfileSyncServiceAutofillTest; |
| 138 | 139 |
| 139 template<class AutofillProfile> | 140 template<class AutofillProfile> |
| 140 syncable::ModelType GetModelType() { | 141 syncable::ModelType GetModelType() { |
| 141 return syncable::UNSPECIFIED; | 142 return syncable::UNSPECIFIED; |
| 142 } | 143 } |
| 143 | 144 |
| 144 template<> | 145 template<> |
| 145 syncable::ModelType GetModelType<AutofillEntry>() { | 146 syncable::ModelType GetModelType<AutofillEntry>() { |
| 146 return syncable::AUTOFILL; | 147 return syncable::AUTOFILL; |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 1087 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
| 1087 content::Source<WebDataService>(web_data_service_.get()), | 1088 content::Source<WebDataService>(web_data_service_.get()), |
| 1088 content::Details<AutofillProfileChange>(&change)); | 1089 content::Details<AutofillProfileChange>(&change)); |
| 1089 | 1090 |
| 1090 std::vector<AutofillProfile> new_sync_profiles; | 1091 std::vector<AutofillProfile> new_sync_profiles; |
| 1091 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 1092 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( |
| 1092 &new_sync_profiles)); | 1093 &new_sync_profiles)); |
| 1093 ASSERT_EQ(0U, new_sync_profiles.size()); | 1094 ASSERT_EQ(0U, new_sync_profiles.size()); |
| 1094 } | 1095 } |
| 1095 | 1096 |
| 1096 // Crashy, http://crbug.com/57884 | 1097 TEST_F(ProfileSyncServiceAutofillTest, ServerChangeRace) { |
| 1097 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { | 1098 // GetHistoryService() gets called indirectly, but the result is ignored, so |
| 1098 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).WillOnce(Return(true)); | 1099 // it is safe to return NULL. |
| 1099 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); | 1100 EXPECT_CALL(profile_, GetHistoryService(_)). |
| 1101 WillRepeatedly(Return(static_cast<HistoryService*>(NULL))); |
| 1102 // Once for MergeDataAndStartSyncing() and twice for ProcessSyncChanges(), via |
| 1103 // LoadAutofillData(). |
| 1104 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). |
| 1105 Times(3).WillRepeatedly(Return(true)); |
| 1106 // On the other hand Autofill and Autocomplete are separated now, so |
| 1107 // GetAutofillProfiles() should not be called. |
| 1108 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).Times(0); |
| 1100 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). | 1109 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). |
| 1101 WillRepeatedly(Return(true)); | 1110 WillRepeatedly(Return(true)); |
| 1102 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); | 1111 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); |
| 1103 CreateRootHelper create_root(this, syncable::AUTOFILL); | 1112 CreateRootHelper create_root(this, syncable::AUTOFILL); |
| 1104 StartSyncService(create_root.callback(), false, syncable::AUTOFILL); | 1113 StartSyncService(create_root.callback(), false, syncable::AUTOFILL); |
| 1105 ASSERT_TRUE(create_root.success()); | 1114 ASSERT_TRUE(create_root.success()); |
| 1106 | 1115 |
| 1107 // (true, false) means we have to reset after |Signal|, init to unsignaled. | 1116 // (true, false) means we have to reset after |Signal|, init to unsignaled. |
| 1108 scoped_ptr<WaitableEvent> wait_for_start(new WaitableEvent(true, false)); | 1117 scoped_ptr<WaitableEvent> wait_for_start(new WaitableEvent(true, false)); |
| 1109 scoped_ptr<WaitableEvent> wait_for_syncapi(new WaitableEvent(true, false)); | 1118 scoped_ptr<WaitableEvent> wait_for_syncapi(new WaitableEvent(true, false)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1129 std::vector<AutofillEntry> sync_entries; | 1138 std::vector<AutofillEntry> sync_entries; |
| 1130 std::vector<AutofillProfile> sync_profiles; | 1139 std::vector<AutofillProfile> sync_profiles; |
| 1131 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1140 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1132 EXPECT_EQ(3U, sync_entries.size()); | 1141 EXPECT_EQ(3U, sync_entries.size()); |
| 1133 EXPECT_EQ(0U, sync_profiles.size()); | 1142 EXPECT_EQ(0U, sync_profiles.size()); |
| 1134 for (size_t i = 0; i < sync_entries.size(); i++) { | 1143 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1135 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1144 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1136 << ", " << sync_entries[i].key().value(); | 1145 << ", " << sync_entries[i].key().value(); |
| 1137 } | 1146 } |
| 1138 } | 1147 } |
| OLD | NEW |