Extensions cleanup: Merge IsSyncableApp+Extension, ShouldSyncApp+Extension
[chromium-blink-merge.git] / chrome / browser / extensions / api / bookmark_manager_private / bookmark_manager_private_apitest.cc
blob5fedf2dc8b9caf3620185abb36f338b1c2b2fe7d
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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.h"
7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
13 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
14 #include "chrome/browser/extensions/extension_apitest.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/common/pref_names.h"
18 #include "components/bookmarks/browser/bookmark_model.h"
19 #include "components/bookmarks/common/bookmark_pref_names.h"
20 #include "components/bookmarks/test/bookmark_test_helpers.h"
21 #include "components/user_prefs/user_prefs.h"
23 using bookmarks::BookmarkModel;
24 using bookmarks::BookmarkNode;
26 // Times out on win syzyasan, http://crbug.com/166026
27 #if defined(SYZYASAN)
28 #define MAYBE_BookmarkManager DISABLED_BookmarkManager
29 #else
30 #define MAYBE_BookmarkManager BookmarkManager
31 #endif
32 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) {
33 // Add managed bookmarks.
34 Profile* profile = browser()->profile();
35 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
36 ChromeBookmarkClient* client =
37 ChromeBookmarkClientFactory::GetForProfile(profile);
38 bookmarks::test::WaitForBookmarkModelToLoad(model);
40 base::ListValue list;
41 base::DictionaryValue* node = new base::DictionaryValue();
42 node->SetString("name", "Managed Bookmark");
43 node->SetString("url", "http://www.chromium.org");
44 list.Append(node);
45 node = new base::DictionaryValue();
46 node->SetString("name", "Managed Folder");
47 node->Set("children", new base::ListValue());
48 list.Append(node);
49 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list);
50 ASSERT_EQ(2, client->managed_node()->child_count());
52 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard"))
53 << message_;
56 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) {
57 Profile* profile = browser()->profile();
59 // Provide some testing data here, since bookmark editing will be disabled
60 // within the extension.
61 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
62 bookmarks::test::WaitForBookmarkModelToLoad(model);
63 const BookmarkNode* bar = model->bookmark_bar_node();
64 const BookmarkNode* folder =
65 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder"));
66 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"),
67 GURL("http://aaa.example.com"));
68 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"),
69 GURL("http://bbb.example.com"));
71 PrefService* prefs = user_prefs::UserPrefs::Get(profile);
72 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false);
74 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled"))
75 << message_;