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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 15 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
16 #include "chrome/common/pref_names.h" | |
17 #include "chrome/test/base/testing_pref_service_syncable.h" | |
16 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
17 #include "components/bookmarks/browser/bookmark_model.h" | 19 #include "components/bookmarks/browser/bookmark_model.h" |
18 #include "components/bookmarks/test/bookmark_test_helpers.h" | 20 #include "components/bookmarks/test/bookmark_test_helpers.h" |
19 #include "content/public/browser/page_navigator.h" | 21 #include "content/public/browser/page_navigator.h" |
20 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
21 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "ui/base/clipboard/clipboard.h" | 25 #include "ui/base/clipboard/clipboard.h" |
24 | 26 |
25 using base::ASCIIToUTF16; | 27 using base::ASCIIToUTF16; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 ASSERT_EQ(bb_node->GetChild(0)->url(), bb_node->GetChild(1)->url()); | 328 ASSERT_EQ(bb_node->GetChild(0)->url(), bb_node->GetChild(1)->url()); |
327 | 329 |
328 controller.reset(new BookmarkContextMenuController( | 330 controller.reset(new BookmarkContextMenuController( |
329 NULL, NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); | 331 NULL, NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); |
330 // Cut the URL. | 332 // Cut the URL. |
331 controller->ExecuteCommand(IDC_CUT, 0); | 333 controller->ExecuteCommand(IDC_CUT, 0); |
332 ASSERT_TRUE(bb_node->GetChild(0)->is_url()); | 334 ASSERT_TRUE(bb_node->GetChild(0)->is_url()); |
333 ASSERT_TRUE(bb_node->GetChild(1)->is_folder()); | 335 ASSERT_TRUE(bb_node->GetChild(1)->is_folder()); |
334 ASSERT_EQ(old_count, bb_node->child_count()); | 336 ASSERT_EQ(old_count, bb_node->child_count()); |
335 } | 337 } |
338 | |
339 TEST_F(BookmarkContextMenuControllerTest, | |
340 ManagedShowAppsShortcutInBookmarksBar) { | |
341 BookmarkContextMenuController controller( | |
342 NULL, NULL, NULL, profile_.get(), NULL, model_->bookmark_bar_node(), | |
343 std::vector<const BookmarkNode*>()); | |
bartfab (slow)
2014/06/04 10:55:20
Nit: #include "components/bookmarks/browser/bookma
Joao da Silva
2014/06/04 11:13:42
Done.
| |
344 | |
345 // By default the pref is not managed and the command is enabled. | |
bartfab (slow)
2014/06/04 10:55:20
Nit: s/default/default,/
Joao da Silva
2014/06/04 11:13:42
Done.
| |
346 TestingPrefServiceSyncable* prefs = profile_->GetTestingPrefService(); | |
347 EXPECT_FALSE( | |
348 prefs->IsManagedPreference(prefs::kShowAppsShortcutInBookmarkBar)); | |
349 EXPECT_TRUE( | |
350 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); | |
351 | |
352 // Disabling the shorcut by policy disables the command. | |
353 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, | |
354 new base::FundamentalValue(false)); | |
bartfab (slow)
2014/06/04 10:55:20
Nit: #include "base/values.h"
Joao da Silva
2014/06/04 11:13:41
Done.
| |
355 EXPECT_FALSE( | |
356 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); | |
357 | |
358 // And enabling the shortcut by policy disables the command too. | |
359 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, | |
360 new base::FundamentalValue(true)); | |
361 EXPECT_FALSE( | |
362 controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT)); | |
363 } | |
OLD | NEW |