| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/sync/engine_impl/directory_commit_contribution.h" | 5 #include "components/sync/engine_impl/directory_commit_contribution.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 sync_pb::ClientToServerMessage message; | 313 sync_pb::ClientToServerMessage message; |
| 314 bm_cc->AddToCommitMessage(&message); | 314 bm_cc->AddToCommitMessage(&message); |
| 315 const sync_pb::CommitMessage& commit_message = message.commit(); | 315 const sync_pb::CommitMessage& commit_message = message.commit(); |
| 316 bm_cc->CleanUp(); | 316 bm_cc->CleanUp(); |
| 317 | 317 |
| 318 ASSERT_EQ(1, commit_message.entries_size()); | 318 ASSERT_EQ(1, commit_message.entries_size()); |
| 319 EXPECT_TRUE(commit_message.entries(0).has_parent_id_string()); | 319 EXPECT_TRUE(commit_message.entries(0).has_parent_id_string()); |
| 320 EXPECT_FALSE(commit_message.entries(0).parent_id_string().empty()); | 320 EXPECT_FALSE(commit_message.entries(0).parent_id_string().empty()); |
| 321 } | 321 } |
| 322 | 322 |
| 323 TEST_F(DirectoryCommitContributionTest, |
| 324 HierarchySupport_BookmarkMissingParent) { |
| 325 // Create a bookmark item that references an unknown client parent id. |
| 326 int64_t bm1; |
| 327 { |
| 328 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
| 329 bm1 = CreateSyncedItem(&trans, BOOKMARKS, "bm1"); |
| 330 syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, bm1); |
| 331 |
| 332 sync_pb::EntitySpecifics specifics; |
| 333 sync_pb::BookmarkSpecifics* bm_specifics = specifics.mutable_bookmark(); |
| 334 bm_specifics->set_url("http://www.chrome.com"); |
| 335 bm_specifics->set_title("Chrome"); |
| 336 e.PutSpecifics(specifics); |
| 337 e.PutIsDel(false); |
| 338 e.PutIsUnsynced(true); |
| 339 e.PutParentId(syncable::Id::CreateFromClientString("does not exist")); |
| 340 |
| 341 EXPECT_TRUE(e.ShouldMaintainHierarchy()); |
| 342 } |
| 343 |
| 344 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); |
| 345 // Because the above bookmark is skipped, there are no contributions and so |
| 346 // expect a null DirectoryCommitContribution back. |
| 347 EXPECT_EQ( |
| 348 nullptr, |
| 349 DirectoryCommitContribution::Build(dir(), BOOKMARKS, 25, &emitter).get()); |
| 350 } |
| 351 |
| 323 // Test that preferences do not support hierarchy. | 352 // Test that preferences do not support hierarchy. |
| 324 TEST_F(DirectoryCommitContributionTest, HierarchySupport_Preferences) { | 353 TEST_F(DirectoryCommitContributionTest, HierarchySupport_Preferences) { |
| 325 // Create a normal-looking prefs item. | 354 // Create a normal-looking prefs item. |
| 326 int64_t pref1; | 355 int64_t pref1; |
| 327 { | 356 { |
| 328 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 357 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
| 329 pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); | 358 pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); |
| 330 syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, pref1); | 359 syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, pref1); |
| 331 | 360 |
| 332 EXPECT_FALSE(e.ShouldMaintainHierarchy()); | 361 EXPECT_FALSE(e.ShouldMaintainHierarchy()); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 EXPECT_FALSE(a3.GetId().ServerKnows()); | 526 EXPECT_FALSE(a3.GetId().ServerKnows()); |
| 498 EXPECT_FALSE(a3.GetSyncing()); | 527 EXPECT_FALSE(a3.GetSyncing()); |
| 499 EXPECT_FALSE(a3.GetDirtySync()); | 528 EXPECT_FALSE(a3.GetDirtySync()); |
| 500 EXPECT_EQ(0, a3.GetServerVersion()); | 529 EXPECT_EQ(0, a3.GetServerVersion()); |
| 501 } | 530 } |
| 502 | 531 |
| 503 art_cc->CleanUp(); | 532 art_cc->CleanUp(); |
| 504 } | 533 } |
| 505 | 534 |
| 506 } // namespace syncer | 535 } // namespace syncer |
| OLD | NEW |