| 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/bookmarks/managed/managed_bookmarks_tracker.h" | 5 #include "components/bookmarks/managed/managed_bookmarks_tracker.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "components/bookmarks/browser/bookmark_model.h" | 16 #include "components/bookmarks/browser/bookmark_model.h" |
| 17 #include "components/bookmarks/browser/bookmark_model_observer.h" | 17 #include "components/bookmarks/browser/bookmark_model_observer.h" |
| 18 #include "components/bookmarks/browser/bookmark_node.h" | 18 #include "components/bookmarks/browser/bookmark_node.h" |
| 19 #include "components/bookmarks/browser/bookmark_utils.h" | 19 #include "components/bookmarks/browser/bookmark_utils.h" |
| 20 #include "components/bookmarks/browser/offline_page_bookmark_observer.h" |
| 20 #include "components/bookmarks/common/bookmark_pref_names.h" | 21 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 21 #include "components/bookmarks/test/bookmark_test_helpers.h" | 22 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 22 #include "components/bookmarks/test/mock_bookmark_model_observer.h" | 23 #include "components/bookmarks/test/mock_bookmark_model_observer.h" |
| 23 #include "components/bookmarks/test/test_bookmark_client.h" | 24 #include "components/bookmarks/test/test_bookmark_client.h" |
| 24 #include "components/prefs/pref_registry_simple.h" | 25 #include "components/prefs/pref_registry_simple.h" |
| 25 #include "components/prefs/testing_pref_service.h" | 26 #include "components/prefs/testing_pref_service.h" |
| 26 #include "grit/components_strings.h" | 27 #include "grit/components_strings.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 59 managed_node->set_visible(!managed_node->empty()); | 60 managed_node->set_visible(!managed_node->empty()); |
| 60 managed_node->SetTitle(l10n_util::GetStringUTF16( | 61 managed_node->SetTitle(l10n_util::GetStringUTF16( |
| 61 is_supervised ? IDS_BOOKMARK_BAR_SUPERVISED_FOLDER_DEFAULT_NAME | 62 is_supervised ? IDS_BOOKMARK_BAR_SUPERVISED_FOLDER_DEFAULT_NAME |
| 62 : IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME)); | 63 : IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME)); |
| 63 | 64 |
| 64 BookmarkPermanentNodeList extra_nodes; | 65 BookmarkPermanentNodeList extra_nodes; |
| 65 extra_nodes.push_back(managed_node); | 66 extra_nodes.push_back(managed_node); |
| 66 | 67 |
| 67 std::unique_ptr<TestBookmarkClient> client(new TestBookmarkClient); | 68 std::unique_ptr<TestBookmarkClient> client(new TestBookmarkClient); |
| 68 client->SetExtraNodesToLoad(std::move(extra_nodes)); | 69 client->SetExtraNodesToLoad(std::move(extra_nodes)); |
| 69 model_.reset(new BookmarkModel(std::move(client))); | 70 std::unique_ptr<OfflinePageBookmarkObserver> observer( |
| 71 new OfflinePageBookmarkObserver); |
| 72 model_.reset(new BookmarkModel(std::move(client), std::move(observer))); |
| 70 | 73 |
| 71 model_->AddObserver(&observer_); | 74 model_->AddObserver(&observer_); |
| 72 EXPECT_CALL(observer_, BookmarkModelLoaded(model_.get(), _)); | 75 EXPECT_CALL(observer_, BookmarkModelLoaded(model_.get(), _)); |
| 73 model_->Load(&prefs_, base::FilePath(), | 76 model_->Load(&prefs_, base::FilePath(), |
| 74 base::ThreadTaskRunnerHandle::Get(), | 77 base::ThreadTaskRunnerHandle::Get(), |
| 75 base::ThreadTaskRunnerHandle::Get()); | 78 base::ThreadTaskRunnerHandle::Get()); |
| 76 test::WaitForBookmarkModelToLoad(model_.get()); | 79 test::WaitForBookmarkModelToLoad(model_.get()); |
| 77 Mock::VerifyAndClearExpectations(&observer_); | 80 Mock::VerifyAndClearExpectations(&observer_); |
| 78 | 81 |
| 79 TestBookmarkClient* client_ptr = | 82 TestBookmarkClient* client_ptr = |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 Mock::VerifyAndClearExpectations(&observer_); | 355 Mock::VerifyAndClearExpectations(&observer_); |
| 353 | 356 |
| 354 EXPECT_CALL(observer_, BookmarkAllUserNodesRemoved(model_.get(), _)); | 357 EXPECT_CALL(observer_, BookmarkAllUserNodesRemoved(model_.get(), _)); |
| 355 model_->RemoveAllUserBookmarks(); | 358 model_->RemoveAllUserBookmarks(); |
| 356 EXPECT_EQ(2, managed_node()->child_count()); | 359 EXPECT_EQ(2, managed_node()->child_count()); |
| 357 EXPECT_EQ(0, model_->bookmark_bar_node()->child_count()); | 360 EXPECT_EQ(0, model_->bookmark_bar_node()->child_count()); |
| 358 Mock::VerifyAndClearExpectations(&observer_); | 361 Mock::VerifyAndClearExpectations(&observer_); |
| 359 } | 362 } |
| 360 | 363 |
| 361 } // namespace bookmarks | 364 } // namespace bookmarks |
| OLD | NEW |