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

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

Issue 330343002: Introduce ChromeBookmarkClientFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
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/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
12 #include "components/bookmarks/browser/bookmark_model.h" 13 #include "components/bookmarks/browser/bookmark_model.h"
13 #include "components/bookmarks/browser/bookmark_node.h" 14 #include "components/bookmarks/browser/bookmark_node.h"
14 #include "components/bookmarks/common/bookmark_pref_names.h" 15 #include "components/bookmarks/common/bookmark_pref_names.h"
15 #include "components/bookmarks/test/bookmark_test_helpers.h" 16 #include "components/bookmarks/test/bookmark_test_helpers.h"
16 17
17 // Flaky on Win only. http://crbug.com/383452 18 // Flaky on Win only. http://crbug.com/383452
18 #if defined(OS_WIN) 19 #if defined(OS_WIN)
19 #define MAYBE_Bookmarks DISABLED_Bookmarks 20 #define MAYBE_Bookmarks DISABLED_Bookmarks
20 #else 21 #else
21 #define MAYBE_Bookmarks Bookmarks 22 #define MAYBE_Bookmarks Bookmarks
22 #endif 23 #endif
23 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Bookmarks) { 24 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Bookmarks) {
24 // Add test managed bookmarks to verify that the bookmarks API can read them 25 // Add test managed bookmarks to verify that the bookmarks API can read them
25 // and can't modify them. 26 // and can't modify them.
26 Profile* profile = browser()->profile(); 27 Profile* profile = browser()->profile();
28 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
27 ChromeBookmarkClient* client = 29 ChromeBookmarkClient* client =
28 BookmarkModelFactory::GetChromeBookmarkClientForProfile(profile); 30 ChromeBookmarkClientFactory::GetForProfile(profile);
29 BookmarkModel* model = client->model();
30 test::WaitForBookmarkModelToLoad(model); 31 test::WaitForBookmarkModelToLoad(model);
31 32
32 base::ListValue list; 33 base::ListValue list;
33 base::DictionaryValue* node = new base::DictionaryValue(); 34 base::DictionaryValue* node = new base::DictionaryValue();
34 node->SetString("name", "Managed Bookmark"); 35 node->SetString("name", "Managed Bookmark");
35 node->SetString("url", "http://www.chromium.org"); 36 node->SetString("url", "http://www.chromium.org");
36 list.Append(node); 37 list.Append(node);
37 node = new base::DictionaryValue(); 38 node = new base::DictionaryValue();
38 node->SetString("name", "Managed Folder"); 39 node->SetString("name", "Managed Folder");
39 node->Set("children", new base::ListValue()); 40 node->Set("children", new base::ListValue());
40 list.Append(node); 41 list.Append(node);
41 profile->GetPrefs()->Set(prefs::kManagedBookmarks, list); 42 profile->GetPrefs()->Set(prefs::kManagedBookmarks, list);
42 ASSERT_EQ(2, client->managed_node()->child_count()); 43 ASSERT_EQ(2, client->managed_node()->child_count());
43 44
44 ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_; 45 ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
45 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698