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

Side by Side Diff: chrome/browser/bookmarks/bookmark_table_model_unittest.cc

Issue 27262: Wires up sorting of bookmarks to the 'organize menu' in the bookmark... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/string_util.h" 5 #include "base/string_util.h"
6 #include "base/time.h" 6 #include "base/time.h"
7 #include "chrome/browser/bookmarks/bookmark_table_model.h" 7 #include "chrome/browser/bookmarks/bookmark_table_model.h"
8 #include "chrome/test/testing_profile.h" 8 #include "chrome/test/testing_profile.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 VerifyAndClearOberserverCounts(0, 0, 1, 0); 136 VerifyAndClearOberserverCounts(0, 0, 1, 0);
137 ASSERT_EQ(4, model_->RowCount()); 137 ASSERT_EQ(4, model_->RowCount());
138 EXPECT_TRUE(new_node == model_->GetNodeForRow(0)); 138 EXPECT_TRUE(new_node == model_->GetNodeForRow(0));
139 139
140 // Add to the bookmark bar, this shouldn't generate an event. 140 // Add to the bookmark bar, this shouldn't generate an event.
141 bookmark_model()->AddURL(bookmark_model()->GetBookmarkBarNode(), 0, L"new", 141 bookmark_model()->AddURL(bookmark_model()->GetBookmarkBarNode(), 0, L"new",
142 url1_); 142 url1_);
143 VerifyAndClearOberserverCounts(0, 0, 0, 0); 143 VerifyAndClearOberserverCounts(0, 0, 0, 0);
144 } 144 }
145 145
146 // Verifies sort sends out notification and results in a sort.
147 TEST_F(BookmarkTableModelTest, SortFolder) {
148 BookmarkNode* other = bookmark_model()->other_node();
149 SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder(
150 bookmark_model(), other));
151 ASSERT_EQ(3, model_->RowCount());
152 bookmark_model()->SortChildren(other);
153
154 // Sorting should trigger change notification.
155 VerifyAndClearOberserverCounts(1, 0, 0, 0);
156
157 // Make sure things reordered.
158 EXPECT_TRUE(other->GetChild(0) == model_->GetNodeForRow(0));
159 EXPECT_TRUE(other->GetChild(1) == model_->GetNodeForRow(1));
160 EXPECT_TRUE(other->GetChild(2) == model_->GetNodeForRow(2));
161 }
162
146 // Verifies removing an item from folder model generates the correct event. 163 // Verifies removing an item from folder model generates the correct event.
147 TEST_F(BookmarkTableModelTest, RemoveFromFolder) { 164 TEST_F(BookmarkTableModelTest, RemoveFromFolder) {
148 BookmarkNode* other = bookmark_model()->other_node(); 165 BookmarkNode* other = bookmark_model()->other_node();
149 SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder( 166 SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder(
150 bookmark_model(), other)); 167 bookmark_model(), other));
151 bookmark_model()->Remove(other, 0); 168 bookmark_model()->Remove(other, 0);
152 169
153 // Should have gotten notification of the remove. 170 // Should have gotten notification of the remove.
154 VerifyAndClearOberserverCounts(0, 0, 0, 1); 171 VerifyAndClearOberserverCounts(0, 0, 0, 1);
155 EXPECT_EQ(2, model_->RowCount()); 172 EXPECT_EQ(2, model_->RowCount());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Change a folder, this shouldn't change the model. 306 // Change a folder, this shouldn't change the model.
290 bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(1), 307 bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(1),
291 L"new"); 308 L"new");
292 VerifyAndClearOberserverCounts(0, 0, 0, 0); 309 VerifyAndClearOberserverCounts(0, 0, 0, 0);
293 310
294 // Change a url that isn't in the model, this shouldn't send change. 311 // Change a url that isn't in the model, this shouldn't send change.
295 bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(0), 312 bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(0),
296 L"new"); 313 L"new");
297 VerifyAndClearOberserverCounts(0, 0, 0, 0); 314 VerifyAndClearOberserverCounts(0, 0, 0, 0);
298 } 315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698