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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_context_menu_unittest.cc

Issue 2809003002: Making bookmark folder context menu display the number of bookmarks that will be opened by Open All (Closed)
Patch Set: Refactoring URL itteration function as per comments, addressing other formatting and style errors Created 3 years, 8 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 "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 TEST_F(BookmarkContextMenuTest, OpenAllIncognito) { 145 TEST_F(BookmarkContextMenuTest, OpenAllIncognito) {
146 const BookmarkNode* folder = model_->bookmark_bar_node()->GetChild(1); 146 const BookmarkNode* folder = model_->bookmark_bar_node()->GetChild(1);
147 chrome::OpenAll(NULL, &navigator_, folder, 147 chrome::OpenAll(NULL, &navigator_, folder,
148 WindowOpenDisposition::OFF_THE_RECORD, profile_.get()); 148 WindowOpenDisposition::OFF_THE_RECORD, profile_.get());
149 149
150 // Should have navigated to only f1a but not f2a. 150 // Should have navigated to only f1a but not f2a.
151 ASSERT_EQ(static_cast<size_t>(1), navigator_.urls_.size()); 151 ASSERT_EQ(static_cast<size_t>(1), navigator_.urls_.size());
152 ASSERT_TRUE(folder->GetChild(0)->url() == navigator_.urls_[0]); 152 ASSERT_TRUE(folder->GetChild(0)->url() == navigator_.urls_[0]);
153 } 153 }
154 154
155 // Tests counting tabs for 'open all' on a folder with a couple of bookmarks.
156 TEST_F(BookmarkContextMenuTest, OpenCount) {
157 const BookmarkNode* folder = model_->bookmark_bar_node()->GetChild(1);
158 int result = chrome::OpenCount(NULL, folder);
159
160 // Should have navigated to F1's child but not F11's child.
Peter Kasting 2017/04/14 08:17:15 Nit: Should have navigated -> OpenAll() would navi
Paezagon 2017/04/14 18:47:25 Done.
161 ASSERT_EQ(static_cast<size_t>(2), result);
Peter Kasting 2017/04/14 08:17:15 Nit: Can be EXPECT rather than ASSERT. Use "2U" i
Paezagon 2017/04/14 18:47:25 Done.
162 }
163
164 // Tests counting on 'open all' on a folder with a couple of bookmarks in
165 // incognito window.
Peter Kasting 2017/04/14 08:17:15 Nit: This is slightly unclear; maybe instead "Same
Paezagon 2017/04/14 18:47:24 Done.
166 TEST_F(BookmarkContextMenuTest, OpenCountIncognito) {
167 const BookmarkNode* folder = model_->bookmark_bar_node()->GetChild(1);
168 int result = chrome::OpenCount(NULL, folder, true, profile_.get());
169
170 // Should have navigated to only f1a but not f2a.
171 ASSERT_EQ(static_cast<size_t>(1), result);
172 }
173
155 // Tests the enabled state of the menus when supplied an empty vector. 174 // Tests the enabled state of the menus when supplied an empty vector.
156 TEST_F(BookmarkContextMenuTest, EmptyNodes) { 175 TEST_F(BookmarkContextMenuTest, EmptyNodes) {
157 BookmarkContextMenu controller( 176 BookmarkContextMenu controller(
158 NULL, NULL, profile_.get(), NULL, model_->other_node(), 177 NULL, NULL, profile_.get(), NULL, model_->other_node(),
159 std::vector<const BookmarkNode*>(), false); 178 std::vector<const BookmarkNode*>(), false);
160 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); 179 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL));
161 EXPECT_FALSE( 180 EXPECT_FALSE(
162 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); 181 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW));
163 EXPECT_FALSE( 182 EXPECT_FALSE(
164 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); 183 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO));
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 controller.reset(new BookmarkContextMenu( 393 controller.reset(new BookmarkContextMenu(
375 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); 394 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false));
376 EXPECT_TRUE(controller->IsCommandVisible(IDC_BOOKMARK_BAR_NEW_FOLDER)); 395 EXPECT_TRUE(controller->IsCommandVisible(IDC_BOOKMARK_BAR_NEW_FOLDER));
377 EXPECT_TRUE( 396 EXPECT_TRUE(
378 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)); 397 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS));
379 menu = controller->menu(); 398 menu = controller->menu();
380 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_NEW_FOLDER)->visible()); 399 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_NEW_FOLDER)->visible());
381 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) 400 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)
382 ->visible()); 401 ->visible());
383 } 402 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698