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

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

Issue 6375007: [Sync] Refactored ProfileSyncService and remove its backend() function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment Created 9 years, 11 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/task.h" 9 #include "base/task.h"
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/password_manager/password_store.h" 12 #include "chrome/browser/password_manager/password_store.h"
13 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 14 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
14 #include "chrome/browser/sync/engine/syncapi.h" 15 #include "chrome/browser/sync/engine/syncapi.h"
15 #include "chrome/browser/sync/glue/password_change_processor.h" 16 #include "chrome/browser/sync/glue/password_change_processor.h"
16 #include "chrome/browser/sync/glue/password_data_type_controller.h" 17 #include "chrome/browser/sync/glue/password_data_type_controller.h"
17 #include "chrome/browser/sync/glue/password_model_associator.h" 18 #include "chrome/browser/sync/glue/password_model_associator.h"
18 #include "chrome/browser/sync/profile_sync_factory.h" 19 #include "chrome/browser/sync/profile_sync_factory.h"
19 #include "chrome/browser/sync/profile_sync_factory_mock.h" 20 #include "chrome/browser/sync/profile_sync_factory_mock.h"
20 #include "chrome/browser/sync/profile_sync_service.h" 21 #include "chrome/browser/sync/profile_sync_service.h"
21 #include "chrome/browser/sync/profile_sync_test_util.h" 22 #include "chrome/browser/sync/profile_sync_test_util.h"
22 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 23 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 Observe( 206 Observe(
206 NotificationType(NotificationType::SYNC_CONFIGURE_DONE), 207 NotificationType(NotificationType::SYNC_CONFIGURE_DONE),
207 _,_)). 208 _,_)).
208 WillOnce(QuitUIMessageLoop()); 209 WillOnce(QuitUIMessageLoop());
209 service_->SetPassphrase("foo", false, true); 210 service_->SetPassphrase("foo", false, true);
210 MessageLoop::current()->Run(); 211 MessageLoop::current()->Run();
211 } 212 }
212 } 213 }
213 214
214 void AddPasswordSyncNode(const PasswordForm& entry) { 215 void AddPasswordSyncNode(const PasswordForm& entry) {
215 sync_api::WriteTransaction trans( 216 sync_api::WriteTransaction trans(service_->GetUserShare());
216 service_->backend()->GetUserShareHandle());
217 sync_api::ReadNode password_root(&trans); 217 sync_api::ReadNode password_root(&trans);
218 ASSERT_TRUE(password_root.InitByTagLookup(browser_sync::kPasswordTag)); 218 ASSERT_TRUE(password_root.InitByTagLookup(browser_sync::kPasswordTag));
219 219
220 sync_api::WriteNode node(&trans); 220 sync_api::WriteNode node(&trans);
221 std::string tag = PasswordModelAssociator::MakeTag(entry); 221 std::string tag = PasswordModelAssociator::MakeTag(entry);
222 ASSERT_TRUE(node.InitUniqueByCreation(syncable::PASSWORDS, 222 ASSERT_TRUE(node.InitUniqueByCreation(syncable::PASSWORDS,
223 password_root, 223 password_root,
224 tag)); 224 tag));
225 PasswordModelAssociator::WriteToSyncNode(entry, &node); 225 PasswordModelAssociator::WriteToSyncNode(entry, &node);
226 } 226 }
227 227
228 void GetPasswordEntriesFromSyncDB(std::vector<PasswordForm>* entries) { 228 void GetPasswordEntriesFromSyncDB(std::vector<PasswordForm>* entries) {
229 sync_api::ReadTransaction trans(service_->backend()->GetUserShareHandle()); 229 sync_api::ReadTransaction trans(service_->GetUserShare());
230 sync_api::ReadNode password_root(&trans); 230 sync_api::ReadNode password_root(&trans);
231 ASSERT_TRUE(password_root.InitByTagLookup(browser_sync::kPasswordTag)); 231 ASSERT_TRUE(password_root.InitByTagLookup(browser_sync::kPasswordTag));
232 232
233 int64 child_id = password_root.GetFirstChildId(); 233 int64 child_id = password_root.GetFirstChildId();
234 while (child_id != sync_api::kInvalidId) { 234 while (child_id != sync_api::kInvalidId) {
235 sync_api::ReadNode child_node(&trans); 235 sync_api::ReadNode child_node(&trans);
236 ASSERT_TRUE(child_node.InitByIdLookup(child_id)); 236 ASSERT_TRUE(child_node.InitByIdLookup(child_id));
237 237
238 const sync_pb::PasswordSpecificsData& password = 238 const sync_pb::PasswordSpecificsData& password =
239 child_node.GetPasswordSpecifics(); 239 child_node.GetPasswordSpecifics();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 AddPasswordEntriesTask node_task(this, sync_forms); 522 AddPasswordEntriesTask node_task(this, sync_forms);
523 523
524 StartSyncService(&root_task, &node_task); 524 StartSyncService(&root_task, &node_task);
525 525
526 std::vector<PasswordForm> new_sync_forms; 526 std::vector<PasswordForm> new_sync_forms;
527 GetPasswordEntriesFromSyncDB(&new_sync_forms); 527 GetPasswordEntriesFromSyncDB(&new_sync_forms);
528 528
529 EXPECT_EQ(1U, new_sync_forms.size()); 529 EXPECT_EQ(1U, new_sync_forms.size());
530 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); 530 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0]));
531 } 531 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_harness.cc ('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