| 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 // TODO(akalin): This file is basically just a unit test for | 5 // TODO(akalin): This file is basically just a unit test for |
| 6 // BookmarkChangeProcessor. Write unit tests for | 6 // BookmarkChangeProcessor. Write unit tests for |
| 7 // BookmarkModelAssociator separately. | 7 // BookmarkModelAssociator separately. |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/strings/string16.h" | 25 #include "base/strings/string16.h" |
| 26 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
| 27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
| 28 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
| 29 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
| 30 #include "base/time/time.h" | 30 #include "base/time/time.h" |
| 31 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| 32 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 32 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
| 33 #include "components/bookmarks/browser/bookmark_model.h" | 33 #include "components/bookmarks/browser/bookmark_model.h" |
| 34 #include "components/bookmarks/browser/bookmark_utils.h" | 34 #include "components/bookmarks/browser/bookmark_utils.h" |
| 35 #include "components/bookmarks/browser/offline_page_bookmark_observer.h" |
| 35 #include "components/bookmarks/managed/managed_bookmark_service.h" | 36 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 36 #include "components/bookmarks/test/bookmark_test_helpers.h" | 37 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 38 #include "components/bookmarks/test/mock_bookmark_model_observer.h" |
| 37 #include "components/bookmarks/test/test_bookmark_client.h" | 39 #include "components/bookmarks/test/test_bookmark_client.h" |
| 38 #include "components/browser_sync/browser/profile_sync_test_util.h" | 40 #include "components/browser_sync/browser/profile_sync_test_util.h" |
| 39 #include "components/sync/api/sync_error.h" | 41 #include "components/sync/api/sync_error.h" |
| 40 #include "components/sync/api/sync_merge_result.h" | 42 #include "components/sync/api/sync_merge_result.h" |
| 41 #include "components/sync/core/change_record.h" | 43 #include "components/sync/core/change_record.h" |
| 42 #include "components/sync/core/data_type_error_handler.h" | 44 #include "components/sync/core/data_type_error_handler.h" |
| 43 #include "components/sync/core/read_node.h" | 45 #include "components/sync/core/read_node.h" |
| 44 #include "components/sync/core/read_transaction.h" | 46 #include "components/sync/core/read_transaction.h" |
| 45 #include "components/sync/core/test/data_type_error_handler_mock.h" | 47 #include "components/sync/core/test/data_type_error_handler_mock.h" |
| 46 #include "components/sync/core/test/test_user_share.h" | 48 #include "components/sync/core/test/test_user_share.h" |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 node.SetBookmarkSpecifics(specifics); | 433 node.SetBookmarkSpecifics(specifics); |
| 432 | 434 |
| 433 return node.GetId(); | 435 return node.GetId(); |
| 434 } | 436 } |
| 435 | 437 |
| 436 // Create a BookmarkModel. If |delete_bookmarks| is true, the bookmarks file | 438 // Create a BookmarkModel. If |delete_bookmarks| is true, the bookmarks file |
| 437 // will be deleted before starting up the BookmarkModel. | 439 // will be deleted before starting up the BookmarkModel. |
| 438 std::unique_ptr<BookmarkModel> CreateBookmarkModel(bool delete_bookmarks) { | 440 std::unique_ptr<BookmarkModel> CreateBookmarkModel(bool delete_bookmarks) { |
| 439 const base::FilePath& data_path = data_dir_.path(); | 441 const base::FilePath& data_path = data_dir_.path(); |
| 440 auto model = base::MakeUnique<BookmarkModel>( | 442 auto model = base::MakeUnique<BookmarkModel>( |
| 441 base::WrapUnique(new bookmarks::TestBookmarkClient())); | 443 base::WrapUnique(new bookmarks::TestBookmarkClient()), |
| 444 base::WrapUnique(new bookmarks::OfflinePageBookmarkObserver())); |
| 442 managed_bookmark_service_->BookmarkModelCreated(model.get()); | 445 managed_bookmark_service_->BookmarkModelCreated(model.get()); |
| 443 int64_t next_id = 0; | 446 int64_t next_id = 0; |
| 444 static_cast<bookmarks::TestBookmarkClient*>(model->client()) | 447 static_cast<bookmarks::TestBookmarkClient*>(model->client()) |
| 445 ->SetExtraNodesToLoad( | 448 ->SetExtraNodesToLoad( |
| 446 managed_bookmark_service_->GetLoadExtraNodesCallback().Run( | 449 managed_bookmark_service_->GetLoadExtraNodesCallback().Run( |
| 447 &next_id)); | 450 &next_id)); |
| 448 if (delete_bookmarks) { | 451 if (delete_bookmarks) { |
| 449 base::DeleteFile(data_path.Append(FILE_PATH_LITERAL("dummy_bookmarks")), | 452 base::DeleteFile(data_path.Append(FILE_PATH_LITERAL("dummy_bookmarks")), |
| 450 false); | 453 false); |
| 451 } | 454 } |
| (...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 EXPECT_EQ(syncer::kInvalidId, sync_id); | 2588 EXPECT_EQ(syncer::kInvalidId, sync_id); |
| 2586 | 2589 |
| 2587 // Verify that Sync ignores deleting this node. | 2590 // Verify that Sync ignores deleting this node. |
| 2588 model()->Remove(node); | 2591 model()->Remove(node); |
| 2589 EXPECT_EQ(sync_bookmark_count, GetSyncBookmarkCount()); | 2592 EXPECT_EQ(sync_bookmark_count, GetSyncBookmarkCount()); |
| 2590 } | 2593 } |
| 2591 | 2594 |
| 2592 } // namespace | 2595 } // namespace |
| 2593 | 2596 |
| 2594 } // namespace browser_sync | 2597 } // namespace browser_sync |
| OLD | NEW |