| 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 { |
| 22 |
| 21 scoped_ptr<PrefService> PrefServiceForTesting() { | 23 scoped_ptr<PrefService> PrefServiceForTesting() { |
| 22 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 24 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
| 23 new user_prefs::PrefRegistrySyncable()); | 25 new user_prefs::PrefRegistrySyncable()); |
| 24 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, | 26 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, |
| 25 new base::ListValue, | 27 new base::ListValue, |
| 26 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 28 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 27 registry->RegisterListPref(prefs::kManagedBookmarks, | 29 registry->RegisterListPref(prefs::kManagedBookmarks, |
| 28 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 30 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 29 base::PrefServiceFactory factory; | 31 base::PrefServiceFactory factory; |
| 30 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore())); | 32 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore())); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 BookmarkExpandedStateTracker::Nodes nodes; | 105 BookmarkExpandedStateTracker::Nodes nodes; |
| 104 nodes.insert(n1); | 106 nodes.insert(n1); |
| 105 tracker->SetExpandedNodes(nodes); | 107 tracker->SetExpandedNodes(nodes); |
| 106 // Verify that the node is present. | 108 // Verify that the node is present. |
| 107 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); | 109 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); |
| 108 // Call remove all. | 110 // Call remove all. |
| 109 model_->RemoveAllUserBookmarks(); | 111 model_->RemoveAllUserBookmarks(); |
| 110 // Verify node is not present. | 112 // Verify node is not present. |
| 111 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); | 113 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); |
| 112 } | 114 } |
| 115 |
| 116 } // namespace bookmarks |
| OLD | NEW |