| 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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 12 #include "components/bookmarks/browser/bookmark_model.h" | 13 #include "components/bookmarks/browser/bookmark_model.h" |
| 13 #include "components/bookmarks/common/bookmark_pref_names.h" | 14 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 14 #include "components/bookmarks/test/bookmark_test_helpers.h" | 15 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 15 #include "components/bookmarks/test/test_bookmark_client.h" | 16 #include "components/bookmarks/test/test_bookmark_client.h" |
| 16 #include "components/prefs/pref_registry_simple.h" | 17 #include "components/prefs/pref_registry_simple.h" |
| 17 #include "components/prefs/testing_pref_service.h" | 18 #include "components/prefs/testing_pref_service.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 namespace bookmarks { | 21 namespace bookmarks { |
| 21 | 22 |
| 22 class BookmarkExpandedStateTrackerTest : public testing::Test { | 23 class BookmarkExpandedStateTrackerTest : public testing::Test { |
| 23 public: | 24 public: |
| 24 BookmarkExpandedStateTrackerTest(); | 25 BookmarkExpandedStateTrackerTest(); |
| 25 ~BookmarkExpandedStateTrackerTest() override; | 26 ~BookmarkExpandedStateTrackerTest() override; |
| 26 | 27 |
| 27 protected: | 28 protected: |
| 28 // testing::Test: | 29 // testing::Test: |
| 29 void SetUp() override; | 30 void SetUp() override; |
| 30 void TearDown() override; | 31 void TearDown() override; |
| 31 | 32 |
| 32 base::MessageLoop message_loop_; | 33 base::MessageLoop message_loop_; |
| 33 TestingPrefServiceSimple prefs_; | 34 TestingPrefServiceSimple prefs_; |
| 34 scoped_ptr<BookmarkModel> model_; | 35 std::unique_ptr<BookmarkModel> model_; |
| 35 | 36 |
| 36 DISALLOW_COPY_AND_ASSIGN(BookmarkExpandedStateTrackerTest); | 37 DISALLOW_COPY_AND_ASSIGN(BookmarkExpandedStateTrackerTest); |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 BookmarkExpandedStateTrackerTest::BookmarkExpandedStateTrackerTest() {} | 40 BookmarkExpandedStateTrackerTest::BookmarkExpandedStateTrackerTest() {} |
| 40 | 41 |
| 41 BookmarkExpandedStateTrackerTest::~BookmarkExpandedStateTrackerTest() {} | 42 BookmarkExpandedStateTrackerTest::~BookmarkExpandedStateTrackerTest() {} |
| 42 | 43 |
| 43 void BookmarkExpandedStateTrackerTest::SetUp() { | 44 void BookmarkExpandedStateTrackerTest::SetUp() { |
| 44 prefs_.registry()->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, | 45 prefs_.registry()->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, |
| 45 new base::ListValue); | 46 new base::ListValue); |
| 46 prefs_.registry()->RegisterListPref(prefs::kManagedBookmarks); | 47 prefs_.registry()->RegisterListPref(prefs::kManagedBookmarks); |
| 47 model_.reset(new BookmarkModel(make_scoped_ptr(new TestBookmarkClient()))); | 48 model_.reset(new BookmarkModel(base::WrapUnique(new TestBookmarkClient()))); |
| 48 model_->Load(&prefs_, base::FilePath(), | 49 model_->Load(&prefs_, base::FilePath(), |
| 49 base::ThreadTaskRunnerHandle::Get(), | 50 base::ThreadTaskRunnerHandle::Get(), |
| 50 base::ThreadTaskRunnerHandle::Get()); | 51 base::ThreadTaskRunnerHandle::Get()); |
| 51 test::WaitForBookmarkModelToLoad(model_.get()); | 52 test::WaitForBookmarkModelToLoad(model_.get()); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void BookmarkExpandedStateTrackerTest::TearDown() { | 55 void BookmarkExpandedStateTrackerTest::TearDown() { |
| 55 model_.reset(); | 56 model_.reset(); |
| 56 message_loop_.RunUntilIdle(); | 57 message_loop_.RunUntilIdle(); |
| 57 } | 58 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 tracker->SetExpandedNodes(nodes); | 94 tracker->SetExpandedNodes(nodes); |
| 94 // Verify that the node is present. | 95 // Verify that the node is present. |
| 95 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); | 96 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); |
| 96 // Call remove all. | 97 // Call remove all. |
| 97 model_->RemoveAllUserBookmarks(); | 98 model_->RemoveAllUserBookmarks(); |
| 98 // Verify node is not present. | 99 // Verify node is not present. |
| 99 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); | 100 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); |
| 100 } | 101 } |
| 101 | 102 |
| 102 } // namespace bookmarks | 103 } // namespace bookmarks |
| OLD | NEW |