Fire an error if a pref used in the UI is missing once all prefs are fetched.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / bookmarks_helper.h
bloba22976048822bb281a2637346481d504d9ce992f
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 // Changes the url of the node |node| in the bookmark model of profile
110 // |profile| to |new_url|. Returns a pointer to the node with the changed url.
111 const bookmarks::BookmarkNode* SetURL(int profile,
112 const bookmarks::BookmarkNode* node,
113 const GURL& new_url) WARN_UNUSED_RESULT;
115 // Moves the node |node| in the bookmark model of profile |profile| so it ends
116 // up under the node |new_parent| at position |index|.
117 void Move(int profile,
118 const bookmarks::BookmarkNode* node,
119 const bookmarks::BookmarkNode* new_parent,
120 int index);
122 // Removes the node in the bookmark model of profile |profile| under the node
123 // |parent| at position |index|.
124 void Remove(int profile, const bookmarks::BookmarkNode* parent, int index);
126 // Removes all non-permanent nodes in the bookmark model of profile |profile|.
127 void RemoveAll(int profile);
129 // Sorts the children of the node |parent| in the bookmark model of profile
130 // |profile|.
131 void SortChildren(int profile, const bookmarks::BookmarkNode* parent);
133 // Reverses the order of the children of the node |parent| in the bookmark
134 // model of profile |profile|.
135 void ReverseChildOrder(int profile, const bookmarks::BookmarkNode* parent);
137 // Checks if the bookmark model of profile |profile| matches the verifier
138 // bookmark model. Returns true if they match.
139 bool ModelMatchesVerifier(int profile) WARN_UNUSED_RESULT;
141 // Checks if the bookmark models of all sync profiles match the verifier
142 // bookmark model. Returns true if they match.
143 bool AllModelsMatchVerifier() WARN_UNUSED_RESULT;
145 // Checks if the bookmark models of |profile_a| and |profile_b| match each
146 // other. Returns true if they match.
147 bool ModelsMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
149 // Checks if the bookmark models of all sync profiles match each other. Does
150 // not compare them with the verifier bookmark model. Returns true if they
151 // match.
152 bool AllModelsMatch() WARN_UNUSED_RESULT;
154 // Check if the bookmarks models of all sync profiles match each other, using
155 // AllModelsMatch. Returns true if bookmark models match and don't timeout
156 // while checking.
157 bool AwaitAllModelsMatch() WARN_UNUSED_RESULT;
159 // Checks if the bookmark model of profile |profile| contains any instances of
160 // two bookmarks with the same URL under the same parent folder. Returns true
161 // if even one instance is found.
162 bool ContainsDuplicateBookmarks(int profile);
164 // Returns whether a node exists with the specified url.
165 bool HasNodeWithURL(int profile, const GURL& url);
167 // Gets the node in the bookmark model of profile |profile| that has the url
168 // |url|. Note: Only one instance of |url| is assumed to be present.
169 const bookmarks::BookmarkNode* GetUniqueNodeByURL(int profile, const GURL& url)
170 WARN_UNUSED_RESULT;
172 // Returns the number of bookmarks in bookmark model of profile |profile|.
173 int CountAllBookmarks(int profile) WARN_UNUSED_RESULT;
175 // Returns the number of bookmarks in bookmark model of profile |profile|
176 // whose titles match the string |title|.
177 int CountBookmarksWithTitlesMatching(
178 int profile,
179 const std::string& title) WARN_UNUSED_RESULT;
181 // Returns the number of bookmark folders in the bookmark model of profile
182 // |profile| whose titles contain the query string |title|.
183 int CountFoldersWithTitlesMatching(
184 int profile,
185 const std::string& title) WARN_UNUSED_RESULT;
187 // Creates a favicon of |color| with image reps of the platform's supported
188 // scale factors (eg MacOS) in addition to 1x.
189 gfx::Image CreateFavicon(SkColor color);
191 // Creates a 1x only favicon from the PNG file at |path|.
192 gfx::Image Create1xFaviconFromPNGFile(const std::string& path);
194 // Returns a URL identifiable by |i|.
195 std::string IndexedURL(int i);
197 // Returns a URL title identifiable by |i|.
198 std::string IndexedURLTitle(int i);
200 // Returns a folder name identifiable by |i|.
201 std::string IndexedFolderName(int i);
203 // Returns a subfolder name identifiable by |i|.
204 std::string IndexedSubfolderName(int i);
206 // Returns a subsubfolder name identifiable by |i|.
207 std::string IndexedSubsubfolderName(int i);
209 } // namespace bookmarks_helper
211 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_