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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 1246063003: Sync: Don't set/use Parent ID for non-hierarchical sync data types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 WriteNode::InitUniqueByCreationResult result = 510 WriteNode::InitUniqueByCreationResult result =
511 password_node.InitUniqueByCreation(PASSWORDS, 511 password_node.InitUniqueByCreation(PASSWORDS,
512 root_node, "foo"); 512 root_node, "foo");
513 EXPECT_EQ(WriteNode::INIT_SUCCESS, result); 513 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
514 sync_pb::PasswordSpecificsData data; 514 sync_pb::PasswordSpecificsData data;
515 data.set_password_value("secret"); 515 data.set_password_value("secret");
516 password_node.SetPasswordSpecifics(data); 516 password_node.SetPasswordSpecifics(data);
517 } 517 }
518 { 518 {
519 ReadTransaction trans(FROM_HERE, user_share()); 519 ReadTransaction trans(FROM_HERE, user_share());
520 ReadNode root_node(&trans);
521 root_node.InitByRootLookup();
522 520
523 ReadNode password_node(&trans); 521 ReadNode password_node(&trans);
524 EXPECT_EQ(BaseNode::INIT_OK, 522 EXPECT_EQ(BaseNode::INIT_OK,
525 password_node.InitByClientTagLookup(PASSWORDS, "foo")); 523 password_node.InitByClientTagLookup(PASSWORDS, "foo"));
526 const sync_pb::PasswordSpecificsData& data = 524 const sync_pb::PasswordSpecificsData& data =
527 password_node.GetPasswordSpecifics(); 525 password_node.GetPasswordSpecifics();
528 EXPECT_EQ("secret", data.password_value()); 526 EXPECT_EQ("secret", data.password_value());
529 } 527 }
530 } 528 }
531 529
(...skipping 16 matching lines...) Expand all
548 bookmark_node.SetTitle("foo"); 546 bookmark_node.SetTitle("foo");
549 547
550 WriteNode pref_node(&trans); 548 WriteNode pref_node(&trans);
551 WriteNode::InitUniqueByCreationResult result = 549 WriteNode::InitUniqueByCreationResult result =
552 pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar"); 550 pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar");
553 ASSERT_EQ(WriteNode::INIT_SUCCESS, result); 551 ASSERT_EQ(WriteNode::INIT_SUCCESS, result);
554 pref_node.SetTitle("bar"); 552 pref_node.SetTitle("bar");
555 } 553 }
556 { 554 {
557 ReadTransaction trans(FROM_HERE, user_share()); 555 ReadTransaction trans(FROM_HERE, user_share());
558 ReadNode root_node(&trans);
559 root_node.InitByRootLookup();
560 556
561 ReadNode bookmark_node(&trans); 557 ReadNode bookmark_node(&trans);
562 ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id)); 558 ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id));
563 EXPECT_EQ("foo", bookmark_node.GetTitle()); 559 EXPECT_EQ("foo", bookmark_node.GetTitle());
564 EXPECT_EQ(kEncryptedString, 560 EXPECT_EQ(kEncryptedString,
565 bookmark_node.GetEntry()->GetNonUniqueName()); 561 bookmark_node.GetEntry()->GetNonUniqueName());
566 562
567 ReadNode pref_node(&trans); 563 ReadNode pref_node(&trans);
568 ASSERT_EQ(BaseNode::INIT_OK, 564 ASSERT_EQ(BaseNode::INIT_OK,
569 pref_node.InitByClientTagLookup(PREFERENCES, 565 pref_node.InitByClientTagLookup(PREFERENCES,
(...skipping 13 matching lines...) Expand all
583 ReadNode root_node(&trans); 579 ReadNode root_node(&trans);
584 root_node.InitByRootLookup(); 580 root_node.InitByRootLookup();
585 581
586 WriteNode bookmark_node(&trans); 582 WriteNode bookmark_node(&trans);
587 ASSERT_TRUE(bookmark_node.InitBookmarkByCreation(root_node, NULL)); 583 ASSERT_TRUE(bookmark_node.InitBookmarkByCreation(root_node, NULL));
588 bookmark_id = bookmark_node.GetId(); 584 bookmark_id = bookmark_node.GetId();
589 bookmark_node.SetTitle(""); 585 bookmark_node.SetTitle("");
590 } 586 }
591 { 587 {
592 ReadTransaction trans(FROM_HERE, user_share()); 588 ReadTransaction trans(FROM_HERE, user_share());
593 ReadNode root_node(&trans);
594 root_node.InitByRootLookup();
595 589
596 ReadNode bookmark_node(&trans); 590 ReadNode bookmark_node(&trans);
597 ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id)); 591 ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id));
598 EXPECT_EQ("", bookmark_node.GetTitle()); 592 EXPECT_EQ("", bookmark_node.GetTitle());
599 EXPECT_EQ(" ", bookmark_node.GetEntry()->GetSpecifics().bookmark().title()); 593 EXPECT_EQ(" ", bookmark_node.GetEntry()->GetSpecifics().bookmark().title());
600 EXPECT_EQ(" ", bookmark_node.GetEntry()->GetNonUniqueName()); 594 EXPECT_EQ(" ", bookmark_node.GetEntry()->GetNonUniqueName());
601 } 595 }
602 } 596 }
603 597
604 TEST_F(SyncApiTest, BaseNodeSetSpecifics) { 598 TEST_F(SyncApiTest, BaseNodeSetSpecifics) {
(...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 // SyncManagerInitInvalidStorageTest::GetFactory will return 3320 // SyncManagerInitInvalidStorageTest::GetFactory will return
3327 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3321 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3328 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3322 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3329 // task is to ensure that SyncManagerImpl reported initialization failure in 3323 // task is to ensure that SyncManagerImpl reported initialization failure in
3330 // OnInitializationComplete callback. 3324 // OnInitializationComplete callback.
3331 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3325 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3332 EXPECT_FALSE(initialization_succeeded_); 3326 EXPECT_FALSE(initialization_succeeded_);
3333 } 3327 }
3334 3328
3335 } // namespace syncer 3329 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698