OLD | NEW |
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 <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 }; | 48 }; |
49 | 49 |
50 class BookmarkContextMenuControllerTest : public testing::Test { | 50 class BookmarkContextMenuControllerTest : public testing::Test { |
51 public: | 51 public: |
52 BookmarkContextMenuControllerTest() : model_(nullptr) {} | 52 BookmarkContextMenuControllerTest() : model_(nullptr) {} |
53 | 53 |
54 void SetUp() override { | 54 void SetUp() override { |
55 TestingProfile::Builder builder; | 55 TestingProfile::Builder builder; |
56 profile_ = builder.Build(); | 56 profile_ = builder.Build(); |
57 profile_->CreateBookmarkModel(true); | 57 profile_->CreateBookmarkModel(true); |
58 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); | 58 model_ = BookmarkModelFactory::GetForBrowserContext(profile_.get()); |
59 bookmarks::test::WaitForBookmarkModelToLoad(model_); | 59 bookmarks::test::WaitForBookmarkModelToLoad(model_); |
60 AddTestData(model_); | 60 AddTestData(model_); |
61 } | 61 } |
62 | 62 |
63 void TearDown() override { | 63 void TearDown() override { |
64 ui::Clipboard::DestroyClipboardForCurrentThread(); | 64 ui::Clipboard::DestroyClipboardForCurrentThread(); |
65 } | 65 } |
66 | 66 |
67 // Creates the following structure: | 67 // Creates the following structure: |
68 // a | 68 // a |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 EXPECT_TRUE( | 233 EXPECT_TRUE( |
234 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 234 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
235 } | 235 } |
236 | 236 |
237 // Tests the enabled state of open incognito. | 237 // Tests the enabled state of open incognito. |
238 TEST_F(BookmarkContextMenuControllerTest, DisableIncognito) { | 238 TEST_F(BookmarkContextMenuControllerTest, DisableIncognito) { |
239 TestingProfile* incognito = | 239 TestingProfile* incognito = |
240 TestingProfile::Builder().BuildIncognito(profile_.get()); | 240 TestingProfile::Builder().BuildIncognito(profile_.get()); |
241 | 241 |
242 incognito->CreateBookmarkModel(true); | 242 incognito->CreateBookmarkModel(true); |
243 BookmarkModel* model = BookmarkModelFactory::GetForProfile(incognito); | 243 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(incognito); |
244 bookmarks::test::WaitForBookmarkModelToLoad(model); | 244 bookmarks::test::WaitForBookmarkModelToLoad(model); |
245 AddTestData(model); | 245 AddTestData(model); |
246 | 246 |
247 std::vector<const BookmarkNode*> nodes; | 247 std::vector<const BookmarkNode*> nodes; |
248 nodes.push_back(model->bookmark_bar_node()->GetChild(0)); | 248 nodes.push_back(model->bookmark_bar_node()->GetChild(0)); |
249 BookmarkContextMenuController controller( | 249 BookmarkContextMenuController controller( |
250 NULL, NULL, NULL, incognito, NULL, nodes[0]->parent(), nodes); | 250 NULL, NULL, NULL, incognito, NULL, nodes[0]->parent(), nodes); |
251 EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_INCOGNITO)); | 251 EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_INCOGNITO)); |
252 EXPECT_FALSE( | 252 EXPECT_FALSE( |
253 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 253 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |