Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
| 7 #include "chrome/browser/sync/profile_sync_service.h" | 7 #include "chrome/browser/sync/profile_sync_service.h" |
| 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h" | |
| 9 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 10 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
| 10 #include "chrome/browser/sync/test/integration/sync_test.h" | 11 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 11 #include "components/bookmarks/browser/bookmark_model.h" | 12 #include "components/bookmarks/browser/bookmark_model.h" |
| 12 #include "sync/test/fake_server/bookmark_entity_builder.h" | 13 #include "sync/test/fake_server/bookmark_entity_builder.h" |
| 13 #include "sync/test/fake_server/entity_builder_factory.h" | 14 #include "sync/test/fake_server/entity_builder_factory.h" |
| 14 #include "sync/test/fake_server/fake_server_verifier.h" | 15 #include "sync/test/fake_server/fake_server_verifier.h" |
| 16 #include "sync/test/fake_server/tombstone_entity.h" | |
| 15 #include "ui/base/layout.h" | 17 #include "ui/base/layout.h" |
| 16 | 18 |
| 17 using bookmarks::BookmarkModel; | 19 using bookmarks::BookmarkModel; |
| 18 using bookmarks::BookmarkNode; | 20 using bookmarks::BookmarkNode; |
| 19 using bookmarks_helper::AddFolder; | 21 using bookmarks_helper::AddFolder; |
| 20 using bookmarks_helper::AddURL; | 22 using bookmarks_helper::AddURL; |
| 23 using bookmarks_helper::AwaitCountBookmarksWithTitlesMatching; | |
| 21 using bookmarks_helper::CountBookmarksWithTitlesMatching; | 24 using bookmarks_helper::CountBookmarksWithTitlesMatching; |
| 22 using bookmarks_helper::Create1xFaviconFromPNGFile; | 25 using bookmarks_helper::Create1xFaviconFromPNGFile; |
| 23 using bookmarks_helper::GetBookmarkBarNode; | 26 using bookmarks_helper::GetBookmarkBarNode; |
| 24 using bookmarks_helper::GetBookmarkModel; | 27 using bookmarks_helper::GetBookmarkModel; |
| 25 using bookmarks_helper::GetOtherNode; | 28 using bookmarks_helper::GetOtherNode; |
| 26 using bookmarks_helper::ModelMatchesVerifier; | 29 using bookmarks_helper::ModelMatchesVerifier; |
| 27 using bookmarks_helper::Move; | 30 using bookmarks_helper::Move; |
| 28 using bookmarks_helper::Remove; | 31 using bookmarks_helper::Remove; |
| 29 using bookmarks_helper::RemoveAll; | 32 using bookmarks_helper::RemoveAll; |
| 30 using bookmarks_helper::SetFavicon; | 33 using bookmarks_helper::SetFavicon; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 290 |
| 288 // Remove all bookmarks and wait for sync completion. | 291 // Remove all bookmarks and wait for sync completion. |
| 289 RemoveAll(0); | 292 RemoveAll(0); |
| 290 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 293 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| 291 // Verify other node has no children now. | 294 // Verify other node has no children now. |
| 292 EXPECT_EQ(0, GetOtherNode(0)->child_count()); | 295 EXPECT_EQ(0, GetOtherNode(0)->child_count()); |
| 293 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count()); | 296 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count()); |
| 294 // Verify model matches verifier. | 297 // Verify model matches verifier. |
| 295 ASSERT_TRUE(ModelMatchesVerifier(0)); | 298 ASSERT_TRUE(ModelMatchesVerifier(0)); |
| 296 } | 299 } |
| 300 | |
| 301 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, | |
| 302 DownloadDeletedBookmark) { | |
| 303 std::string title = "Patrick Star"; | |
| 304 fake_server::EntityBuilderFactory entity_builder_factory; | |
| 305 scoped_ptr<fake_server::FakeServerEntity> entity = | |
| 306 entity_builder_factory.NewBookmarkEntityBuilder( | |
| 307 title, GURL("http://en.wikipedia.org/wiki/Patrick_Star")).Build(); | |
| 308 fake_server_->InjectEntity(entity.Pass()); | |
| 309 | |
| 310 DisableVerifier(); | |
| 311 ASSERT_TRUE(SetupSync()); | |
| 312 | |
| 313 ASSERT_EQ(1, CountBookmarksWithTitlesMatching(0, title)); | |
| 314 | |
| 315 std::vector<sync_pb::SyncEntity> server_bookmarks = | |
| 316 GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS); | |
| 317 ASSERT_EQ(1ul, server_bookmarks.size()); | |
| 318 std::string entity_id = server_bookmarks[0].id_string(); | |
| 319 scoped_ptr<fake_server::FakeServerEntity> tombstone( | |
| 320 fake_server::TombstoneEntity::Create(entity_id)); | |
| 321 GetFakeServer()->InjectEntity(tombstone.Pass()); | |
| 322 | |
| 323 const syncer::ModelTypeSet kBookmarksType(syncer::BOOKMARKS); | |
| 324 TriggerSyncForModelTypes(0, kBookmarksType); | |
| 325 | |
| 326 ASSERT_TRUE(AwaitCountBookmarksWithTitlesMatching(0 /* profile */, | |
|
maniscalco
2015/05/08 20:13:18
nit: I like how you added a comment here to the re
pval...(no longer on Chromium)
2015/05/08 22:34:19
constant added in this file. PTAL.
I think we cou
maniscalco
2015/05/08 23:56:14
Agreed.
| |
| 327 title, | |
| 328 0 /* expected_count */)); | |
| 329 } | |
| OLD | NEW |