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

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

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

Powered by Google App Engine
This is Rietveld 408576698