| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 harness_.service->Shutdown(); | 449 harness_.service->Shutdown(); |
| 450 harness_.service.reset(); | 450 harness_.service.reset(); |
| 451 | 451 |
| 452 // This file should have been deleted when the whole directory was nuked. | 452 // This file should have been deleted when the whole directory was nuked. |
| 453 ASSERT_FALSE(base::PathExists(sync_file3)); | 453 ASSERT_FALSE(base::PathExists(sync_file3)); |
| 454 ASSERT_FALSE(base::PathExists(sync_file1)); | 454 ASSERT_FALSE(base::PathExists(sync_file1)); |
| 455 | 455 |
| 456 // This will still exist, but the text should have changed. | 456 // This will still exist, but the text should have changed. |
| 457 ASSERT_TRUE(base::PathExists(sync_file2)); | 457 ASSERT_TRUE(base::PathExists(sync_file2)); |
| 458 std::string file2text; | 458 std::string file2text; |
| 459 ASSERT_TRUE(file_util::ReadFileToString(sync_file2, &file2text)); | 459 ASSERT_TRUE(base::ReadFileToString(sync_file2, &file2text)); |
| 460 ASSERT_NE(file2text.compare(nonsense2), 0); | 460 ASSERT_NE(file2text.compare(nonsense2), 0); |
| 461 } | 461 } |
| 462 | 462 |
| 463 // Simulates a scenario where a database is corrupted and it is impossible to | 463 // Simulates a scenario where a database is corrupted and it is impossible to |
| 464 // recreate it. This test is useful mainly when it is run under valgrind. Its | 464 // recreate it. This test is useful mainly when it is run under valgrind. Its |
| 465 // expectations are not very interesting. | 465 // expectations are not very interesting. |
| 466 TEST_F(ProfileSyncServiceTest, FailToOpenDatabase) { | 466 TEST_F(ProfileSyncServiceTest, FailToOpenDatabase) { |
| 467 harness_.StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, | 467 harness_.StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, |
| 468 syncer::STORAGE_INVALID); | 468 syncer::STORAGE_INVALID); |
| 469 | 469 |
| 470 // The backend is not ready. Ensure the PSS knows this. | 470 // The backend is not ready. Ensure the PSS knows this. |
| 471 EXPECT_FALSE(harness_.service->sync_initialized()); | 471 EXPECT_FALSE(harness_.service->sync_initialized()); |
| 472 } | 472 } |
| 473 | 473 |
| 474 // This setup will allow the database to exist, but leave it empty. The attempt | 474 // This setup will allow the database to exist, but leave it empty. The attempt |
| 475 // to download control types will silently fail (no downloads have any effect in | 475 // to download control types will silently fail (no downloads have any effect in |
| 476 // these tests). The sync_backend_host will notice this and inform the profile | 476 // these tests). The sync_backend_host will notice this and inform the profile |
| 477 // sync service of the failure to initialize the backed. | 477 // sync service of the failure to initialize the backed. |
| 478 TEST_F(ProfileSyncServiceTest, FailToDownloadControlTypes) { | 478 TEST_F(ProfileSyncServiceTest, FailToDownloadControlTypes) { |
| 479 harness_.StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, | 479 harness_.StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, |
| 480 syncer::STORAGE_IN_MEMORY); | 480 syncer::STORAGE_IN_MEMORY); |
| 481 | 481 |
| 482 // The backend is not ready. Ensure the PSS knows this. | 482 // The backend is not ready. Ensure the PSS knows this. |
| 483 EXPECT_FALSE(harness_.service->sync_initialized()); | 483 EXPECT_FALSE(harness_.service->sync_initialized()); |
| 484 } | 484 } |
| 485 | 485 |
| 486 } // namespace | 486 } // namespace |
| 487 } // namespace browser_sync | 487 } // namespace browser_sync |
| OLD | NEW |