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

Side by Side Diff: chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc

Issue 1233673002: Fix componentization of chrome/browser/bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix "gn check" and compilation on Mac Created 5 years, 5 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 "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h" 5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 12 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
13 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
14 #include "chrome/browser/extensions/extension_apitest.h" 13 #include "chrome/browser/extensions/extension_apitest.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
17 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
18 #include "components/bookmarks/browser/bookmark_model.h" 17 #include "components/bookmarks/browser/bookmark_model.h"
19 #include "components/bookmarks/common/bookmark_pref_names.h" 18 #include "components/bookmarks/common/bookmark_pref_names.h"
19 #include "components/bookmarks/managed/managed_bookmark_service.h"
20 #include "components/bookmarks/test/bookmark_test_helpers.h" 20 #include "components/bookmarks/test/bookmark_test_helpers.h"
21 #include "components/user_prefs/user_prefs.h" 21 #include "components/user_prefs/user_prefs.h"
22 22
23 using bookmarks::BookmarkModel; 23 using bookmarks::BookmarkModel;
24 using bookmarks::BookmarkNode; 24 using bookmarks::BookmarkNode;
25 25
26 // Times out on win syzyasan, http://crbug.com/166026 26 // Times out on win syzyasan, http://crbug.com/166026
27 #if defined(SYZYASAN) 27 #if defined(SYZYASAN)
28 #define MAYBE_BookmarkManager DISABLED_BookmarkManager 28 #define MAYBE_BookmarkManager DISABLED_BookmarkManager
29 #else 29 #else
30 #define MAYBE_BookmarkManager BookmarkManager 30 #define MAYBE_BookmarkManager BookmarkManager
31 #endif 31 #endif
32 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) { 32 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) {
33 // Add managed bookmarks. 33 // Add managed bookmarks.
34 Profile* profile = browser()->profile(); 34 Profile* profile = browser()->profile();
35 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 35 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
36 ChromeBookmarkClient* client = 36 bookmarks::ManagedBookmarkService* managed =
37 ChromeBookmarkClientFactory::GetForProfile(profile); 37 ManagedBookmarkServiceFactory::GetForProfile(profile);
38 bookmarks::test::WaitForBookmarkModelToLoad(model); 38 bookmarks::test::WaitForBookmarkModelToLoad(model);
39 39
40 base::ListValue list; 40 base::ListValue list;
41 base::DictionaryValue* node = new base::DictionaryValue(); 41 base::DictionaryValue* node = new base::DictionaryValue();
42 node->SetString("name", "Managed Bookmark"); 42 node->SetString("name", "Managed Bookmark");
43 node->SetString("url", "http://www.chromium.org"); 43 node->SetString("url", "http://www.chromium.org");
44 list.Append(node); 44 list.Append(node);
45 node = new base::DictionaryValue(); 45 node = new base::DictionaryValue();
46 node->SetString("name", "Managed Folder"); 46 node->SetString("name", "Managed Folder");
47 node->Set("children", new base::ListValue()); 47 node->Set("children", new base::ListValue());
48 list.Append(node); 48 list.Append(node);
49 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); 49 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list);
50 ASSERT_EQ(2, client->managed_node()->child_count()); 50 ASSERT_EQ(2, managed->managed_node()->child_count());
51 51
52 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) 52 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard"))
53 << message_; 53 << message_;
54 } 54 }
55 55
56 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { 56 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) {
57 Profile* profile = browser()->profile(); 57 Profile* profile = browser()->profile();
58 58
59 // Provide some testing data here, since bookmark editing will be disabled 59 // Provide some testing data here, since bookmark editing will be disabled
60 // within the extension. 60 // within the extension.
61 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 61 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
62 bookmarks::test::WaitForBookmarkModelToLoad(model); 62 bookmarks::test::WaitForBookmarkModelToLoad(model);
63 const BookmarkNode* bar = model->bookmark_bar_node(); 63 const BookmarkNode* bar = model->bookmark_bar_node();
64 const BookmarkNode* folder = 64 const BookmarkNode* folder =
65 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); 65 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder"));
66 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), 66 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"),
67 GURL("http://aaa.example.com")); 67 GURL("http://aaa.example.com"));
68 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), 68 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"),
69 GURL("http://bbb.example.com")); 69 GURL("http://bbb.example.com"));
70 70
71 PrefService* prefs = user_prefs::UserPrefs::Get(profile); 71 PrefService* prefs = user_prefs::UserPrefs::Get(profile);
72 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); 72 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false);
73 73
74 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) 74 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled"))
75 << message_; 75 << message_;
76 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698