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

Side by Side Diff: chrome/browser/webdata/autofill_profile_syncable_service_unittest.cc

Issue 9749012: [Sync] Have SyncableService's take ownership of their SyncChangeProcessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser_tests Created 8 years, 9 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/location.h" 5 #include "base/location.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autofill/autofill_profile.h" 8 #include "chrome/browser/autofill/autofill_profile.h"
9 #include "chrome/browser/sync/internal_api/read_node_mock.h" 9 #include "chrome/browser/sync/internal_api/read_node_mock.h"
10 #include "chrome/browser/webdata/autofill_change.h" 10 #include "chrome/browser/webdata/autofill_change.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 .WillOnce(Return(true)); 162 .WillOnce(Return(true));
163 ON_CALL(*sync_processor_, ProcessSyncChanges(_, _)) 163 ON_CALL(*sync_processor_, ProcessSyncChanges(_, _))
164 .WillByDefault(Return(SyncError())); 164 .WillByDefault(Return(SyncError()));
165 EXPECT_CALL(*sync_processor_, 165 EXPECT_CALL(*sync_processor_,
166 ProcessSyncChanges(_, CheckSyncChanges(expected_change_list))) 166 ProcessSyncChanges(_, CheckSyncChanges(expected_change_list)))
167 .Times(1) 167 .Times(1)
168 .WillOnce(Return(SyncError())); 168 .WillOnce(Return(SyncError()));
169 169
170 // Takes ownership of sync_processor_. 170 // Takes ownership of sync_processor_.
171 autofill_syncable_service_.MergeDataAndStartSyncing( 171 autofill_syncable_service_.MergeDataAndStartSyncing(
172 syncable::AUTOFILL_PROFILE, data_list, sync_processor_.release()); 172 syncable::AUTOFILL_PROFILE, data_list,
173 sync_processor_.PassAs<SyncChangeProcessor>());
173 autofill_syncable_service_.StopSyncing(syncable::AUTOFILL_PROFILE); 174 autofill_syncable_service_.StopSyncing(syncable::AUTOFILL_PROFILE);
174 } 175 }
175 176
176 TEST_F(AutofillProfileSyncableServiceTest, GetAllSyncData) { 177 TEST_F(AutofillProfileSyncableServiceTest, GetAllSyncData) {
177 std::vector<AutofillProfile *> profiles_from_web_db; 178 std::vector<AutofillProfile *> profiles_from_web_db;
178 std::string guid_present1 = kGuid1; 179 std::string guid_present1 = kGuid1;
179 std::string guid_present2 = kGuid2; 180 std::string guid_present2 = kGuid2;
180 181
181 profiles_from_web_db.push_back(new AutofillProfile(guid_present1)); 182 profiles_from_web_db.push_back(new AutofillProfile(guid_present1));
182 profiles_from_web_db.back()->SetInfo(NAME_FIRST, UTF8ToUTF16("John")); 183 profiles_from_web_db.back()->SetInfo(NAME_FIRST, UTF8ToUTF16("John"));
183 profiles_from_web_db.push_back(new AutofillProfile(guid_present2)); 184 profiles_from_web_db.push_back(new AutofillProfile(guid_present2));
184 profiles_from_web_db.back()->SetInfo(NAME_FIRST, UTF8ToUTF16("Jane")); 185 profiles_from_web_db.back()->SetInfo(NAME_FIRST, UTF8ToUTF16("Jane"));
185 186
186 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_)) 187 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_))
187 .Times(1) 188 .Times(1)
188 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true))); 189 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true)));
189 EXPECT_CALL(autofill_syncable_service_, SaveChangesToWebData(_)) 190 EXPECT_CALL(autofill_syncable_service_, SaveChangesToWebData(_))
190 .Times(1) 191 .Times(1)
191 .WillOnce(Return(true)); 192 .WillOnce(Return(true));
192 ON_CALL(*sync_processor_, ProcessSyncChanges(_, _)) 193 ON_CALL(*sync_processor_, ProcessSyncChanges(_, _))
193 .WillByDefault(Return(SyncError())); 194 .WillByDefault(Return(SyncError()));
194 EXPECT_CALL(*sync_processor_, 195 EXPECT_CALL(*sync_processor_,
195 ProcessSyncChanges(_, Property(&SyncChangeList::size, Eq(2U)))) 196 ProcessSyncChanges(_, Property(&SyncChangeList::size, Eq(2U))))
196 .Times(1) 197 .Times(1)
197 .WillOnce(Return(SyncError())); 198 .WillOnce(Return(SyncError()));
198 199
199 SyncDataList data_list; 200 SyncDataList data_list;
200 // Takes ownership of sync_processor_. 201 // Takes ownership of sync_processor_.
201 autofill_syncable_service_.MergeDataAndStartSyncing( 202 autofill_syncable_service_.MergeDataAndStartSyncing(
202 syncable::AUTOFILL_PROFILE, data_list, sync_processor_.release()); 203 syncable::AUTOFILL_PROFILE, data_list,
204 sync_processor_.PassAs<SyncChangeProcessor>());
203 205
204 SyncDataList data = 206 SyncDataList data =
205 autofill_syncable_service_.GetAllSyncData(syncable::AUTOFILL_PROFILE); 207 autofill_syncable_service_.GetAllSyncData(syncable::AUTOFILL_PROFILE);
206 208
207 EXPECT_EQ(2U, data.size()); 209 EXPECT_EQ(2U, data.size());
208 EXPECT_EQ(guid_present1, data.front().GetSpecifics() 210 EXPECT_EQ(guid_present1, data.front().GetSpecifics()
209 .autofill_profile().guid()); 211 .autofill_profile().guid());
210 EXPECT_EQ(guid_present2, data.back().GetSpecifics() 212 EXPECT_EQ(guid_present2, data.back().GetSpecifics()
211 .autofill_profile().guid()); 213 .autofill_profile().guid());
212 } 214 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 profile1.GetMultiInfo(EMAIL_ADDRESS, &values); 400 profile1.GetMultiInfo(EMAIL_ADDRESS, &values);
399 ASSERT_EQ(values.size(), 3U); 401 ASSERT_EQ(values.size(), 3U);
400 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com")); 402 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com"));
401 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com")); 403 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com"));
402 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com")); 404 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com"));
403 405
404 profile1.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); 406 profile1.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
405 ASSERT_EQ(values.size(), 1U); 407 ASSERT_EQ(values.size(), 1U);
406 EXPECT_EQ(values[0], UTF8ToUTF16("650234567")); 408 EXPECT_EQ(values[0], UTF8ToUTF16("650234567"));
407 } 409 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698