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

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

Issue 1134793006: [Sync] WriteNode::SetTitle doesn't update bookmark title when it is empty string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small change after Nicolas' feedback. Created 5 years, 7 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
« no previous file with comments | « no previous file | sync/internal_api/write_node.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | sync/internal_api/write_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698