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

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

Issue 10152003: sync: Make BaseNode lookup-related Init functions return specific failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: init Created 8 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) 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest { 135 class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest {
136 public: 136 public:
137 sync_api::UserShare* GetUserShare() { 137 sync_api::UserShare* GetUserShare() {
138 return service_->GetUserShare(); 138 return service_->GetUserShare();
139 } 139 }
140 140
141 void AddPasswordSyncNode(const PasswordForm& entry) { 141 void AddPasswordSyncNode(const PasswordForm& entry) {
142 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); 142 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
143 sync_api::ReadNode password_root(&trans); 143 sync_api::ReadNode password_root(&trans);
144 ASSERT_TRUE(password_root.InitByTagLookup(browser_sync::kPasswordTag)); 144 ASSERT_EQ(sync_api::BaseNode::INIT_OK,
145 password_root.InitByTagLookup(browser_sync::kPasswordTag));
145 146
146 sync_api::WriteNode node(&trans); 147 sync_api::WriteNode node(&trans);
147 std::string tag = PasswordModelAssociator::MakeTag(entry); 148 std::string tag = PasswordModelAssociator::MakeTag(entry);
148 ASSERT_TRUE(node.InitUniqueByCreation(syncable::PASSWORDS, 149 ASSERT_TRUE(node.InitUniqueByCreation(syncable::PASSWORDS,
149 password_root, 150 password_root,
150 tag)); 151 tag));
151 PasswordModelAssociator::WriteToSyncNode(entry, &node); 152 PasswordModelAssociator::WriteToSyncNode(entry, &node);
152 } 153 }
153 154
154 protected: 155 protected:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 FlushLastDBTask(); 239 FlushLastDBTask();
239 240
240 service_->SetEncryptionPassphrase("foo", ProfileSyncService::IMPLICIT); 241 service_->SetEncryptionPassphrase("foo", ProfileSyncService::IMPLICIT);
241 MessageLoop::current()->Run(); 242 MessageLoop::current()->Run();
242 } 243 }
243 } 244 }
244 245
245 void GetPasswordEntriesFromSyncDB(std::vector<PasswordForm>* entries) { 246 void GetPasswordEntriesFromSyncDB(std::vector<PasswordForm>* entries) {
246 sync_api::ReadTransaction trans(FROM_HERE, service_->GetUserShare()); 247 sync_api::ReadTransaction trans(FROM_HERE, service_->GetUserShare());
247 sync_api::ReadNode password_root(&trans); 248 sync_api::ReadNode password_root(&trans);
248 ASSERT_TRUE(password_root.InitByTagLookup(browser_sync::kPasswordTag)); 249 ASSERT_EQ(sync_api::BaseNode::INIT_OK,
250 password_root.InitByTagLookup(browser_sync::kPasswordTag));
249 251
250 int64 child_id = password_root.GetFirstChildId(); 252 int64 child_id = password_root.GetFirstChildId();
251 while (child_id != sync_api::kInvalidId) { 253 while (child_id != sync_api::kInvalidId) {
252 sync_api::ReadNode child_node(&trans); 254 sync_api::ReadNode child_node(&trans);
253 ASSERT_TRUE(child_node.InitByIdLookup(child_id)); 255 ASSERT_EQ(sync_api::BaseNode::INIT_OK,
256 child_node.InitByIdLookup(child_id));
254 257
255 const sync_pb::PasswordSpecificsData& password = 258 const sync_pb::PasswordSpecificsData& password =
256 child_node.GetPasswordSpecifics(); 259 child_node.GetPasswordSpecifics();
257 260
258 PasswordForm form; 261 PasswordForm form;
259 PasswordModelAssociator::CopyPassword(password, &form); 262 PasswordModelAssociator::CopyPassword(password, &form);
260 263
261 entries->push_back(form); 264 entries->push_back(form);
262 265
263 child_id = child_node.GetSuccessorId(); 266 child_id = child_node.GetSuccessorId();
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 CreateRootHelper create_root(this, syncable::PASSWORDS); 589 CreateRootHelper create_root(this, syncable::PASSWORDS);
587 StartSyncService(create_root.callback(), 590 StartSyncService(create_root.callback(),
588 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); 591 base::Bind(&AddPasswordEntriesCallback, this, sync_forms));
589 592
590 std::vector<PasswordForm> new_sync_forms; 593 std::vector<PasswordForm> new_sync_forms;
591 GetPasswordEntriesFromSyncDB(&new_sync_forms); 594 GetPasswordEntriesFromSyncDB(&new_sync_forms);
592 595
593 EXPECT_EQ(1U, new_sync_forms.size()); 596 EXPECT_EQ(1U, new_sync_forms.size());
594 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); 597 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0]));
595 } 598 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698