OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 profile2_.get(), username_, password_)); | 43 profile2_.get(), username_, password_)); |
44 if (ShouldSetupSyncWithRace()) { | 44 if (ShouldSetupSyncWithRace()) { |
45 return client1_->SetupSync() && client2_->SetupSync(); | 45 return client1_->SetupSync() && client2_->SetupSync(); |
46 } else { | 46 } else { |
47 bool result_client1 = client1_->SetupSync(); | 47 bool result_client1 = client1_->SetupSync(); |
48 client1()->AwaitSyncCycleCompletion("Initial setup"); | 48 client1()->AwaitSyncCycleCompletion("Initial setup"); |
49 return result_client1 && client2_->SetupSync(); | 49 return result_client1 && client2_->SetupSync(); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
| 53 // Overwrites ShouldDeleteProfile, so profile doesn't get deleted. |
| 54 virtual bool ShouldDeleteProfile() { |
| 55 return false; |
| 56 } |
| 57 |
53 // Overload this method in inherited class and return false to avoid | 58 // Overload this method in inherited class and return false to avoid |
54 // race condition (two clients trying to sync/commit at the same time). | 59 // race condition (two clients trying to sync/commit at the same time). |
55 // Race condition may lead to duplicate bookmarks if there is existing | 60 // Race condition may lead to duplicate bookmarks if there is existing |
56 // bookmark model on both clients. | 61 // bookmark model on both clients. |
57 virtual bool ShouldSetupSyncWithRace() { | 62 virtual bool ShouldSetupSyncWithRace() { |
58 return true; | 63 return true; |
59 } | 64 } |
60 | 65 |
61 // Overload this method in your class and return true to pre-populate | 66 // Overload this method in your class and return true to pre-populate |
62 // bookmark files for client2 also. | 67 // bookmark files for client2 also. |
(...skipping 19 matching lines...) Expand all Loading... |
82 FilePath sync_data_source; | 87 FilePath sync_data_source; |
83 PathService::Get(base::DIR_SOURCE_ROOT, &sync_data_source); | 88 PathService::Get(base::DIR_SOURCE_ROOT, &sync_data_source); |
84 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("chrome")); | 89 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("chrome")); |
85 sync_data_source = sync_data_source.Append( | 90 sync_data_source = sync_data_source.Append( |
86 FILE_PATH_LITERAL("personalization")); | 91 FILE_PATH_LITERAL("personalization")); |
87 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("test")); | 92 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("test")); |
88 sync_data_source = sync_data_source.Append( | 93 sync_data_source = sync_data_source.Append( |
89 FILE_PATH_LITERAL("live_sync_data")); | 94 FILE_PATH_LITERAL("live_sync_data")); |
90 FilePath source_file = sync_data_source.Append( | 95 FilePath source_file = sync_data_source.Append( |
91 bookmarks_file_name); | 96 bookmarks_file_name); |
92 ASSERT_TRUE(file_util::PathExists(source_file)) | 97 ASSERT_TRUE(file_util::PathExists(source_file)); |
93 << "Could not locate test data file: " << source_file.value(); | |
94 // Now copy pre-generated bookmark file to default profile. | 98 // Now copy pre-generated bookmark file to default profile. |
95 ASSERT_TRUE(file_util::CopyFile(source_file, | 99 ASSERT_TRUE(file_util::CopyFile(source_file, |
96 dest_user_data_dir_default.Append(FILE_PATH_LITERAL("bookmarks")))); | 100 dest_user_data_dir_default.Append(FILE_PATH_LITERAL("bookmarks")))); |
97 // Now copy pre-generated bookmark file to verifier profile. | 101 // Now copy pre-generated bookmark file to verifier profile. |
98 ASSERT_TRUE(file_util::CopyFile(source_file, | 102 ASSERT_TRUE(file_util::CopyFile(source_file, |
99 dest_user_data_dir_verifier.Append(FILE_PATH_LITERAL("bookmarks")))); | 103 dest_user_data_dir_verifier.Append(FILE_PATH_LITERAL("bookmarks")))); |
100 | 104 |
101 // Let's pre-populate bookmarks file for client2 also if we need to. | 105 // Let's pre-populate bookmarks file for client2 also if we need to. |
102 if (ShouldCopyBookmarksToClient2()) { | 106 if (ShouldCopyBookmarksToClient2()) { |
103 // Let's create verifier profile directory. | 107 // Let's create verifier profile directory. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 144 |
141 DISALLOW_COPY_AND_ASSIGN(TwoClientLiveBookmarksSyncTest); | 145 DISALLOW_COPY_AND_ASSIGN(TwoClientLiveBookmarksSyncTest); |
142 }; | 146 }; |
143 | 147 |
144 class LiveSyncTestPrePopulatedHistory1K | 148 class LiveSyncTestPrePopulatedHistory1K |
145 : public TwoClientLiveBookmarksSyncTest { | 149 : public TwoClientLiveBookmarksSyncTest { |
146 public: | 150 public: |
147 LiveSyncTestPrePopulatedHistory1K() {} | 151 LiveSyncTestPrePopulatedHistory1K() {} |
148 virtual ~LiveSyncTestPrePopulatedHistory1K() {} | 152 virtual ~LiveSyncTestPrePopulatedHistory1K() {} |
149 | 153 |
150 // This is used to pre-populate history data (1K URL Visit) to Client1 | 154 // This is used to pre-populate history data (1K URL Visit)to Client1 |
151 // and Verifier Client. Invoked by InProcBrowserTest::SetUp before | 155 // and Verifier Client. |
152 // the browser is started. | 156 void PrePopulateHistory1K() { |
153 virtual void SetUpUserDataDirectory() { | |
154 // Let's copy history files to default profile. | 157 // Let's copy history files to default profile. |
155 FilePath dest_user_data_dir; | 158 FilePath dest_user_data_dir; |
156 PathService::Get(chrome::DIR_USER_DATA, &dest_user_data_dir); | 159 PathService::Get(chrome::DIR_USER_DATA, &dest_user_data_dir); |
157 dest_user_data_dir = dest_user_data_dir.Append( | 160 dest_user_data_dir = dest_user_data_dir.Append( |
158 FILE_PATH_LITERAL("Default")); | 161 FILE_PATH_LITERAL("Default")); |
159 file_util::CreateDirectory(dest_user_data_dir); | 162 file_util::CreateDirectory(dest_user_data_dir); |
160 FilePath sync_data_source; | 163 FilePath sync_data_source; |
161 PathService::Get(base::DIR_SOURCE_ROOT, &sync_data_source); | 164 PathService::Get(base::DIR_SOURCE_ROOT, &sync_data_source); |
162 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("chrome")); | 165 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("chrome")); |
163 sync_data_source = sync_data_source.Append( | 166 sync_data_source = sync_data_source.Append( |
164 FILE_PATH_LITERAL("personalization")); | 167 FILE_PATH_LITERAL("personalization")); |
165 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("test")); | 168 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("test")); |
166 sync_data_source = sync_data_source.Append( | 169 sync_data_source = sync_data_source.Append( |
167 FILE_PATH_LITERAL("live_sync_data")); | 170 FILE_PATH_LITERAL("live_sync_data")); |
168 sync_data_source = sync_data_source.Append( | 171 sync_data_source = sync_data_source.Append( |
169 FILE_PATH_LITERAL("1K_url_visit_history")); | 172 FILE_PATH_LITERAL("1K_url_visit_history")); |
170 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("Default")); | 173 sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("Default")); |
171 ASSERT_TRUE(file_util::PathExists(sync_data_source)); | 174 ASSERT_TRUE(file_util::PathExists(sync_data_source)); |
172 file_util::FileEnumerator sync_data( | 175 file_util::FileEnumerator sync_data( |
173 sync_data_source, false, file_util::FileEnumerator::FILES); | 176 sync_data_source, false, file_util::FileEnumerator::FILES); |
174 FilePath source_file = sync_data.Next(); | 177 FilePath source_file = sync_data.Next(); |
175 while (!source_file.empty()) { | 178 while (!source_file.empty()) { |
176 FilePath dest_file = dest_user_data_dir.Append(source_file.BaseName()); | 179 FilePath dest_file = dest_user_data_dir.Append(source_file.BaseName()); |
177 ASSERT_TRUE(file_util::CopyFile(source_file, dest_file)); | 180 ASSERT_TRUE(file_util::CopyFile(source_file, dest_file)); |
178 source_file = sync_data.Next(); | 181 source_file = sync_data.Next(); |
179 } | 182 } |
180 } | 183 } |
181 | 184 |
| 185 virtual void SetUp() { |
| 186 PrePopulateHistory1K(); |
| 187 LiveSyncTest::SetUp(); |
| 188 } |
| 189 |
182 private: | 190 private: |
183 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestPrePopulatedHistory1K); | 191 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestPrePopulatedHistory1K); |
184 }; | 192 }; |
185 | 193 |
186 class LiveSyncTestBasicHierarchy50BM | 194 class LiveSyncTestBasicHierarchy50BM |
187 : public TwoClientLiveBookmarksSyncTest { | 195 : public TwoClientLiveBookmarksSyncTest { |
188 public: | 196 public: |
189 LiveSyncTestBasicHierarchy50BM() {} | 197 LiveSyncTestBasicHierarchy50BM() {} |
190 virtual ~LiveSyncTestBasicHierarchy50BM() {} | 198 virtual ~LiveSyncTestBasicHierarchy50BM() {} |
191 | 199 |
192 // Invoked by InProcBrowserTest::SetUp before the browser is started. | 200 virtual void SetUp() { |
193 virtual void SetUpUserDataDirectory() { | |
194 FilePath file_name(FILE_PATH_LITERAL("bookmarks_50BM5F3L")); | 201 FilePath file_name(FILE_PATH_LITERAL("bookmarks_50BM5F3L")); |
195 PrePopulateBookmarksHierarchy(file_name); | 202 PrePopulateBookmarksHierarchy(file_name); |
| 203 LiveSyncTest::SetUp(); |
196 } | 204 } |
197 | 205 |
198 private: | 206 private: |
199 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestBasicHierarchy50BM); | 207 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestBasicHierarchy50BM); |
200 }; | 208 }; |
201 | 209 |
202 class LiveSyncTestBasicHierarchy50BMBothClients | 210 class LiveSyncTestBasicHierarchy50BMBothClients |
203 : public LiveSyncTestBasicHierarchy50BM { | 211 : public LiveSyncTestBasicHierarchy50BM { |
204 public: | 212 public: |
205 LiveSyncTestBasicHierarchy50BMBothClients() {} | 213 LiveSyncTestBasicHierarchy50BMBothClients() {} |
(...skipping 12 matching lines...) Expand all Loading... |
218 | 226 |
219 private: | 227 private: |
220 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestBasicHierarchy50BMBothClients); | 228 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestBasicHierarchy50BMBothClients); |
221 }; | 229 }; |
222 | 230 |
223 class LiveSyncTestComplexHierarchy800BM | 231 class LiveSyncTestComplexHierarchy800BM |
224 : public TwoClientLiveBookmarksSyncTest { | 232 : public TwoClientLiveBookmarksSyncTest { |
225 public: | 233 public: |
226 LiveSyncTestComplexHierarchy800BM() {} | 234 LiveSyncTestComplexHierarchy800BM() {} |
227 virtual ~LiveSyncTestComplexHierarchy800BM() {} | 235 virtual ~LiveSyncTestComplexHierarchy800BM() {} |
228 | 236 virtual void SetUp() { |
229 // Invoked by InProcBrowserTest::SetUp before the browser is started. | |
230 virtual void SetUpUserDataDirectory() { | |
231 FilePath file_name(FILE_PATH_LITERAL("bookmarks_800BM32F8L")); | 237 FilePath file_name(FILE_PATH_LITERAL("bookmarks_800BM32F8L")); |
232 PrePopulateBookmarksHierarchy(file_name); | 238 TwoClientLiveBookmarksSyncTest::PrePopulateBookmarksHierarchy(file_name); |
| 239 LiveSyncTest::SetUp(); |
233 } | 240 } |
234 | 241 |
235 private: | 242 private: |
236 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestComplexHierarchy800BM); | 243 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestComplexHierarchy800BM); |
237 }; | 244 }; |
238 | 245 |
239 class LiveSyncTestHugeHierarchy5500BM | 246 class LiveSyncTestHugeHierarchy5500BM |
240 : public TwoClientLiveBookmarksSyncTest { | 247 : public TwoClientLiveBookmarksSyncTest { |
241 public: | 248 public: |
242 LiveSyncTestHugeHierarchy5500BM() {} | 249 LiveSyncTestHugeHierarchy5500BM() {} |
243 virtual ~LiveSyncTestHugeHierarchy5500BM() {} | 250 virtual ~LiveSyncTestHugeHierarchy5500BM() {} |
244 | 251 virtual void SetUp() { |
245 // Invoked by InProcBrowserTest::SetUp before the browser is started. | |
246 virtual void SetUpUserDataDirectory() { | |
247 FilePath file_name(FILE_PATH_LITERAL("bookmarks_5500BM125F25L")); | 252 FilePath file_name(FILE_PATH_LITERAL("bookmarks_5500BM125F25L")); |
248 PrePopulateBookmarksHierarchy(file_name); | 253 TwoClientLiveBookmarksSyncTest::PrePopulateBookmarksHierarchy(file_name); |
| 254 LiveSyncTest::SetUp(); |
249 } | 255 } |
250 virtual bool ShouldSetupSyncWithRace() { | 256 virtual bool ShouldSetupSyncWithRace() { |
251 return false; | 257 return false; |
252 } | 258 } |
253 | 259 |
254 private: | 260 private: |
255 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestHugeHierarchy5500BM); | 261 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestHugeHierarchy5500BM); |
256 }; | 262 }; |
257 | 263 |
258 class LiveSyncTestDefaultIEFavorites | 264 class LiveSyncTestDefaultIEFavorites |
259 : public TwoClientLiveBookmarksSyncTest { | 265 : public TwoClientLiveBookmarksSyncTest { |
260 public: | 266 public: |
261 LiveSyncTestDefaultIEFavorites() {} | 267 LiveSyncTestDefaultIEFavorites() {} |
262 virtual ~LiveSyncTestDefaultIEFavorites() {} | 268 virtual ~LiveSyncTestDefaultIEFavorites() {} |
263 | 269 |
264 // Invoked by InProcBrowserTest::SetUp before the browser is started. | 270 virtual void SetUp() { |
265 virtual void SetUpUserDataDirectory() { | |
266 const FilePath file_name( | 271 const FilePath file_name( |
267 FILE_PATH_LITERAL("bookmarks_default_IE_favorites")); | 272 FILE_PATH_LITERAL("bookmarks_default_IE_favorites")); |
268 TwoClientLiveBookmarksSyncTest::PrePopulateBookmarksHierarchy(file_name); | 273 TwoClientLiveBookmarksSyncTest::PrePopulateBookmarksHierarchy(file_name); |
| 274 LiveSyncTest::SetUp(); |
269 } | 275 } |
270 | 276 |
271 private: | 277 private: |
272 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestDefaultIEFavorites); | 278 DISALLOW_COPY_AND_ASSIGN(LiveSyncTestDefaultIEFavorites); |
273 }; | 279 }; |
274 | 280 |
275 | 281 |
276 | 282 |
277 // Test case Naming Convention: | 283 // Test case Naming Convention: |
278 // SC/MC - SingleClient / MultiClient. | 284 // SC/MC - SingleClient / MultiClient. |
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 // Wait for changes to propagate. | 2521 // Wait for changes to propagate. |
2516 ASSERT_TRUE(client2()->AwaitMutualSyncCycleCompletion(client1())); | 2522 ASSERT_TRUE(client2()->AwaitMutualSyncCycleCompletion(client1())); |
2517 // Let's make sure there aren't any duplicates after sync. | 2523 // Let's make sure there aren't any duplicates after sync. |
2518 BookmarkModelVerifier::VerifyNoDuplicates(model_one); | 2524 BookmarkModelVerifier::VerifyNoDuplicates(model_one); |
2519 // Let's compare and make sure both bookmark models are same after sync. | 2525 // Let's compare and make sure both bookmark models are same after sync. |
2520 BookmarkModelVerifier::ExpectModelsMatchIncludingFavicon( | 2526 BookmarkModelVerifier::ExpectModelsMatchIncludingFavicon( |
2521 model_one, model_two, false); | 2527 model_one, model_two, false); |
2522 | 2528 |
2523 Cleanup(); | 2529 Cleanup(); |
2524 } | 2530 } |
OLD | NEW |