| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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. | |
| 4 | |
| 5 #ifndef CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_ | |
| 6 #define CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "chrome/browser/bookmarks/bookmark_model.h" | |
| 14 #include "chrome/test/live_sync/bookmark_model_verifier.h" | |
| 15 #include "chrome/test/live_sync/live_sync_test.h" | |
| 16 #include "testing/gtest/include/gtest/gtest.h" | |
| 17 | |
| 18 class GURL; | |
| 19 class Profile; | |
| 20 | |
| 21 class LiveBookmarksSyncTest : public LiveSyncTest { | |
| 22 public: | |
| 23 explicit LiveBookmarksSyncTest(TestType test_type); | |
| 24 virtual ~LiveBookmarksSyncTest(); | |
| 25 | |
| 26 // Sets up sync profiles and clients and initializes the bookmark verifier. | |
| 27 virtual bool SetupClients() WARN_UNUSED_RESULT; | |
| 28 | |
| 29 // Used to access the bookmark model within a particular sync profile. | |
| 30 BookmarkModel* GetBookmarkModel(int index) WARN_UNUSED_RESULT; | |
| 31 | |
| 32 // Used to access the bookmark bar within a particular sync profile. | |
| 33 const BookmarkNode* GetBookmarkBarNode(int index) WARN_UNUSED_RESULT; | |
| 34 | |
| 35 // Used to access the "other bookmarks" node within a particular sync profile. | |
| 36 const BookmarkNode* GetOtherNode(int index) WARN_UNUSED_RESULT; | |
| 37 | |
| 38 // Used to access the bookmarks within the verifier sync profile. | |
| 39 BookmarkModel* GetVerifierBookmarkModel() WARN_UNUSED_RESULT; | |
| 40 | |
| 41 // After calling this method, changes made to a bookmark model will no longer | |
| 42 // be reflected in the verifier model. | |
| 43 void DisableVerifier(); | |
| 44 | |
| 45 // Encrypt Bookmarks datatype. | |
| 46 bool EnableEncryption(int index); | |
| 47 | |
| 48 // Check if Bookmarks are encrypted. | |
| 49 bool IsEncrypted(int index); | |
| 50 | |
| 51 // Adds a URL with address |url| and title |title| to the bookmark bar of | |
| 52 // profile |profile|. Returns a pointer to the node that was added. | |
| 53 const BookmarkNode* AddURL(int profile, | |
| 54 const std::wstring& title, | |
| 55 const GURL& url) WARN_UNUSED_RESULT; | |
| 56 | |
| 57 // Adds a URL with address |url| and title |title| to the bookmark bar of | |
| 58 // profile |profile| at position |index|. Returns a pointer to the node that | |
| 59 // was added. | |
| 60 const BookmarkNode* AddURL(int profile, | |
| 61 int index, | |
| 62 const std::wstring& title, | |
| 63 const GURL& url) WARN_UNUSED_RESULT; | |
| 64 | |
| 65 // Adds a URL with address |url| and title |title| under the node |parent| of | |
| 66 // profile |profile| at position |index|. Returns a pointer to the node that | |
| 67 // was added. | |
| 68 const BookmarkNode* AddURL(int profile, | |
| 69 const BookmarkNode* parent, | |
| 70 int index, | |
| 71 const std::wstring& title, | |
| 72 const GURL& url) WARN_UNUSED_RESULT; | |
| 73 | |
| 74 // Adds a folder named |title| to the bookmark bar of profile |profile|. | |
| 75 // Returns a pointer to the folder that was added. | |
| 76 const BookmarkNode* AddFolder(int profile, | |
| 77 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 78 | |
| 79 // Adds a folder named |title| to the bookmark bar of profile |profile| at | |
| 80 // position |index|. Returns a pointer to the folder that was added. | |
| 81 const BookmarkNode* AddFolder(int profile, | |
| 82 int index, | |
| 83 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 84 | |
| 85 // Adds a folder named |title| to the node |parent| in the bookmark model of | |
| 86 // profile |profile| at position |index|. Returns a pointer to the node that | |
| 87 // was added. | |
| 88 const BookmarkNode* AddFolder(int profile, | |
| 89 const BookmarkNode* parent, | |
| 90 int index, | |
| 91 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 92 | |
| 93 // Changes the title of the node |node| in the bookmark model of profile | |
| 94 // |profile| to |new_title|. | |
| 95 void SetTitle(int profile, | |
| 96 const BookmarkNode* node, | |
| 97 const std::wstring& new_title); | |
| 98 | |
| 99 // Sets the favicon of the node |node| (of type BookmarkNode::URL) in the | |
| 100 // bookmark model of profile |profile| using the data in |icon_bytes_vector|. | |
| 101 void SetFavicon(int profile, | |
| 102 const BookmarkNode* node, | |
| 103 const std::vector<unsigned char>& icon_bytes_vector); | |
| 104 | |
| 105 // Changes the url of the node |node| in the bookmark model of profile | |
| 106 // |profile| to |new_url|. Returns a pointer to the node with the changed url. | |
| 107 const BookmarkNode* SetURL(int profile, | |
| 108 const BookmarkNode* node, | |
| 109 const GURL& new_url) WARN_UNUSED_RESULT; | |
| 110 | |
| 111 // Moves the node |node| in the bookmark model of profile |profile| so it ends | |
| 112 // up under the node |new_parent| at position |index|. | |
| 113 void Move(int profile, | |
| 114 const BookmarkNode* node, | |
| 115 const BookmarkNode* new_parent, | |
| 116 int index); | |
| 117 | |
| 118 // Removes the node in the bookmark model of profile |profile| under the node | |
| 119 // |parent| at position |index|. | |
| 120 void Remove(int profile, const BookmarkNode* parent, int index); | |
| 121 | |
| 122 // Sorts the children of the node |parent| in the bookmark model of profile | |
| 123 // |profile|. | |
| 124 void SortChildren(int profile, const BookmarkNode* parent); | |
| 125 | |
| 126 // Reverses the order of the children of the node |parent| in the bookmark | |
| 127 // model of profile |profile|. | |
| 128 void ReverseChildOrder(int profile, const BookmarkNode* parent); | |
| 129 | |
| 130 // Checks if the bookmark model of profile |profile| matches the verifier | |
| 131 // bookmark model. Returns true if they match. | |
| 132 bool ModelMatchesVerifier(int profile) WARN_UNUSED_RESULT; | |
| 133 | |
| 134 // Checks if the bookmark models of all sync profiles match the verifier | |
| 135 // bookmark model. Returns true if they match. | |
| 136 bool AllModelsMatchVerifier() WARN_UNUSED_RESULT; | |
| 137 | |
| 138 // Checks if the bookmark models of |profile_a| and |profile_b| match each | |
| 139 // other. Returns true if they match. | |
| 140 bool ModelsMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; | |
| 141 | |
| 142 // Checks if the bookmark models of all sync profiles match each other. Does | |
| 143 // not compare them with the verifier bookmark model. Returns true if they | |
| 144 // match. | |
| 145 bool AllModelsMatch() WARN_UNUSED_RESULT; | |
| 146 | |
| 147 // Checks if the bookmark model of profile |profile| contains any instances of | |
| 148 // two bookmarks with the same URL under the same parent folder. Returns true | |
| 149 // if even one instance is found. | |
| 150 bool ContainsDuplicateBookmarks(int profile); | |
| 151 | |
| 152 // Gets the node in the bookmark model of profile |profile| that has the url | |
| 153 // |url|. Note: Only one instance of |url| is assumed to be present. | |
| 154 const BookmarkNode* GetUniqueNodeByURL(int profile, | |
| 155 const GURL& url) WARN_UNUSED_RESULT; | |
| 156 | |
| 157 // Returns the number of bookmarks in bookmark model of profile |profile| | |
| 158 // whose titles match the string |title|. | |
| 159 int CountBookmarksWithTitlesMatching(int profile, const std::wstring& title) | |
| 160 WARN_UNUSED_RESULT; | |
| 161 | |
| 162 // Returns the number of bookmark folders in the bookmark model of profile | |
| 163 // |profile| whose titles contain the query string |title|. | |
| 164 int CountFoldersWithTitlesMatching( | |
| 165 int profile, | |
| 166 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 167 | |
| 168 // Creates a unique favicon using |seed|. | |
| 169 static std::vector<unsigned char> CreateFavicon(int seed); | |
| 170 | |
| 171 // Returns a URL identifiable by |i|. | |
| 172 static std::string IndexedURL(int i); | |
| 173 | |
| 174 // Returns a URL title identifiable by |i|. | |
| 175 static std::wstring IndexedURLTitle(int i); | |
| 176 | |
| 177 // Returns a folder name identifiable by |i|. | |
| 178 static std::wstring IndexedFolderName(int i); | |
| 179 | |
| 180 // Returns a subfolder name identifiable by |i|. | |
| 181 static std::wstring IndexedSubfolderName(int i); | |
| 182 | |
| 183 // Returns a subsubfolder name identifiable by |i|. | |
| 184 static std::wstring IndexedSubsubfolderName(int i); | |
| 185 | |
| 186 private: | |
| 187 // Helper object that has the functionality to verify changes made to the | |
| 188 // bookmarks of individual profiles. | |
| 189 scoped_ptr<BookmarkModelVerifier> verifier_helper_; | |
| 190 | |
| 191 DISALLOW_COPY_AND_ASSIGN(LiveBookmarksSyncTest); | |
| 192 }; | |
| 193 | |
| 194 class SingleClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest { | |
| 195 public: | |
| 196 SingleClientLiveBookmarksSyncTest() | |
| 197 : LiveBookmarksSyncTest(SINGLE_CLIENT) {} | |
| 198 virtual ~SingleClientLiveBookmarksSyncTest() {} | |
| 199 | |
| 200 private: | |
| 201 DISALLOW_COPY_AND_ASSIGN(SingleClientLiveBookmarksSyncTest); | |
| 202 }; | |
| 203 | |
| 204 class TwoClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest { | |
| 205 public: | |
| 206 TwoClientLiveBookmarksSyncTest() | |
| 207 : LiveBookmarksSyncTest(TWO_CLIENT) {} | |
| 208 virtual ~TwoClientLiveBookmarksSyncTest() {} | |
| 209 | |
| 210 private: | |
| 211 DISALLOW_COPY_AND_ASSIGN(TwoClientLiveBookmarksSyncTest); | |
| 212 }; | |
| 213 | |
| 214 class MultipleClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest { | |
| 215 public: | |
| 216 MultipleClientLiveBookmarksSyncTest() | |
| 217 : LiveBookmarksSyncTest(MULTIPLE_CLIENT) {} | |
| 218 virtual ~MultipleClientLiveBookmarksSyncTest() {} | |
| 219 | |
| 220 private: | |
| 221 DISALLOW_COPY_AND_ASSIGN(MultipleClientLiveBookmarksSyncTest); | |
| 222 }; | |
| 223 | |
| 224 class ManyClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest { | |
| 225 public: | |
| 226 ManyClientLiveBookmarksSyncTest() | |
| 227 : LiveBookmarksSyncTest(MANY_CLIENT) {} | |
| 228 virtual ~ManyClientLiveBookmarksSyncTest() {} | |
| 229 | |
| 230 private: | |
| 231 DISALLOW_COPY_AND_ASSIGN(ManyClientLiveBookmarksSyncTest); | |
| 232 }; | |
| 233 | |
| 234 #endif // CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_ | |
| OLD | NEW |