Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: components/bookmarks/browser/bookmark_expanded_state_tracker_unittest.cc

Issue 1105413002: Avoid conversion of index to BookmarkNode pointer unnacessarily. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); 81 EXPECT_EQ(nodes, tracker->GetExpandedNodes());
82 82
83 // Add a folder and mark it expanded. 83 // Add a folder and mark it expanded.
84 const BookmarkNode* n1 = model_->AddFolder( 84 const BookmarkNode* n1 = model_->AddFolder(
85 model_->bookmark_bar_node(), 0, base::ASCIIToUTF16("x")); 85 model_->bookmark_bar_node(), 0, base::ASCIIToUTF16("x"));
86 nodes.insert(n1); 86 nodes.insert(n1);
87 tracker->SetExpandedNodes(nodes); 87 tracker->SetExpandedNodes(nodes);
88 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); 88 EXPECT_EQ(nodes, tracker->GetExpandedNodes());
89 89
90 // Remove the folder, which should remove it from the list of expanded nodes. 90 // Remove the folder, which should remove it from the list of expanded nodes.
91 model_->Remove(model_->bookmark_bar_node(), 0); 91 model_->Remove(model_->bookmark_bar_node()->GetChild(0));
92 nodes.erase(n1); 92 nodes.erase(n1);
93 n1 = NULL; 93 n1 = NULL;
94 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); 94 EXPECT_EQ(nodes, tracker->GetExpandedNodes());
95 } 95 }
96 96
97 TEST_F(BookmarkExpandedStateTrackerTest, RemoveAllUserBookmarks) { 97 TEST_F(BookmarkExpandedStateTrackerTest, RemoveAllUserBookmarks) {
98 BookmarkExpandedStateTracker* tracker = model_->expanded_state_tracker(); 98 BookmarkExpandedStateTracker* tracker = model_->expanded_state_tracker();
99 99
100 // Add a folder and mark it expanded. 100 // Add a folder and mark it expanded.
101 const BookmarkNode* n1 = model_->AddFolder( 101 const BookmarkNode* n1 = model_->AddFolder(
102 model_->bookmark_bar_node(), 0, base::ASCIIToUTF16("x")); 102 model_->bookmark_bar_node(), 0, base::ASCIIToUTF16("x"));
103 BookmarkExpandedStateTracker::Nodes nodes; 103 BookmarkExpandedStateTracker::Nodes nodes;
104 nodes.insert(n1); 104 nodes.insert(n1);
105 tracker->SetExpandedNodes(nodes); 105 tracker->SetExpandedNodes(nodes);
106 // Verify that the node is present. 106 // Verify that the node is present.
107 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); 107 EXPECT_EQ(nodes, tracker->GetExpandedNodes());
108 // Call remove all. 108 // Call remove all.
109 model_->RemoveAllUserBookmarks(); 109 model_->RemoveAllUserBookmarks();
110 // Verify node is not present. 110 // Verify node is not present.
111 EXPECT_TRUE(tracker->GetExpandedNodes().empty()); 111 EXPECT_TRUE(tracker->GetExpandedNodes().empty());
112 } 112 }
113 113
114 } // namespace bookmarks 114 } // namespace bookmarks
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc ('k') | components/bookmarks/browser/bookmark_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698