Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/signin/signin_manager.h" | 9 #include "chrome/browser/signin/signin_manager.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 args1, reply_handler.AsWeakHandle()); | 308 args1, reply_handler.AsWeakHandle()); |
| 309 } | 309 } |
| 310 | 310 |
| 311 IssueTestTokens(); | 311 IssueTestTokens(); |
| 312 | 312 |
| 313 // This forces the sync thread to process the message and reply. | 313 // This forces the sync thread to process the message and reply. |
| 314 service_.reset(); | 314 service_.reset(); |
| 315 ui_loop_.RunAllPending(); | 315 ui_loop_.RunAllPending(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 // Make sure that things still work if sync is not enabled, but some old sync | |
| 319 // databases are lingering in the "Sync Data" folder. | |
| 320 TEST_F(ProfileSyncServiceTest, TestStartupWithOldSyncData) { | |
|
rlarocque
2012/08/11 01:31:52
This test is not very useful anymore. I think the
| |
| 321 const char* nonsense1 = "reginald"; | |
| 322 const char* nonsense2 = "beartato"; | |
| 323 const char* nonsense3 = "harrison"; | |
| 324 FilePath temp_directory = profile_->GetPath().AppendASCII("Sync Data"); | |
| 325 FilePath sync_file1 = | |
| 326 temp_directory.AppendASCII("BookmarkSyncSettings.sqlite3"); | |
| 327 FilePath sync_file2 = temp_directory.AppendASCII("SyncData.sqlite3"); | |
| 328 FilePath sync_file3 = temp_directory.AppendASCII("nonsense_file"); | |
| 329 ASSERT_TRUE(file_util::CreateDirectory(temp_directory)); | |
| 330 ASSERT_NE(-1, | |
| 331 file_util::WriteFile(sync_file1, nonsense1, strlen(nonsense1))); | |
| 332 ASSERT_NE(-1, | |
| 333 file_util::WriteFile(sync_file2, nonsense2, strlen(nonsense2))); | |
| 334 ASSERT_NE(-1, | |
| 335 file_util::WriteFile(sync_file3, nonsense3, strlen(nonsense3))); | |
| 336 | |
| 337 StartSyncServiceAndSetInitialSyncEnded(false, false, true, false, | |
| 338 syncer::STORAGE_ON_DISK); | |
| 339 EXPECT_FALSE(service_->HasSyncSetupCompleted()); | |
| 340 EXPECT_FALSE(service_->sync_initialized()); | |
| 341 | |
| 342 // Since we're doing synchronous initialization, backend should be | |
| 343 // initialized by this call. | |
| 344 IssueTestTokens(); | |
| 345 | |
| 346 // Stop the service so we can read the new Sync Data files that were | |
| 347 // created. | |
| 348 service_.reset(); | |
| 349 | |
| 350 // This file should have been deleted when the whole directory was nuked. | |
| 351 ASSERT_FALSE(file_util::PathExists(sync_file3)); | |
| 352 ASSERT_FALSE(file_util::PathExists(sync_file1)); | |
| 353 | |
| 354 // This will still exist, but the text should have changed. | |
| 355 ASSERT_TRUE(file_util::PathExists(sync_file2)); | |
| 356 std::string file2text; | |
| 357 ASSERT_TRUE(file_util::ReadFileToString(sync_file2, &file2text)); | |
| 358 ASSERT_NE(file2text.compare(nonsense2), 0); | |
| 359 } | |
| 360 | |
| 361 // Simulates a scenario where a database is corrupted and it is impossible to | 318 // Simulates a scenario where a database is corrupted and it is impossible to |
| 362 // recreate it. This test is useful mainly when it is run under valgrind. Its | 319 // recreate it. This test is useful mainly when it is run under valgrind. Its |
| 363 // expectations are not very interesting. | 320 // expectations are not very interesting. |
| 364 TEST_F(ProfileSyncServiceTest, FailToOpenDatabase) { | 321 TEST_F(ProfileSyncServiceTest, FailToOpenDatabase) { |
| 365 StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, | 322 StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, |
| 366 syncer::STORAGE_INVALID); | 323 syncer::STORAGE_INVALID); |
| 367 | 324 |
| 368 // The backend is not ready. Ensure the PSS knows this. | 325 // The backend is not ready. Ensure the PSS knows this. |
| 369 EXPECT_FALSE(service_->sync_initialized()); | 326 EXPECT_FALSE(service_->sync_initialized()); |
| 370 } | 327 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 SyncBackendHostForProfileSyncTest* const backend = | 394 SyncBackendHostForProfileSyncTest* const backend = |
| 438 service_->GetBackendForTest(); | 395 service_->GetBackendForTest(); |
| 439 | 396 |
| 440 backend->EmitOnNotificationsEnabled(); | 397 backend->EmitOnNotificationsEnabled(); |
| 441 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); | 398 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); |
| 442 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); | 399 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); |
| 443 } | 400 } |
| 444 | 401 |
| 445 } // namespace | 402 } // namespace |
| 446 } // namespace browser_sync | 403 } // namespace browser_sync |
| OLD | NEW |