| OLD | NEW |
| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 bookmark_node.GetEntry()->GetNonUniqueName()); | 565 bookmark_node.GetEntry()->GetNonUniqueName()); |
| 566 | 566 |
| 567 ReadNode pref_node(&trans); | 567 ReadNode pref_node(&trans); |
| 568 ASSERT_EQ(BaseNode::INIT_OK, | 568 ASSERT_EQ(BaseNode::INIT_OK, |
| 569 pref_node.InitByClientTagLookup(PREFERENCES, | 569 pref_node.InitByClientTagLookup(PREFERENCES, |
| 570 "bar")); | 570 "bar")); |
| 571 EXPECT_EQ(kEncryptedString, pref_node.GetTitle()); | 571 EXPECT_EQ(kEncryptedString, pref_node.GetTitle()); |
| 572 } | 572 } |
| 573 } | 573 } |
| 574 | 574 |
| 575 // Non-unique name should not be empty. For bookmarks non-unique name is copied |
| 576 // from bookmark title. This test verifies that setting bookmark title to "" |
| 577 // results in single space title and non-unique name in internal representation. |
| 578 // GetTitle should still return empty string. |
| 579 TEST_F(SyncApiTest, WriteEmptyBookmarkTitle) { |
| 580 int bookmark_id; |
| 581 { |
| 582 WriteTransaction trans(FROM_HERE, user_share()); |
| 583 ReadNode root_node(&trans); |
| 584 root_node.InitByRootLookup(); |
| 585 |
| 586 WriteNode bookmark_node(&trans); |
| 587 ASSERT_TRUE(bookmark_node.InitBookmarkByCreation(root_node, NULL)); |
| 588 bookmark_id = bookmark_node.GetId(); |
| 589 bookmark_node.SetTitle(""); |
| 590 } |
| 591 { |
| 592 ReadTransaction trans(FROM_HERE, user_share()); |
| 593 ReadNode root_node(&trans); |
| 594 root_node.InitByRootLookup(); |
| 595 |
| 596 ReadNode bookmark_node(&trans); |
| 597 ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id)); |
| 598 EXPECT_EQ("", bookmark_node.GetTitle()); |
| 599 EXPECT_EQ(" ", bookmark_node.GetEntry()->GetSpecifics().bookmark().title()); |
| 600 EXPECT_EQ(" ", bookmark_node.GetEntry()->GetNonUniqueName()); |
| 601 } |
| 602 } |
| 603 |
| 575 TEST_F(SyncApiTest, BaseNodeSetSpecifics) { | 604 TEST_F(SyncApiTest, BaseNodeSetSpecifics) { |
| 576 int64 child_id = MakeNodeWithRoot(user_share(), BOOKMARKS, "testtag"); | 605 int64 child_id = MakeNodeWithRoot(user_share(), BOOKMARKS, "testtag"); |
| 577 WriteTransaction trans(FROM_HERE, user_share()); | 606 WriteTransaction trans(FROM_HERE, user_share()); |
| 578 WriteNode node(&trans); | 607 WriteNode node(&trans); |
| 579 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(child_id)); | 608 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(child_id)); |
| 580 | 609 |
| 581 sync_pb::EntitySpecifics entity_specifics; | 610 sync_pb::EntitySpecifics entity_specifics; |
| 582 entity_specifics.mutable_bookmark()->set_url("http://www.google.com"); | 611 entity_specifics.mutable_bookmark()->set_url("http://www.google.com"); |
| 583 | 612 |
| 584 EXPECT_NE(entity_specifics.SerializeAsString(), | 613 EXPECT_NE(entity_specifics.SerializeAsString(), |
| (...skipping 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 // SyncManagerInitInvalidStorageTest::GetFactory will return | 3226 // SyncManagerInitInvalidStorageTest::GetFactory will return |
| 3198 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. | 3227 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. |
| 3199 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's | 3228 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's |
| 3200 // task is to ensure that SyncManagerImpl reported initialization failure in | 3229 // task is to ensure that SyncManagerImpl reported initialization failure in |
| 3201 // OnInitializationComplete callback. | 3230 // OnInitializationComplete callback. |
| 3202 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { | 3231 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { |
| 3203 EXPECT_FALSE(initialization_succeeded_); | 3232 EXPECT_FALSE(initialization_succeeded_); |
| 3204 } | 3233 } |
| 3205 | 3234 |
| 3206 } // namespace syncer | 3235 } // namespace syncer |
| OLD | NEW |