Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / bookmarks_helper.h
blob7a1a5036a50f3f74042a1074f890b14d1ee8ce8c
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 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "third_party/skia/include/core/SkColor.h"
13 class GURL;
15 namespace bookmarks {
16 class BookmarkModel;
17 class BookmarkNode;
20 namespace gfx {
21 class Image;
24 namespace bookmarks_helper {
26 // Used to access the bookmark model within a particular sync profile.
27 bookmarks::BookmarkModel* GetBookmarkModel(int index) WARN_UNUSED_RESULT;
29 // Used to access the bookmark bar within a particular sync profile.
30 const bookmarks::BookmarkNode* GetBookmarkBarNode(int index) WARN_UNUSED_RESULT;
32 // Used to access the "other bookmarks" node within a particular sync profile.
33 const bookmarks::BookmarkNode* GetOtherNode(int index) WARN_UNUSED_RESULT;
35 // Used to access the "Synced Bookmarks" node within a particular sync profile.
36 const bookmarks::BookmarkNode* GetSyncedBookmarksNode(int index)
37 WARN_UNUSED_RESULT;
39 // Used to access the "Managed Bookmarks" node for the given profile.
40 const bookmarks::BookmarkNode* GetManagedNode(int index) WARN_UNUSED_RESULT;
42 // Used to access the bookmarks within the verifier sync profile.
43 bookmarks::BookmarkModel* GetVerifierBookmarkModel() WARN_UNUSED_RESULT;
45 // Adds a URL with address |url| and title |title| to the bookmark bar of
46 // profile |profile|. Returns a pointer to the node that was added.
47 const bookmarks::BookmarkNode* AddURL(int profile,
48 const std::string& title,
49 const GURL& url) WARN_UNUSED_RESULT;
51 // Adds a URL with address |url| and title |title| to the bookmark bar of
52 // profile |profile| at position |index|. Returns a pointer to the node that
53 // was added.
54 const bookmarks::BookmarkNode* AddURL(int profile,
55 int index,
56 const std::string& title,
57 const GURL& url) WARN_UNUSED_RESULT;
59 // Adds a URL with address |url| and title |title| under the node |parent| of
60 // profile |profile| at position |index|. Returns a pointer to the node that
61 // was added.
62 const bookmarks::BookmarkNode* AddURL(int profile,
63 const bookmarks::BookmarkNode* parent,
64 int index,
65 const std::string& title,
66 const GURL& url) WARN_UNUSED_RESULT;
68 // Adds a folder named |title| to the bookmark bar of profile |profile|.
69 // Returns a pointer to the folder that was added.
70 const bookmarks::BookmarkNode* AddFolder(int profile, const std::string& title)
71 WARN_UNUSED_RESULT;
73 // Adds a folder named |title| to the bookmark bar of profile |profile| at
74 // position |index|. Returns a pointer to the folder that was added.
75 const bookmarks::BookmarkNode* AddFolder(int profile,
76 int index,
77 const std::string& title)
78 WARN_UNUSED_RESULT;
80 // Adds a folder named |title| to the node |parent| in the bookmark model of
81 // profile |profile| at position |index|. Returns a pointer to the node that
82 // was added.
83 const bookmarks::BookmarkNode* AddFolder(int profile,
84 const bookmarks::BookmarkNode* parent,
85 int index,
86 const std::string& title)
87 WARN_UNUSED_RESULT;
89 // Changes the title of the node |node| in the bookmark model of profile
90 // |profile| to |new_title|.
91 void SetTitle(int profile,
92 const bookmarks::BookmarkNode* node,
93 const std::string& new_title);
95 // The source of the favicon.
96 enum FaviconSource {
97 FROM_UI,
98 FROM_SYNC
101 // Sets the |icon_url| and |image| data for the favicon for |node| in the
102 // bookmark model for |profile|.
103 void SetFavicon(int profile,
104 const bookmarks::BookmarkNode* node,
105 const GURL& icon_url,
106 const gfx::Image& image,
107 FaviconSource source);
109 // Expires the favicon for |node| in the bookmark model for |profile|.
110 void ExpireFavicon(int profile, const bookmarks::BookmarkNode* node);
112 // Checks whether the favicon at |icon_url| for |profile| is expired;
113 void CheckFaviconExpired(int profile, const GURL& icon_url);
115 // Changes the url of the node |node| in the bookmark model of profile
116 // |profile| to |new_url|. Returns a pointer to the node with the changed url.
117 const bookmarks::BookmarkNode* SetURL(int profile,
118 const bookmarks::BookmarkNode* node,
119 const GURL& new_url) WARN_UNUSED_RESULT;
121 // Moves the node |node| in the bookmark model of profile |profile| so it ends
122 // up under the node |new_parent| at position |index|.
123 void Move(int profile,
124 const bookmarks::BookmarkNode* node,
125 const bookmarks::BookmarkNode* new_parent,
126 int index);
128 // Removes the node in the bookmark model of profile |profile| under the node
129 // |parent| at position |index|.
130 void Remove(int profile, const bookmarks::BookmarkNode* parent, int index);
132 // Removes all non-permanent nodes in the bookmark model of profile |profile|.
133 void RemoveAll(int profile);
135 // Sorts the children of the node |parent| in the bookmark model of profile
136 // |profile|.
137 void SortChildren(int profile, const bookmarks::BookmarkNode* parent);
139 // Reverses the order of the children of the node |parent| in the bookmark
140 // model of profile |profile|.
141 void ReverseChildOrder(int profile, const bookmarks::BookmarkNode* parent);
143 // Checks if the bookmark model of profile |profile| matches the verifier
144 // bookmark model. Returns true if they match.
145 bool ModelMatchesVerifier(int profile) WARN_UNUSED_RESULT;
147 // Checks if the bookmark models of all sync profiles match the verifier
148 // bookmark model. Returns true if they match.
149 bool AllModelsMatchVerifier() WARN_UNUSED_RESULT;
151 // Checks if the bookmark models of |profile_a| and |profile_b| match each
152 // other. Returns true if they match.
153 bool ModelsMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
155 // Checks if the bookmark models of all sync profiles match each other. Does
156 // not compare them with the verifier bookmark model. Returns true if they
157 // match.
158 bool AllModelsMatch() WARN_UNUSED_RESULT;
160 // Check if the bookmarks models of all sync profiles match each other, using
161 // AllModelsMatch. Returns true if bookmark models match and don't timeout
162 // while checking.
163 bool AwaitAllModelsMatch() WARN_UNUSED_RESULT;
165 // Blocks the caller until the given |profile| contains |expected_count|
166 // bookmarks with |title| or until waiting times out.
167 bool AwaitCountBookmarksWithTitlesMatching(int profile,
168 const std::string& title,
169 int expected_count)
170 WARN_UNUSED_RESULT;
172 // Blocks the caller until the given |profile| contains |expected_count|
173 // bookmarks with |url| or until waiting times out.
174 bool AwaitCountBookmarksWithUrlsMatching(int profile,
175 const GURL& url,
176 int expected_count) WARN_UNUSED_RESULT;
178 // Checks if the bookmark model of profile |profile| contains any instances of
179 // two bookmarks with the same URL under the same parent folder. Returns true
180 // if even one instance is found.
181 bool ContainsDuplicateBookmarks(int profile);
183 // Returns whether a node exists with the specified url.
184 bool HasNodeWithURL(int profile, const GURL& url);
186 // Gets the node in the bookmark model of profile |profile| that has the url
187 // |url|. Note: Only one instance of |url| is assumed to be present.
188 const bookmarks::BookmarkNode* GetUniqueNodeByURL(int profile, const GURL& url)
189 WARN_UNUSED_RESULT;
191 // Returns the number of bookmarks in bookmark model of profile |profile|.
192 int CountAllBookmarks(int profile) WARN_UNUSED_RESULT;
194 // Returns the number of bookmarks in bookmark model of profile |profile|
195 // whose titles match the string |title|.
196 int CountBookmarksWithTitlesMatching(
197 int profile,
198 const std::string& title) WARN_UNUSED_RESULT;
200 // Returns the number of bookmarks in bookmark model of profile |profile|
201 // whose URLs match the |url|.
202 int CountBookmarksWithUrlsMatching(int profile,
203 const GURL& url) WARN_UNUSED_RESULT;
205 // Returns the number of bookmark folders in the bookmark model of profile
206 // |profile| whose titles contain the query string |title|.
207 int CountFoldersWithTitlesMatching(
208 int profile,
209 const std::string& title) WARN_UNUSED_RESULT;
211 // Creates a favicon of |color| with image reps of the platform's supported
212 // scale factors (eg MacOS) in addition to 1x.
213 gfx::Image CreateFavicon(SkColor color);
215 // Creates a 1x only favicon from the PNG file at |path|.
216 gfx::Image Create1xFaviconFromPNGFile(const std::string& path);
218 // Returns a URL identifiable by |i|.
219 std::string IndexedURL(int i);
221 // Returns a URL title identifiable by |i|.
222 std::string IndexedURLTitle(int i);
224 // Returns a folder name identifiable by |i|.
225 std::string IndexedFolderName(int i);
227 // Returns a subfolder name identifiable by |i|.
228 std::string IndexedSubfolderName(int i);
230 // Returns a subsubfolder name identifiable by |i|.
231 std::string IndexedSubsubfolderName(int i);
233 } // namespace bookmarks_helper
235 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_