| OLD | NEW |
| 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 "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "components/bookmarks/browser/bookmark_model.h" | 16 #include "components/bookmarks/browser/bookmark_model.h" |
| 17 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 16 #include "components/bookmarks/test/bookmark_test_helpers.h" | 18 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 17 #include "components/user_prefs/user_prefs.h" | 19 #include "components/user_prefs/user_prefs.h" |
| 18 | 20 |
| 19 // Times out on win syzyasan, http://crbug.com/166026 | 21 // Times out on win syzyasan, http://crbug.com/166026 |
| 20 #if defined(SYZYASAN) | 22 #if defined(SYZYASAN) |
| 21 #define MAYBE_BookmarkManager DISABLED_BookmarkManager | 23 #define MAYBE_BookmarkManager DISABLED_BookmarkManager |
| 22 #else | 24 #else |
| 23 #define MAYBE_BookmarkManager BookmarkManager | 25 #define MAYBE_BookmarkManager BookmarkManager |
| 24 #endif | 26 #endif |
| 25 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) { | 27 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) { |
| 28 // Add managed bookmarks. |
| 29 Profile* profile = browser()->profile(); |
| 30 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
| 31 test::WaitForBookmarkModelToLoad(model); |
| 32 |
| 33 base::ListValue list; |
| 34 base::DictionaryValue* node = new base::DictionaryValue(); |
| 35 node->SetString("name", "Managed Bookmark"); |
| 36 node->SetString("url", "http://www.chromium.org"); |
| 37 list.Append(node); |
| 38 node = new base::DictionaryValue(); |
| 39 node->SetString("name", "Managed Folder"); |
| 40 node->Set("children", new base::ListValue()); |
| 41 list.Append(node); |
| 42 profile->GetPrefs()->Set(prefs::kManagedBookmarks, list); |
| 43 ASSERT_EQ(2, model->managed_node()->child_count()); |
| 44 |
| 26 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) | 45 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) |
| 27 << message_; | 46 << message_; |
| 28 } | 47 } |
| 29 | 48 |
| 30 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { | 49 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { |
| 31 Profile* profile = browser()->profile(); | 50 Profile* profile = browser()->profile(); |
| 32 | 51 |
| 33 // Provide some testing data here, since bookmark editing will be disabled | 52 // Provide some testing data here, since bookmark editing will be disabled |
| 34 // within the extension. | 53 // within the extension. |
| 35 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 54 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
| 36 test::WaitForBookmarkModelToLoad(model); | 55 test::WaitForBookmarkModelToLoad(model); |
| 37 const BookmarkNode* bar = model->bookmark_bar_node(); | 56 const BookmarkNode* bar = model->bookmark_bar_node(); |
| 38 const BookmarkNode* folder = | 57 const BookmarkNode* folder = |
| 39 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); | 58 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); |
| 40 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), | 59 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), |
| 41 GURL("http://aaa.example.com")); | 60 GURL("http://aaa.example.com")); |
| 42 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), | 61 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), |
| 43 GURL("http://bbb.example.com")); | 62 GURL("http://bbb.example.com")); |
| 44 | 63 |
| 45 PrefService* prefs = user_prefs::UserPrefs::Get(profile); | 64 PrefService* prefs = user_prefs::UserPrefs::Get(profile); |
| 46 prefs->SetBoolean(prefs::kEditBookmarksEnabled, false); | 65 prefs->SetBoolean(prefs::kEditBookmarksEnabled, false); |
| 47 | 66 |
| 48 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) | 67 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) |
| 49 << message_; | 68 << message_; |
| 50 } | 69 } |
| OLD | NEW |