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