| 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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/pref_service_factory.h" | 10 #include "base/prefs/pref_service_factory.h" |
| 11 #include "base/prefs/testing_pref_store.h" | 11 #include "base/prefs/testing_pref_store.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "components/bookmarks/browser/bookmark_model.h" | 14 #include "components/bookmarks/browser/bookmark_model.h" |
| 15 #include "components/bookmarks/common/bookmark_pref_names.h" | 15 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 16 #include "components/bookmarks/test/bookmark_test_helpers.h" | 16 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 17 #include "components/bookmarks/test/test_bookmark_client.h" | 17 #include "components/bookmarks/test/test_bookmark_client.h" |
| 18 #include "components/pref_registry/pref_registry_syncable.h" | 18 #include "components/pref_registry/pref_registry_syncable.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace bookmarks { | 21 namespace bookmarks { |
| 22 | 22 |
| 23 scoped_ptr<PrefService> PrefServiceForTesting() { | 23 scoped_ptr<PrefService> PrefServiceForTesting() { |
| 24 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 24 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
| 25 new user_prefs::PrefRegistrySyncable()); | 25 new user_prefs::PrefRegistrySyncable()); |
| 26 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, | 26 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, |
| 27 new base::ListValue, | 27 new base::ListValue); |
| 28 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 28 registry->RegisterListPref(prefs::kManagedBookmarks); |
| 29 registry->RegisterListPref(prefs::kManagedBookmarks, | |
| 30 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 31 base::PrefServiceFactory factory; | 29 base::PrefServiceFactory factory; |
| 32 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore())); | 30 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore())); |
| 33 return factory.Create(registry.get()); | 31 return factory.Create(registry.get()); |
| 34 } | 32 } |
| 35 | 33 |
| 36 class BookmarkExpandedStateTrackerTest : public testing::Test { | 34 class BookmarkExpandedStateTrackerTest : public testing::Test { |
| 37 public: | 35 public: |
| 38 BookmarkExpandedStateTrackerTest(); | 36 BookmarkExpandedStateTrackerTest(); |
| 39 ~BookmarkExpandedStateTrackerTest() override; | 37 ~BookmarkExpandedStateTrackerTest() override; |
| 40 | 38 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 tracker->SetExpandedNodes(nodes); | 105 tracker->SetExpandedNodes(nodes); |
| 108 // Verify that the node is present. | 106 // Verify that the node is present. |
| 109 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); | 107 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); |
| 110 // Call remove all. | 108 // Call remove all. |
| 111 model_->RemoveAllUserBookmarks(); | 109 model_->RemoveAllUserBookmarks(); |
| 112 // Verify node is not present. | 110 // Verify node is not present. |
| 113 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); | 111 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); |
| 114 } | 112 } |
| 115 | 113 |
| 116 } // namespace bookmarks | 114 } // namespace bookmarks |
| OLD | NEW |