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

Unified Diff: sync/engine/directory_update_handler_unittest.cc

Issue 805633004: Enable Null Syncable ID which is different than Root ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/commit_util.cc ('k') | sync/engine/get_commit_ids.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/directory_update_handler_unittest.cc
diff --git a/sync/engine/directory_update_handler_unittest.cc b/sync/engine/directory_update_handler_unittest.cc
index e7518ff6b9ff13673a071eda1269294b07e73a7a..ed597c7c73dfb9f69cfdc44062c97c3e61eb08f9 100644
--- a/sync/engine/directory_update_handler_unittest.cc
+++ b/sync/engine/directory_update_handler_unittest.cc
@@ -29,6 +29,7 @@
namespace syncer {
+using syncable::Id;
using syncable::UNITTEST;
static const int64 kDefaultVersion = 1000;
@@ -83,7 +84,7 @@ class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
bool EntryExists(const std::string& id) {
syncable::ReadTransaction trans(FROM_HERE, dir());
syncable::Entry e(&trans, syncable::GET_BY_ID,
- syncable::Id::CreateFromServerId(id));
+ Id::CreateFromServerId(id));
return e.good() && !e.GetIsDel();
}
@@ -136,13 +137,13 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) {
sessions::StatusController status;
// Add a bookmark item to the update message.
- std::string root = syncable::GetNullId().GetServerId();
- syncable::Id server_id = syncable::Id::CreateFromServerId("b1");
+ std::string root = Id::GetRoot().GetServerId();
+ Id server_id = Id::CreateFromServerId("b1");
scoped_ptr<sync_pb::SyncEntity> e =
CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS);
e->set_originator_cache_guid(
std::string(kCacheGuid, arraysize(kCacheGuid)-1));
- syncable::Id client_id = syncable::Id::CreateFromClientString("-2");
+ Id client_id = Id::CreateFromClientString("-2");
e->set_originator_client_item_id(client_id.GetServerId());
e->set_position_in_parent(0);
@@ -175,8 +176,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest,
sessions::StatusController status;
// Create an update that mimics the bookmark root.
- syncable::Id server_id = syncable::Id::CreateFromServerId("xyz");
- std::string root = syncable::GetNullId().GetServerId();
+ Id server_id = Id::CreateFromServerId("xyz");
+ std::string root = Id::GetRoot().GetServerId();
scoped_ptr<sync_pb::SyncEntity> e =
CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS);
e->set_server_defined_unique_tag("google_chrome_bookmarks");
@@ -209,8 +210,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ReceiveNonBookmarkItem) {
sync_pb::GetUpdatesResponse gu_response;
sessions::StatusController status;
- std::string root = syncable::GetNullId().GetServerId();
- syncable::Id server_id = syncable::Id::CreateFromServerId("xyz");
+ std::string root = Id::GetRoot().GetServerId();
+ Id server_id = Id::CreateFromServerId("xyz");
scoped_ptr<sync_pb::SyncEntity> e =
CreateUpdate(SyncableIdToProto(server_id), root, AUTOFILL);
e->set_server_defined_unique_tag("9PGRuKdX5sHyGMB17CvYTXuC43I=");
@@ -271,20 +272,19 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, GarbageCollectionByVersion) {
context.set_version(1);
scoped_ptr<sync_pb::SyncEntity> type_root =
- CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")),
- syncable::GetNullId().GetServerId(),
- SYNCED_NOTIFICATIONS);
+ CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("root")),
+ Id::GetRoot().GetServerId(), SYNCED_NOTIFICATIONS);
type_root->set_server_defined_unique_tag(
ModelTypeToRootTag(SYNCED_NOTIFICATIONS));
type_root->set_folder(true);
scoped_ptr<sync_pb::SyncEntity> e1 =
- CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")),
+ CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e1")),
type_root->id_string(),
SYNCED_NOTIFICATIONS);
scoped_ptr<sync_pb::SyncEntity> e2 =
- CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e2")),
+ CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e2")),
type_root->id_string(),
SYNCED_NOTIFICATIONS);
e2->set_version(kDefaultVersion + 100);
@@ -335,14 +335,13 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ContextVersion) {
old_context.set_data_type_id(field_number);
scoped_ptr<sync_pb::SyncEntity> type_root =
- CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")),
- syncable::GetNullId().GetServerId(),
- SYNCED_NOTIFICATIONS);
+ CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("root")),
+ Id::GetRoot().GetServerId(), SYNCED_NOTIFICATIONS);
type_root->set_server_defined_unique_tag(
ModelTypeToRootTag(SYNCED_NOTIFICATIONS));
type_root->set_folder(true);
scoped_ptr<sync_pb::SyncEntity> e1 =
- CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")),
+ CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e1")),
type_root->id_string(),
SYNCED_NOTIFICATIONS);
@@ -373,7 +372,7 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ContextVersion) {
new_context.set_data_type_id(field_number);
scoped_ptr<sync_pb::SyncEntity> e2 =
- CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e2")),
+ CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e2")),
type_root->id_string(),
SYNCED_NOTIFICATIONS);
updates.clear();
@@ -416,14 +415,13 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest,
context.set_version(1);
scoped_ptr<sync_pb::SyncEntity> type_root =
- CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")),
- syncable::GetNullId().GetServerId(),
- ARTICLES);
+ CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("root")),
+ Id::GetRoot().GetServerId(), ARTICLES);
type_root->set_server_defined_unique_tag(ModelTypeToRootTag(ARTICLES));
type_root->set_folder(true);
scoped_ptr<sync_pb::SyncEntity> e1 =
- CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")),
+ CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e1")),
type_root->id_string(),
ARTICLES);
sync_pb::AttachmentIdProto* attachment_id = e1->add_attachment_id();
@@ -445,7 +443,7 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest,
syncable::ReadTransaction trans(FROM_HERE, dir());
syncable::Entry e(&trans,
syncable::GET_BY_ID,
- syncable::Id::CreateFromServerId(e1->id_string()));
+ Id::CreateFromServerId(e1->id_string()));
// See that the attachment_metadata is correct.
sync_pb::AttachmentMetadata attachment_metadata = e.GetAttachmentMetadata();
@@ -575,7 +573,7 @@ sync_pb::EntitySpecifics DefaultBookmarkSpecifics() {
TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SimpleBookmark) {
sessions::StatusController status;
- std::string root_server_id = syncable::GetNullId().GetServerId();
+ std::string root_server_id = Id::GetRoot().GetServerId();
int64 parent_handle =
entry_factory()->CreateUnappliedNewBookmarkItemWithParent(
"parent", DefaultBookmarkSpecifics(), root_server_id);
@@ -613,7 +611,7 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SimpleBookmark) {
TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
BookmarkChildrenBeforeParent) {
// Start with some bookmarks whose parents are unknown.
- std::string root_server_id = syncable::GetNullId().GetServerId();
+ std::string root_server_id = Id::GetRoot().GetServerId();
int64 a_handle = entry_factory()->CreateUnappliedNewBookmarkItemWithParent(
"a_child_created_first", DefaultBookmarkSpecifics(), "parent");
int64 x_handle = entry_factory()->CreateUnappliedNewBookmarkItemWithParent(
@@ -790,7 +788,7 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
// Create a locally deleted parent item.
int64 parent_handle;
entry_factory()->CreateUnsyncedItem(
- syncable::Id::CreateFromServerId("parent"), TestIdFactory::root(),
+ Id::CreateFromServerId("parent"), TestIdFactory::root(),
"parent", true, BOOKMARKS, &parent_handle);
{
syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
@@ -903,7 +901,7 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
// fail due to hierarchy conflicts. Others should succeed.
TEST_F(DirectoryUpdateHandlerApplyUpdateTest, ItemsBothKnownAndUnknown) {
// See what happens when there's a mixture of good and bad updates.
- std::string root_server_id = syncable::GetNullId().GetServerId();
+ std::string root_server_id = Id::GetRoot().GetServerId();
int64 u1_handle = entry_factory()->CreateUnappliedNewItemWithParent(
"first_unknown_item", DefaultBookmarkSpecifics(), "unknown_parent");
int64 k1_handle = entry_factory()->CreateUnappliedNewItemWithParent(
@@ -994,7 +992,7 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest, UndecryptableData) {
sync_pb::EntitySpecifics encrypted_bookmark;
encrypted_bookmark.mutable_encrypted();
AddDefaultFieldValue(BOOKMARKS, &encrypted_bookmark);
- std::string root_server_id = syncable::GetNullId().GetServerId();
+ std::string root_server_id = Id::GetRoot().GetServerId();
int64 folder_handle = entry_factory()->CreateUnappliedNewItemWithParent(
"folder",
encrypted_bookmark,
« no previous file with comments | « sync/engine/commit_util.cc ('k') | sync/engine/get_commit_ids.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698