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

Side by Side Diff: chrome/browser/extensions/api/bookmarks/bookmark_apitest.cc

Issue 769153007: Managed bookmarks for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build (Android & unit_tests) Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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 "base/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
8 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 8 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
9 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" 9 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "components/bookmarks/browser/bookmark_model.h" 13 #include "components/bookmarks/browser/bookmark_model.h"
14 #include "components/bookmarks/browser/bookmark_node.h" 14 #include "components/bookmarks/browser/bookmark_node.h"
15 #include "components/bookmarks/common/bookmark_pref_names.h" 15 #include "components/bookmarks/common/bookmark_pref_names.h"
16 #include "components/bookmarks/test/bookmark_test_helpers.h" 16 #include "components/bookmarks/test/bookmark_test_helpers.h"
17 17
18 using bookmarks::BookmarkModel; 18 using bookmarks::BookmarkModel;
19 19
20 // Flaky on Windows and Linux. http://crbug.com/383452 20 // Flaky on Windows and Linux. http://crbug.com/383452
21 #if defined(OS_WIN) || defined(OS_LINUX) 21 #if defined(OS_WIN) || defined(OS_LINUX)
22 #define MAYBE_Bookmarks DISABLED_Bookmarks 22 #define MAYBE_Bookmarks DISABLED_Bookmarks
23 #else 23 #else
24 #define MAYBE_Bookmarks Bookmarks 24 #define MAYBE_Bookmarks Bookmarks
25 #endif 25 #endif
26 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Bookmarks) { 26 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Bookmarks) {
27 // Add test managed bookmarks to verify that the bookmarks API can read them 27 // Add test managed and supervised bookmarks to verify that the bookmarks API
28 // and can't modify them. 28 // can read them and can't modify them.
29 Profile* profile = browser()->profile(); 29 Profile* profile = browser()->profile();
30 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 30 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
31 ChromeBookmarkClient* client = 31 ChromeBookmarkClient* client =
32 ChromeBookmarkClientFactory::GetForProfile(profile); 32 ChromeBookmarkClientFactory::GetForProfile(profile);
33 bookmarks::test::WaitForBookmarkModelToLoad(model); 33 bookmarks::test::WaitForBookmarkModelToLoad(model);
34 34
35 base::ListValue list; 35 {
36 base::DictionaryValue* node = new base::DictionaryValue(); 36 base::ListValue list;
37 node->SetString("name", "Managed Bookmark"); 37 base::DictionaryValue* node = new base::DictionaryValue();
38 node->SetString("url", "http://www.chromium.org"); 38 node->SetString("name", "Managed Bookmark");
39 list.Append(node); 39 node->SetString("url", "http://www.chromium.org");
40 node = new base::DictionaryValue(); 40 list.Append(node);
41 node->SetString("name", "Managed Folder"); 41 node = new base::DictionaryValue();
42 node->Set("children", new base::ListValue()); 42 node->SetString("name", "Managed Folder");
43 list.Append(node); 43 node->Set("children", new base::ListValue());
44 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); 44 list.Append(node);
45 ASSERT_EQ(2, client->managed_node()->child_count()); 45 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list);
46 ASSERT_EQ(2, client->managed_node()->child_count());
47 }
48
49 {
50 base::ListValue list;
51 base::DictionaryValue* node = new base::DictionaryValue();
52 node->SetString("name", "Supervised Bookmark");
53 node->SetString("url", "http://www.pbskids.org");
54 list.Append(node);
55 node = new base::DictionaryValue();
56 node->SetString("name", "Supervised Folder");
57 node->Set("children", new base::ListValue());
58 list.Append(node);
59 profile->GetPrefs()->Set(bookmarks::prefs::kSupervisedBookmarks, list);
60 ASSERT_EQ(2, client->supervised_node()->child_count());
61 }
46 62
47 ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_; 63 ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
48 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698