| 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/browser/bookmark_expanded_state_tracker.h" | 5 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "components/bookmarks/browser/bookmark_model.h" | 14 #include "components/bookmarks/browser/bookmark_model.h" |
| 15 #include "components/bookmarks/browser/offline_page_bookmark_observer.h" |
| 15 #include "components/bookmarks/common/bookmark_pref_names.h" | 16 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 16 #include "components/bookmarks/test/bookmark_test_helpers.h" | 17 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 17 #include "components/bookmarks/test/test_bookmark_client.h" | 18 #include "components/bookmarks/test/test_bookmark_client.h" |
| 18 #include "components/prefs/pref_registry_simple.h" | 19 #include "components/prefs/pref_registry_simple.h" |
| 19 #include "components/prefs/testing_pref_service.h" | 20 #include "components/prefs/testing_pref_service.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 namespace bookmarks { | 23 namespace bookmarks { |
| 23 | 24 |
| 24 class BookmarkExpandedStateTrackerTest : public testing::Test { | 25 class BookmarkExpandedStateTrackerTest : public testing::Test { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 BookmarkExpandedStateTrackerTest::BookmarkExpandedStateTrackerTest() {} | 42 BookmarkExpandedStateTrackerTest::BookmarkExpandedStateTrackerTest() {} |
| 42 | 43 |
| 43 BookmarkExpandedStateTrackerTest::~BookmarkExpandedStateTrackerTest() {} | 44 BookmarkExpandedStateTrackerTest::~BookmarkExpandedStateTrackerTest() {} |
| 44 | 45 |
| 45 void BookmarkExpandedStateTrackerTest::SetUp() { | 46 void BookmarkExpandedStateTrackerTest::SetUp() { |
| 46 prefs_.registry()->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, | 47 prefs_.registry()->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, |
| 47 new base::ListValue); | 48 new base::ListValue); |
| 48 prefs_.registry()->RegisterListPref(prefs::kManagedBookmarks); | 49 prefs_.registry()->RegisterListPref(prefs::kManagedBookmarks); |
| 49 model_.reset(new BookmarkModel(base::WrapUnique(new TestBookmarkClient()))); | 50 model_.reset( |
| 51 new BookmarkModel(base::MakeUnique<TestBookmarkClient>(), |
| 52 base::MakeUnique<OfflinePageBookmarkObserver>())); |
| 50 model_->Load(&prefs_, base::FilePath(), | 53 model_->Load(&prefs_, base::FilePath(), |
| 51 base::ThreadTaskRunnerHandle::Get(), | 54 base::ThreadTaskRunnerHandle::Get(), |
| 52 base::ThreadTaskRunnerHandle::Get()); | 55 base::ThreadTaskRunnerHandle::Get()); |
| 53 test::WaitForBookmarkModelToLoad(model_.get()); | 56 test::WaitForBookmarkModelToLoad(model_.get()); |
| 54 } | 57 } |
| 55 | 58 |
| 56 void BookmarkExpandedStateTrackerTest::TearDown() { | 59 void BookmarkExpandedStateTrackerTest::TearDown() { |
| 57 model_.reset(); | 60 model_.reset(); |
| 58 base::RunLoop().RunUntilIdle(); | 61 base::RunLoop().RunUntilIdle(); |
| 59 } | 62 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 tracker->SetExpandedNodes(nodes); | 98 tracker->SetExpandedNodes(nodes); |
| 96 // Verify that the node is present. | 99 // Verify that the node is present. |
| 97 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); | 100 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); |
| 98 // Call remove all. | 101 // Call remove all. |
| 99 model_->RemoveAllUserBookmarks(); | 102 model_->RemoveAllUserBookmarks(); |
| 100 // Verify node is not present. | 103 // Verify node is not present. |
| 101 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); | 104 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); |
| 102 } | 105 } |
| 103 | 106 |
| 104 } // namespace bookmarks | 107 } // namespace bookmarks |
| OLD | NEW |