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

Side by Side Diff: chrome/browser/ui/bookmarks/bookmark_context_menu_controller_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bookmarks/bookmark_context_menu_controller.h" 5 #include "chrome/browser/ui/bookmarks/bookmark_context_menu_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
9 #include <string> 10 #include <string>
10 11
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 17 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
18 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" 18 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
19 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
20 #include "components/bookmarks/browser/bookmark_model.h" 20 #include "components/bookmarks/browser/bookmark_model.h"
21 #include "components/bookmarks/browser/bookmark_node.h" 21 #include "components/bookmarks/browser/bookmark_node.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const BookmarkNode* f11 = model->AddFolder(f1, 1, ASCIIToUTF16("F11")); 83 const BookmarkNode* f11 = model->AddFolder(f1, 1, ASCIIToUTF16("F11"));
84 model->AddURL(f11, 0, ASCIIToUTF16("f11a"), GURL(test_base + "f11a")); 84 model->AddURL(f11, 0, ASCIIToUTF16("f11a"), GURL(test_base + "f11a"));
85 model->AddFolder(bb_node, 2, ASCIIToUTF16("F2")); 85 model->AddFolder(bb_node, 2, ASCIIToUTF16("F2"));
86 model->AddFolder(bb_node, 3, ASCIIToUTF16("F3")); 86 model->AddFolder(bb_node, 3, ASCIIToUTF16("F3"));
87 const BookmarkNode* f4 = model->AddFolder(bb_node, 4, ASCIIToUTF16("F4")); 87 const BookmarkNode* f4 = model->AddFolder(bb_node, 4, ASCIIToUTF16("F4"));
88 model->AddURL(f4, 0, ASCIIToUTF16("f4a"), GURL(test_base + "f4a")); 88 model->AddURL(f4, 0, ASCIIToUTF16("f4a"), GURL(test_base + "f4a"));
89 } 89 }
90 90
91 protected: 91 protected:
92 content::TestBrowserThreadBundle thread_bundle_; 92 content::TestBrowserThreadBundle thread_bundle_;
93 scoped_ptr<TestingProfile> profile_; 93 std::unique_ptr<TestingProfile> profile_;
94 BookmarkModel* model_; 94 BookmarkModel* model_;
95 TestingPageNavigator navigator_; 95 TestingPageNavigator navigator_;
96 }; 96 };
97 97
98 // Tests Deleting from the menu. 98 // Tests Deleting from the menu.
99 TEST_F(BookmarkContextMenuControllerTest, DeleteURL) { 99 TEST_F(BookmarkContextMenuControllerTest, DeleteURL) {
100 std::vector<const BookmarkNode*> nodes; 100 std::vector<const BookmarkNode*> nodes;
101 nodes.push_back(model_->bookmark_bar_node()->GetChild(0)); 101 nodes.push_back(model_->bookmark_bar_node()->GetChild(0));
102 BookmarkContextMenuController controller( 102 BookmarkContextMenuController controller(
103 NULL, NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes); 103 NULL, NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 EXPECT_TRUE( 297 EXPECT_TRUE(
298 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); 298 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK));
299 EXPECT_TRUE( 299 EXPECT_TRUE(
300 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); 300 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER));
301 } 301 }
302 302
303 TEST_F(BookmarkContextMenuControllerTest, CutCopyPasteNode) { 303 TEST_F(BookmarkContextMenuControllerTest, CutCopyPasteNode) {
304 const BookmarkNode* bb_node = model_->bookmark_bar_node(); 304 const BookmarkNode* bb_node = model_->bookmark_bar_node();
305 std::vector<const BookmarkNode*> nodes; 305 std::vector<const BookmarkNode*> nodes;
306 nodes.push_back(bb_node->GetChild(0)); 306 nodes.push_back(bb_node->GetChild(0));
307 scoped_ptr<BookmarkContextMenuController> controller( 307 std::unique_ptr<BookmarkContextMenuController> controller(
308 new BookmarkContextMenuController( 308 new BookmarkContextMenuController(NULL, NULL, NULL, profile_.get(), NULL,
309 NULL, NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); 309 nodes[0]->parent(), nodes));
310 EXPECT_TRUE(controller->IsCommandIdEnabled(IDC_COPY)); 310 EXPECT_TRUE(controller->IsCommandIdEnabled(IDC_COPY));
311 EXPECT_TRUE(controller->IsCommandIdEnabled(IDC_CUT)); 311 EXPECT_TRUE(controller->IsCommandIdEnabled(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 BookmarkContextMenuController( 316 controller.reset(new BookmarkContextMenuController(
317 NULL, NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); 317 NULL, NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes));
318 int old_count = bb_node->child_count(); 318 int old_count = bb_node->child_count();
319 controller->ExecuteCommand(IDC_PASTE, 0); 319 controller->ExecuteCommand(IDC_PASTE, 0);
(...skipping 30 matching lines...) Expand all
350 new base::FundamentalValue(false)); 350 new base::FundamentalValue(false));
351 EXPECT_FALSE( 351 EXPECT_FALSE(
352 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); 352 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT));
353 353
354 // And enabling the shortcut by policy disables the command too. 354 // And enabling the shortcut by policy disables the command too.
355 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, 355 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar,
356 new base::FundamentalValue(true)); 356 new base::FundamentalValue(true));
357 EXPECT_FALSE( 357 EXPECT_FALSE(
358 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); 358 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT));
359 } 359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698