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

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

Issue 6811003: [Sync] Make generic non-frontend thread datatype controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copy paste :( Created 9 years, 8 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) 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 virtual ~AbstractAutofillFactory() {} 200 virtual ~AbstractAutofillFactory() {}
201 }; 201 };
202 202
203 class AutofillEntryFactory : public AbstractAutofillFactory { 203 class AutofillEntryFactory : public AbstractAutofillFactory {
204 public: 204 public:
205 browser_sync::AutofillDataTypeController* CreateDataTypeController( 205 browser_sync::AutofillDataTypeController* CreateDataTypeController(
206 ProfileSyncFactory *factory, 206 ProfileSyncFactory *factory,
207 ProfileMock* profile, 207 ProfileMock* profile,
208 ProfileSyncService* service) { 208 ProfileSyncService* service) {
209 return new AutofillDataTypeController(factory, 209 return new AutofillDataTypeController(factory,
210 profile, 210 profile);
211 service);
212 } 211 }
213 212
214 void SetExpectation(ProfileSyncFactoryMock* factory, 213 void SetExpectation(ProfileSyncFactoryMock* factory,
215 ProfileSyncService* service, 214 ProfileSyncService* service,
216 WebDatabase* wd, 215 WebDatabase* wd,
217 PersonalDataManager* pdm, 216 PersonalDataManager* pdm,
218 DataTypeController* dtc) { 217 DataTypeController* dtc) {
219 EXPECT_CALL(*factory, CreateAutofillSyncComponents(_,_,_,_)). 218 EXPECT_CALL(*factory, CreateAutofillSyncComponents(_,_,_,_)).
220 WillOnce(MakeAutofillSyncComponents(service, wd, pdm, dtc)); 219 WillOnce(MakeAutofillSyncComponents(service, wd, pdm, dtc));
221 } 220 }
222 }; 221 };
223 222
224 class AutofillProfileFactory : public AbstractAutofillFactory { 223 class AutofillProfileFactory : public AbstractAutofillFactory {
225 public: 224 public:
226 browser_sync::AutofillDataTypeController* CreateDataTypeController( 225 browser_sync::AutofillDataTypeController* CreateDataTypeController(
227 ProfileSyncFactory *factory, 226 ProfileSyncFactory *factory,
228 ProfileMock* profile, 227 ProfileMock* profile,
229 ProfileSyncService* service) { 228 ProfileSyncService* service) {
230 return new AutofillProfileDataTypeController(factory, 229 return new AutofillProfileDataTypeController(factory,
231 profile, 230 profile);
232 service);
233 } 231 }
234 232
235 void SetExpectation(ProfileSyncFactoryMock* factory, 233 void SetExpectation(ProfileSyncFactoryMock* factory,
236 ProfileSyncService* service, 234 ProfileSyncService* service,
237 WebDatabase* wd, 235 WebDatabase* wd,
238 PersonalDataManager* pdm, 236 PersonalDataManager* pdm,
239 DataTypeController* dtc) { 237 DataTypeController* dtc) {
240 EXPECT_CALL(*factory, CreateAutofillProfileSyncComponents(_,_,_,_)). 238 EXPECT_CALL(*factory, CreateAutofillProfileSyncComponents(_,_,_,_)).
241 WillOnce(MakeAutofillProfileSyncComponents(service, wd, pdm, dtc)); 239 WillOnce(MakeAutofillProfileSyncComponents(service, wd, pdm, dtc));
242 } 240 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 MessageLoop::current()->RunAllPending(); 288 MessageLoop::current()->RunAllPending();
291 } 289 }
292 290
293 void StartSyncService(Task* task, 291 void StartSyncService(Task* task,
294 bool will_fail_association, 292 bool will_fail_association,
295 syncable::ModelType type) { 293 syncable::ModelType type) {
296 AbstractAutofillFactory* factory = GetFactory(type); 294 AbstractAutofillFactory* factory = GetFactory(type);
297 service_.reset( 295 service_.reset(
298 new TestProfileSyncService(&factory_, &profile_, "test_user", false, 296 new TestProfileSyncService(&factory_, &profile_, "test_user", false,
299 task)); 297 task));
298 EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly(
299 Return(service_.get()));
300 AutofillDataTypeController* data_type_controller = 300 AutofillDataTypeController* data_type_controller =
301 factory->CreateDataTypeController(&factory_, 301 factory->CreateDataTypeController(&factory_,
302 &profile_, 302 &profile_,
303 service_.get()); 303 service_.get());
304 SyncBackendHostForProfileSyncTest:: 304 SyncBackendHostForProfileSyncTest::
305 SetDefaultExpectationsForWorkerCreation(&profile_); 305 SetDefaultExpectationsForWorkerCreation(&profile_);
306 306
307 factory->SetExpectation(&factory_, 307 factory->SetExpectation(&factory_,
308 service_.get(), 308 service_.get(),
309 web_database_.get(), 309 web_database_.get(),
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 ASSERT_TRUE(task.success()); 658 ASSERT_TRUE(task.success());
659 std::vector<AutofillEntry> sync_entries; 659 std::vector<AutofillEntry> sync_entries;
660 std::vector<AutofillProfile> sync_profiles; 660 std::vector<AutofillProfile> sync_profiles;
661 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 661 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
662 ASSERT_EQ(1U, entries.size()); 662 ASSERT_EQ(1U, entries.size());
663 EXPECT_TRUE(entries[0] == sync_entries[0]); 663 EXPECT_TRUE(entries[0] == sync_entries[0]);
664 EXPECT_EQ(0U, sync_profiles.size()); 664 EXPECT_EQ(0U, sync_profiles.size());
665 } 665 }
666 666
667 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) { 667 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) {
668
669 std::vector<AutofillProfile*> profiles; 668 std::vector<AutofillProfile*> profiles;
670 std::vector<AutofillProfile> expected_profiles; 669 std::vector<AutofillProfile> expected_profiles;
671 // Owned by GetAutofillProfiles caller. 670 // Owned by GetAutofillProfiles caller.
672 AutofillProfile* profile0 = new AutofillProfile; 671 AutofillProfile* profile0 = new AutofillProfile;
673 autofill_test::SetProfileInfoWithGuid(profile0, 672 autofill_test::SetProfileInfoWithGuid(profile0,
674 "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing", 673 "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing",
675 "Mitchell", "Morrison", 674 "Mitchell", "Morrison",
676 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 675 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
677 "91601", "US", "12345678910", "01987654321"); 676 "91601", "US", "12345678910", "01987654321");
678 profiles.push_back(profile0); 677 profiles.push_back(profile0);
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 std::vector<AutofillEntry> sync_entries; 1084 std::vector<AutofillEntry> sync_entries;
1086 std::vector<AutofillProfile> sync_profiles; 1085 std::vector<AutofillProfile> sync_profiles;
1087 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1086 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1088 EXPECT_EQ(3U, sync_entries.size()); 1087 EXPECT_EQ(3U, sync_entries.size());
1089 EXPECT_EQ(0U, sync_profiles.size()); 1088 EXPECT_EQ(0U, sync_profiles.size());
1090 for (size_t i = 0; i < sync_entries.size(); i++) { 1089 for (size_t i = 0; i < sync_entries.size(); i++) {
1091 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1090 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1092 << ", " << sync_entries[i].key().value(); 1091 << ", " << sync_entries[i].key().value();
1093 } 1092 }
1094 } 1093 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_factory_mock.h ('k') | chrome/browser/sync/profile_sync_service_password_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698