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

Unified Diff: components/policy/core/browser/managed_bookmarks_tracker_unittest.cc

Issue 769153007: Managed bookmarks for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 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: components/policy/core/browser/managed_bookmarks_tracker_unittest.cc
diff --git a/components/policy/core/browser/managed_bookmarks_tracker_unittest.cc b/components/policy/core/browser/managed_bookmarks_tracker_unittest.cc
index 9b609fbfa06c1f448069f72c3b0fdc9099da16f5..d2b246b0bb9b2236df4d1bbab59b82a462ae5b07 100644
--- a/components/policy/core/browser/managed_bookmarks_tracker_unittest.cc
+++ b/components/policy/core/browser/managed_bookmarks_tracker_unittest.cc
@@ -36,6 +36,7 @@ class ManagedBookmarksTrackerTest : public testing::Test {
void SetUp() override {
prefs_.registry()->RegisterListPref(bookmarks::prefs::kManagedBookmarks);
+ prefs_.registry()->RegisterListPref(bookmarks::prefs::kSupervisedBookmarks);
prefs_.registry()->RegisterListPref(
bookmarks::prefs::kBookmarkEditorExpandedNodes);
}
@@ -46,13 +47,20 @@ class ManagedBookmarksTrackerTest : public testing::Test {
}
void CreateModel() {
+ CreateModel(false);
+ }
+
+ void CreateModel(bool is_supervised) {
// Simulate the creation of the managed node by the BookmarkClient.
BookmarkPermanentNode* managed_node = new BookmarkPermanentNode(100);
policy::ManagedBookmarksTracker::LoadInitial(
- managed_node, prefs_.GetList(bookmarks::prefs::kManagedBookmarks), 101);
+ managed_node,
+ prefs_.GetList(ManagedBookmarksTracker::GetPrefName(is_supervised)),
+ 101);
managed_node->set_visible(!managed_node->empty());
managed_node->SetTitle(l10n_util::GetStringUTF16(
- IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME));
+ is_supervised ? IDS_BOOKMARK_BAR_SUPERVISED_FOLDER_DEFAULT_NAME
+ : IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME));
bookmarks::BookmarkPermanentNodeList extra_nodes;
extra_nodes.push_back(managed_node);
@@ -76,6 +84,7 @@ class ManagedBookmarksTrackerTest : public testing::Test {
managed_bookmarks_tracker_.reset(new ManagedBookmarksTracker(
model_.get(),
&prefs_,
+ is_supervised,
base::Bind(&ManagedBookmarksTrackerTest::GetManagementDomain)));
managed_bookmarks_tracker_->Init(managed_node_);
}
@@ -190,6 +199,23 @@ TEST_F(ManagedBookmarksTrackerTest, LoadInitial) {
EXPECT_TRUE(NodeMatchesValue(managed_node(), expected.get()));
}
+TEST_F(ManagedBookmarksTrackerTest, SupervisedTrackerIgnoresManagedPref) {
+ prefs_.SetManagedPref(bookmarks::prefs::kManagedBookmarks, CreateTestTree());
+ CreateModel(true);
+ EXPECT_TRUE(managed_node()->empty());
+ EXPECT_FALSE(managed_node()->IsVisible());
+}
+
+TEST_F(ManagedBookmarksTrackerTest, SupervisedTrackerHandlesSupervisedPref) {
+ prefs_.SetManagedPref(bookmarks::prefs::kSupervisedBookmarks,
+ CreateTestTree());
+ CreateModel(true);
+ EXPECT_FALSE(managed_node()->empty());
+ EXPECT_TRUE(managed_node()->IsVisible());
+ // Don't bother checking the actual contents, the non-supervised tests cover
+ // that already.
+}
+
TEST_F(ManagedBookmarksTrackerTest, SwapNodes) {
prefs_.SetManagedPref(bookmarks::prefs::kManagedBookmarks, CreateTestTree());
CreateModel();

Powered by Google App Engine
This is Rietveld 408576698