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

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

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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 <vector> 5 #include <vector>
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 new PasswordModelAssociator(service, ps, NULL); 64 new PasswordModelAssociator(service, ps, NULL);
65 PasswordChangeProcessor* change_processor = 65 PasswordChangeProcessor* change_processor =
66 new PasswordChangeProcessor(model_associator, ps, dtc); 66 new PasswordChangeProcessor(model_associator, ps, dtc);
67 return ProfileSyncComponentsFactory::SyncComponents(model_associator, 67 return ProfileSyncComponentsFactory::SyncComponents(model_associator,
68 change_processor); 68 change_processor);
69 } 69 }
70 70
71 ACTION_P(AcquireSyncTransaction, password_test_service) { 71 ACTION_P(AcquireSyncTransaction, password_test_service) {
72 // Check to make sure we can aquire a transaction (will crash if a transaction 72 // Check to make sure we can aquire a transaction (will crash if a transaction
73 // is already held by this thread, deadlock if held by another thread). 73 // is already held by this thread, deadlock if held by another thread).
74 csync::WriteTransaction trans( 74 syncer::WriteTransaction trans(
75 FROM_HERE, password_test_service->GetUserShare()); 75 FROM_HERE, password_test_service->GetUserShare());
76 DVLOG(1) << "Sync transaction acquired."; 76 DVLOG(1) << "Sync transaction acquired.";
77 } 77 }
78 78
79 static void QuitMessageLoop() { 79 static void QuitMessageLoop() {
80 MessageLoop::current()->Quit(); 80 MessageLoop::current()->Quit();
81 } 81 }
82 82
83 class PasswordTestProfileSyncService : public TestProfileSyncService { 83 class PasswordTestProfileSyncService : public TestProfileSyncService {
84 public: 84 public:
(...skipping 20 matching lines...) Expand all
105 105
106 TestProfileSyncService::OnPassphraseAccepted(); 106 TestProfileSyncService::OnPassphraseAccepted();
107 } 107 }
108 108
109 private: 109 private:
110 base::Closure callback_; 110 base::Closure callback_;
111 }; 111 };
112 112
113 class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest { 113 class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest {
114 public: 114 public:
115 csync::UserShare* GetUserShare() { 115 syncer::UserShare* GetUserShare() {
116 return service_->GetUserShare(); 116 return service_->GetUserShare();
117 } 117 }
118 118
119 void AddPasswordSyncNode(const PasswordForm& entry) { 119 void AddPasswordSyncNode(const PasswordForm& entry) {
120 csync::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); 120 syncer::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
121 csync::ReadNode password_root(&trans); 121 syncer::ReadNode password_root(&trans);
122 ASSERT_EQ(csync::BaseNode::INIT_OK, 122 ASSERT_EQ(syncer::BaseNode::INIT_OK,
123 password_root.InitByTagLookup(browser_sync::kPasswordTag)); 123 password_root.InitByTagLookup(browser_sync::kPasswordTag));
124 124
125 csync::WriteNode node(&trans); 125 syncer::WriteNode node(&trans);
126 std::string tag = PasswordModelAssociator::MakeTag(entry); 126 std::string tag = PasswordModelAssociator::MakeTag(entry);
127 csync::WriteNode::InitUniqueByCreationResult result = 127 syncer::WriteNode::InitUniqueByCreationResult result =
128 node.InitUniqueByCreation(syncable::PASSWORDS, password_root, tag); 128 node.InitUniqueByCreation(syncable::PASSWORDS, password_root, tag);
129 ASSERT_EQ(csync::WriteNode::INIT_SUCCESS, result); 129 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result);
130 PasswordModelAssociator::WriteToSyncNode(entry, &node); 130 PasswordModelAssociator::WriteToSyncNode(entry, &node);
131 } 131 }
132 132
133 protected: 133 protected:
134 ProfileSyncServicePasswordTest() {} 134 ProfileSyncServicePasswordTest() {}
135 135
136 virtual void SetUp() { 136 virtual void SetUp() {
137 AbstractProfileSyncServiceTest::SetUp(); 137 AbstractProfileSyncServiceTest::SetUp();
138 profile_.CreateRequestContext(); 138 profile_.CreateRequestContext();
139 password_store_ = static_cast<MockPasswordStore*>( 139 password_store_ = static_cast<MockPasswordStore*>(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 service_->Initialize(); 215 service_->Initialize();
216 MessageLoop::current()->Run(); 216 MessageLoop::current()->Run();
217 FlushLastDBTask(); 217 FlushLastDBTask();
218 218
219 service_->SetEncryptionPassphrase("foo", ProfileSyncService::IMPLICIT); 219 service_->SetEncryptionPassphrase("foo", ProfileSyncService::IMPLICIT);
220 MessageLoop::current()->Run(); 220 MessageLoop::current()->Run();
221 } 221 }
222 } 222 }
223 223
224 void GetPasswordEntriesFromSyncDB(std::vector<PasswordForm>* entries) { 224 void GetPasswordEntriesFromSyncDB(std::vector<PasswordForm>* entries) {
225 csync::ReadTransaction trans(FROM_HERE, service_->GetUserShare()); 225 syncer::ReadTransaction trans(FROM_HERE, service_->GetUserShare());
226 csync::ReadNode password_root(&trans); 226 syncer::ReadNode password_root(&trans);
227 ASSERT_EQ(csync::BaseNode::INIT_OK, 227 ASSERT_EQ(syncer::BaseNode::INIT_OK,
228 password_root.InitByTagLookup(browser_sync::kPasswordTag)); 228 password_root.InitByTagLookup(browser_sync::kPasswordTag));
229 229
230 int64 child_id = password_root.GetFirstChildId(); 230 int64 child_id = password_root.GetFirstChildId();
231 while (child_id != csync::kInvalidId) { 231 while (child_id != syncer::kInvalidId) {
232 csync::ReadNode child_node(&trans); 232 syncer::ReadNode child_node(&trans);
233 ASSERT_EQ(csync::BaseNode::INIT_OK, 233 ASSERT_EQ(syncer::BaseNode::INIT_OK,
234 child_node.InitByIdLookup(child_id)); 234 child_node.InitByIdLookup(child_id));
235 235
236 const sync_pb::PasswordSpecificsData& password = 236 const sync_pb::PasswordSpecificsData& password =
237 child_node.GetPasswordSpecifics(); 237 child_node.GetPasswordSpecifics();
238 238
239 PasswordForm form; 239 PasswordForm form;
240 PasswordModelAssociator::CopyPassword(password, &form); 240 PasswordModelAssociator::CopyPassword(password, &form);
241 241
242 entries->push_back(form); 242 entries->push_back(form);
243 243
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 CreateRootHelper create_root(this, syncable::PASSWORDS); 567 CreateRootHelper create_root(this, syncable::PASSWORDS);
568 StartSyncService(create_root.callback(), 568 StartSyncService(create_root.callback(),
569 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); 569 base::Bind(&AddPasswordEntriesCallback, this, sync_forms));
570 570
571 std::vector<PasswordForm> new_sync_forms; 571 std::vector<PasswordForm> new_sync_forms;
572 GetPasswordEntriesFromSyncDB(&new_sync_forms); 572 GetPasswordEntriesFromSyncDB(&new_sync_forms);
573 573
574 EXPECT_EQ(1U, new_sync_forms.size()); 574 EXPECT_EQ(1U, new_sync_forms.size());
575 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); 575 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0]));
576 } 576 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_mock.h ('k') | chrome/browser/sync/profile_sync_service_preference_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698