1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
#include <set>
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "url/gurl.h"
class GURL;
namespace bookmarks_helper {
// Used to access the bookmark model within a particular sync profile.
BookmarkModel* GetBookmarkModel(int index) WARN_UNUSED_RESULT;
// Used to access the bookmark bar within a particular sync profile.
const BookmarkNode* GetBookmarkBarNode(int index) WARN_UNUSED_RESULT;
// Used to access the "other bookmarks" node within a particular sync profile.
const BookmarkNode* GetOtherNode(int index) WARN_UNUSED_RESULT;
// Used to access the "Synced Bookmarks" node within a particular sync profile.
const BookmarkNode* GetSyncedBookmarksNode(int index) WARN_UNUSED_RESULT;
// Used to access the "Managed Bookmarks" node for the given profile.
const BookmarkNode* GetManagedNode(int index) WARN_UNUSED_RESULT;
// Used to access the bookmarks within the verifier sync profile.
BookmarkModel* GetVerifierBookmarkModel() WARN_UNUSED_RESULT;
// Adds a URL with address |url| and title |title| to the bookmark bar of
// profile |profile|. Returns a pointer to the node that was added.
const BookmarkNode* AddURL(
int profile,
const std::string& title,
const GURL& url) WARN_UNUSED_RESULT;
// Adds a URL with address |url| and title |title| to the bookmark bar of
// profile |profile| at position |index|. Returns a pointer to the node that
// was added.
const BookmarkNode* AddURL(
int profile,
int index,
const std::string& title,
const GURL& url) WARN_UNUSED_RESULT;
// Adds a URL with address |url| and title |title| under the node |parent| of
// profile |profile| at position |index|. Returns a pointer to the node that
// was added.
const BookmarkNode* AddURL(
int profile,
const BookmarkNode* parent,
int index,
const std::string& title,
const GURL& url) WARN_UNUSED_RESULT;
// Adds a folder named |title| to the bookmark bar of profile |profile|.
// Returns a pointer to the folder that was added.
const BookmarkNode* AddFolder(
int profile,
const std::string& title) WARN_UNUSED_RESULT;
// Adds a folder named |title| to the bookmark bar of profile |profile| at
// position |index|. Returns a pointer to the folder that was added.
const BookmarkNode* AddFolder(
int profile,
int index,
const std::string& title) WARN_UNUSED_RESULT;
// Adds a folder named |title| to the node |parent| in the bookmark model of
// profile |profile| at position |index|. Returns a pointer to the node that
// was added.
const BookmarkNode* AddFolder(
int profile,
const BookmarkNode* parent,
int index,
const std::string& title) WARN_UNUSED_RESULT;
// Changes the title of the node |node| in the bookmark model of profile
// |profile| to |new_title|.
void SetTitle(int profile,
const BookmarkNode* node,
const std::string& new_title);
// The source of the favicon.
enum FaviconSource {
FROM_UI,
FROM_SYNC
};
// Sets the |icon_url| and |image| data for the favicon for |node| in the
// bookmark model for |profile|.
void SetFavicon(int profile,
const BookmarkNode* node,
const GURL& icon_url,
const gfx::Image& image,
FaviconSource source);
// Changes the url of the node |node| in the bookmark model of profile
// |profile| to |new_url|. Returns a pointer to the node with the changed url.
const BookmarkNode* SetURL(
int profile,
const BookmarkNode* node,
const GURL& new_url) WARN_UNUSED_RESULT;
// Moves the node |node| in the bookmark model of profile |profile| so it ends
// up under the node |new_parent| at position |index|.
void Move(
int profile,
const BookmarkNode* node,
const BookmarkNode* new_parent,
int index);
// Removes the node in the bookmark model of profile |profile| under the node
// |parent| at position |index|.
void Remove(int profile, const BookmarkNode* parent, int index);
// Removes all non-permanent nodes in the bookmark model of profile |profile|.
void RemoveAll(int profile);
// Sorts the children of the node |parent| in the bookmark model of profile
// |profile|.
void SortChildren(int profile, const BookmarkNode* parent);
// Reverses the order of the children of the node |parent| in the bookmark
// model of profile |profile|.
void ReverseChildOrder(int profile, const BookmarkNode* parent);
// Checks if the bookmark model of profile |profile| matches the verifier
// bookmark model. Returns true if they match.
bool ModelMatchesVerifier(int profile) WARN_UNUSED_RESULT;
// Checks if the bookmark models of all sync profiles match the verifier
// bookmark model. Returns true if they match.
bool AllModelsMatchVerifier() WARN_UNUSED_RESULT;
// Checks if the bookmark models of |profile_a| and |profile_b| match each
// other. Returns true if they match.
bool ModelsMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
// Checks if the bookmark models of all sync profiles match each other. Does
// not compare them with the verifier bookmark model. Returns true if they
// match.
bool AllModelsMatch() WARN_UNUSED_RESULT;
// Check if the bookmarks models of all sync profiles match each other, using
// AllModelsMatch. Returns true if bookmark models match and don't timeout
// while checking.
bool AwaitAllModelsMatch() WARN_UNUSED_RESULT;
// Checks if the bookmark model of profile |profile| contains any instances of
// two bookmarks with the same URL under the same parent folder. Returns true
// if even one instance is found.
bool ContainsDuplicateBookmarks(int profile);
// Returns whether a node exists with the specified url.
bool HasNodeWithURL(int profile, const GURL& url);
// Gets the node in the bookmark model of profile |profile| that has the url
// |url|. Note: Only one instance of |url| is assumed to be present.
const BookmarkNode* GetUniqueNodeByURL(
int profile,
const GURL& url) WARN_UNUSED_RESULT;
// Returns the number of bookmarks in bookmark model of profile |profile|
// whose titles match the string |title|.
int CountBookmarksWithTitlesMatching(
int profile,
const std::string& title) WARN_UNUSED_RESULT;
// Returns the number of bookmark folders in the bookmark model of profile
// |profile| whose titles contain the query string |title|.
int CountFoldersWithTitlesMatching(
int profile,
const std::string& title) WARN_UNUSED_RESULT;
// Creates a favicon of |color| with image reps of the platform's supported
// scale factors (eg MacOS) in addition to 1x.
gfx::Image CreateFavicon(SkColor color);
// Creates a 1x only favicon from the PNG file at |path|.
gfx::Image Create1xFaviconFromPNGFile(const std::string& path);
// Returns a URL identifiable by |i|.
std::string IndexedURL(int i);
// Returns a URL title identifiable by |i|.
std::string IndexedURLTitle(int i);
// Returns a folder name identifiable by |i|.
std::string IndexedFolderName(int i);
// Returns a subfolder name identifiable by |i|.
std::string IndexedSubfolderName(int i);
// Returns a subsubfolder name identifiable by |i|.
std::string IndexedSubsubfolderName(int i);
} // namespace bookmarks_helper
#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
|