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

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

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/app/chrome_command_ids.h" 18 #include "chrome/app/chrome_command_ids.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" 22 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
23 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 void TearDown() override { 78 void TearDown() override {
79 ui::Clipboard::DestroyClipboardForCurrentThread(); 79 ui::Clipboard::DestroyClipboardForCurrentThread();
80 80
81 BrowserThread::GetBlockingPool()->FlushForTesting(); 81 BrowserThread::GetBlockingPool()->FlushForTesting();
82 } 82 }
83 83
84 protected: 84 protected:
85 content::TestBrowserThreadBundle thread_bundle_; 85 content::TestBrowserThreadBundle thread_bundle_;
86 scoped_ptr<TestingProfile> profile_; 86 std::unique_ptr<TestingProfile> profile_;
87 BookmarkModel* model_; 87 BookmarkModel* model_;
88 TestingPageNavigator navigator_; 88 TestingPageNavigator navigator_;
89 89
90 private: 90 private:
91 // Creates the following structure: 91 // Creates the following structure:
92 // a 92 // a
93 // F1 93 // F1
94 // f1a 94 // f1a
95 // -f1b as "chrome://settings" 95 // -f1b as "chrome://settings"
96 // F11 96 // F11
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 EXPECT_FALSE( 298 EXPECT_FALSE(
299 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); 299 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK));
300 EXPECT_FALSE( 300 EXPECT_FALSE(
301 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); 301 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER));
302 } 302 }
303 303
304 TEST_F(BookmarkContextMenuTest, CutCopyPasteNode) { 304 TEST_F(BookmarkContextMenuTest, CutCopyPasteNode) {
305 const BookmarkNode* bb_node = model_->bookmark_bar_node(); 305 const BookmarkNode* bb_node = model_->bookmark_bar_node();
306 std::vector<const BookmarkNode*> nodes; 306 std::vector<const BookmarkNode*> nodes;
307 nodes.push_back(bb_node->GetChild(0)); 307 nodes.push_back(bb_node->GetChild(0));
308 scoped_ptr<BookmarkContextMenu> controller(new BookmarkContextMenu( 308 std::unique_ptr<BookmarkContextMenu> controller(new BookmarkContextMenu(
309 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); 309 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false));
310 EXPECT_TRUE(controller->IsCommandEnabled(IDC_COPY)); 310 EXPECT_TRUE(controller->IsCommandEnabled(IDC_COPY));
311 EXPECT_TRUE(controller->IsCommandEnabled(IDC_CUT)); 311 EXPECT_TRUE(controller->IsCommandEnabled(IDC_CUT));
312 312
313 // Copy the URL. 313 // Copy the URL.
314 controller->ExecuteCommand(IDC_COPY, 0); 314 controller->ExecuteCommand(IDC_COPY, 0);
315 315
316 controller.reset(new BookmarkContextMenu( 316 controller.reset(new BookmarkContextMenu(
317 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); 317 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false));
318 int old_count = bb_node->child_count(); 318 int old_count = bb_node->child_count();
(...skipping 12 matching lines...) Expand all
331 ASSERT_EQ(old_count, bb_node->child_count()); 331 ASSERT_EQ(old_count, bb_node->child_count());
332 } 332 }
333 333
334 // Tests that the "Show managed bookmarks" option in the context menu is only 334 // Tests that the "Show managed bookmarks" option in the context menu is only
335 // visible if the policy is set. 335 // visible if the policy is set.
336 TEST_F(BookmarkContextMenuTest, ShowManagedBookmarks) { 336 TEST_F(BookmarkContextMenuTest, ShowManagedBookmarks) {
337 // Create a BookmarkContextMenu for the bookmarks bar. 337 // Create a BookmarkContextMenu for the bookmarks bar.
338 const BookmarkNode* bb_node = model_->bookmark_bar_node(); 338 const BookmarkNode* bb_node = model_->bookmark_bar_node();
339 std::vector<const BookmarkNode*> nodes; 339 std::vector<const BookmarkNode*> nodes;
340 nodes.push_back(bb_node->GetChild(0)); 340 nodes.push_back(bb_node->GetChild(0));
341 scoped_ptr<BookmarkContextMenu> controller(new BookmarkContextMenu( 341 std::unique_ptr<BookmarkContextMenu> controller(new BookmarkContextMenu(
342 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); 342 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false));
343 343
344 // Verify that there are no managed nodes yet. 344 // Verify that there are no managed nodes yet.
345 bookmarks::ManagedBookmarkService* managed = 345 bookmarks::ManagedBookmarkService* managed =
346 ManagedBookmarkServiceFactory::GetForProfile(profile_.get()); 346 ManagedBookmarkServiceFactory::GetForProfile(profile_.get());
347 EXPECT_TRUE(managed->managed_node()->empty()); 347 EXPECT_TRUE(managed->managed_node()->empty());
348 348
349 // The context menu should not show the option to "Show managed bookmarks". 349 // The context menu should not show the option to "Show managed bookmarks".
350 EXPECT_FALSE( 350 EXPECT_FALSE(
351 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)); 351 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS));
(...skipping 19 matching lines...) Expand all
371 controller.reset(new BookmarkContextMenu( 371 controller.reset(new BookmarkContextMenu(
372 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); 372 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false));
373 EXPECT_TRUE(controller->IsCommandVisible(IDC_BOOKMARK_BAR_NEW_FOLDER)); 373 EXPECT_TRUE(controller->IsCommandVisible(IDC_BOOKMARK_BAR_NEW_FOLDER));
374 EXPECT_TRUE( 374 EXPECT_TRUE(
375 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)); 375 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS));
376 menu = controller->menu(); 376 menu = controller->menu();
377 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_NEW_FOLDER)->visible()); 377 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_NEW_FOLDER)->visible());
378 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) 378 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)
379 ->visible()); 379 ->visible());
380 } 380 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_context_menu.h ('k') | chrome/browser/ui/views/bookmarks/bookmark_editor_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698