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

Unified Diff: chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc

Issue 312673006: Added a policy to control the visibility of the apps shortcut. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed remaining nits Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc
diff --git a/chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc b/chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc
index 7393354f6220c86b04df60779499ab23acef26bb..31021587d3bba1ac5d9d11710b49d394d8d05ec1 100644
--- a/chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc
@@ -9,12 +9,16 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/bookmarks/bookmark_utils.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
#include "components/bookmarks/browser/bookmark_model.h"
+#include "components/bookmarks/browser/bookmark_node.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/test/test_browser_thread.h"
@@ -333,3 +337,29 @@ TEST_F(BookmarkContextMenuControllerTest, CutCopyPasteNode) {
ASSERT_TRUE(bb_node->GetChild(1)->is_folder());
ASSERT_EQ(old_count, bb_node->child_count());
}
+
+TEST_F(BookmarkContextMenuControllerTest,
+ ManagedShowAppsShortcutInBookmarksBar) {
+ BookmarkContextMenuController controller(
+ NULL, NULL, NULL, profile_.get(), NULL, model_->bookmark_bar_node(),
+ std::vector<const BookmarkNode*>());
+
+ // By default, the pref is not managed and the command is enabled.
+ TestingPrefServiceSyncable* prefs = profile_->GetTestingPrefService();
+ EXPECT_FALSE(
+ prefs->IsManagedPreference(prefs::kShowAppsShortcutInBookmarkBar));
+ EXPECT_TRUE(
+ controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT));
+
+ // Disabling the shorcut by policy disables the command.
+ prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar,
+ new base::FundamentalValue(false));
+ EXPECT_FALSE(
+ controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT));
+
+ // And enabling the shortcut by policy disables the command too.
+ prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar,
+ new base::FundamentalValue(true));
+ EXPECT_FALSE(
+ controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT));
+}

Powered by Google App Engine
This is Rietveld 408576698