| 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 scoped_ptr<PrefService> PrefServiceForTesting() { | 21 scoped_ptr<PrefService> PrefServiceForTesting() { |
| 22 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 22 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
| 23 new user_prefs::PrefRegistrySyncable()); | 23 new user_prefs::PrefRegistrySyncable()); |
| 24 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, | 24 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, |
| 25 new base::ListValue, | 25 new base::ListValue, |
| 26 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 26 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 27 registry->RegisterListPref(prefs::kManagedBookmarks, |
| 28 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 27 base::PrefServiceFactory factory; | 29 base::PrefServiceFactory factory; |
| 28 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore())); | 30 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore())); |
| 29 return factory.Create(registry.get()); | 31 return factory.Create(registry.get()); |
| 30 } | 32 } |
| 31 | 33 |
| 32 class BookmarkExpandedStateTrackerTest : public testing::Test { | 34 class BookmarkExpandedStateTrackerTest : public testing::Test { |
| 33 public: | 35 public: |
| 34 BookmarkExpandedStateTrackerTest(); | 36 BookmarkExpandedStateTrackerTest(); |
| 35 virtual ~BookmarkExpandedStateTrackerTest(); | 37 virtual ~BookmarkExpandedStateTrackerTest(); |
| 36 | 38 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 BookmarkExpandedStateTracker::Nodes nodes; | 103 BookmarkExpandedStateTracker::Nodes nodes; |
| 102 nodes.insert(n1); | 104 nodes.insert(n1); |
| 103 tracker->SetExpandedNodes(nodes); | 105 tracker->SetExpandedNodes(nodes); |
| 104 // Verify that the node is present. | 106 // Verify that the node is present. |
| 105 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); | 107 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); |
| 106 // Call remove all. | 108 // Call remove all. |
| 107 model_->RemoveAll(); | 109 model_->RemoveAll(); |
| 108 // Verify node is not present. | 110 // Verify node is not present. |
| 109 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); | 111 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); |
| 110 } | 112 } |
| OLD | NEW |