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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 233 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
234 EXPECT_TRUE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 234 EXPECT_TRUE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
235 EXPECT_TRUE( | 235 EXPECT_TRUE( |
236 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 236 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
237 EXPECT_TRUE( | 237 EXPECT_TRUE( |
238 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 238 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
239 } | 239 } |
240 | 240 |
241 // Tests the enabled state of open incognito. | 241 // Tests the enabled state of open incognito. |
242 TEST_F(BookmarkContextMenuControllerTest, DisableIncognito) { | 242 TEST_F(BookmarkContextMenuControllerTest, DisableIncognito) { |
243 // Create an incognito Profile. It must be associated with the original | 243 TestingProfile* incognito = |
244 // Profile, so that GetOriginalProfile() works as expected. | 244 TestingProfile::Builder().BuildIncognito(profile_.get()); |
245 TestingProfile::Builder builder; | |
246 builder.SetIncognito(); | |
247 scoped_ptr<TestingProfile> testing_incognito = builder.Build(); | |
248 testing_incognito->SetOriginalProfile(profile_.get()); | |
249 TestingProfile* incognito = testing_incognito.get(); | |
250 profile_->SetOffTheRecordProfile(testing_incognito.PassAs<Profile>()); | |
251 | 245 |
252 incognito->CreateBookmarkModel(true); | 246 incognito->CreateBookmarkModel(true); |
253 BookmarkModel* model = BookmarkModelFactory::GetForProfile(incognito); | 247 BookmarkModel* model = BookmarkModelFactory::GetForProfile(incognito); |
254 test::WaitForBookmarkModelToLoad(model); | 248 test::WaitForBookmarkModelToLoad(model); |
255 AddTestData(model); | 249 AddTestData(model); |
256 | 250 |
257 std::vector<const BookmarkNode*> nodes; | 251 std::vector<const BookmarkNode*> nodes; |
258 nodes.push_back(model->bookmark_bar_node()->GetChild(0)); | 252 nodes.push_back(model->bookmark_bar_node()->GetChild(0)); |
259 BookmarkContextMenuController controller( | 253 BookmarkContextMenuController controller( |
260 NULL, NULL, NULL, incognito, NULL, nodes[0]->parent(), nodes); | 254 NULL, NULL, NULL, incognito, NULL, nodes[0]->parent(), nodes); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 new base::FundamentalValue(false)); | 353 new base::FundamentalValue(false)); |
360 EXPECT_FALSE( | 354 EXPECT_FALSE( |
361 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); | 355 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); |
362 | 356 |
363 // And enabling the shortcut by policy disables the command too. | 357 // And enabling the shortcut by policy disables the command too. |
364 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 358 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
365 new base::FundamentalValue(true)); | 359 new base::FundamentalValue(true)); |
366 EXPECT_FALSE( | 360 EXPECT_FALSE( |
367 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); | 361 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); |
368 } | 362 } |
OLD | NEW |