OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/location.h" | 5 #include "base/location.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Verify that when the sync directory's backing store becomes corrupted, we | 85 // Verify that when the sync directory's backing store becomes corrupted, we |
86 // trigger an unrecoverable error and delete the database. | 86 // trigger an unrecoverable error and delete the database. |
87 // | 87 // |
88 // If this test fails, see the definition of kNumEntriesRequiredForCorruption | 88 // If this test fails, see the definition of kNumEntriesRequiredForCorruption |
89 // for one possible cause. | 89 // for one possible cause. |
90 IN_PROC_BROWSER_TEST_F(SingleClientDirectorySyncTest, | 90 IN_PROC_BROWSER_TEST_F(SingleClientDirectorySyncTest, |
91 DeleteDirectoryWhenCorrupted) { | 91 DeleteDirectoryWhenCorrupted) { |
92 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 92 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
93 // Sync and wait for syncing to complete. | 93 // Sync and wait for syncing to complete. |
94 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 94 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
95 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 95 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
96 ASSERT_TRUE(bookmarks_helper::ModelMatchesVerifier(0)); | 96 ASSERT_TRUE(bookmarks_helper::ModelMatchesVerifier(0)); |
97 | 97 |
98 // Flush the directory to the backing store and wait until the flush | 98 // Flush the directory to the backing store and wait until the flush |
99 // completes. | 99 // completes. |
100 browser_sync::ProfileSyncService* sync_service = GetSyncService(0); | 100 browser_sync::ProfileSyncService* sync_service = GetSyncService(0); |
101 sync_service->FlushDirectory(); | 101 sync_service->FlushDirectory(); |
102 base::MessageLoop* sync_loop = sync_service->GetSyncLoopForTest(); | 102 base::MessageLoop* sync_loop = sync_service->GetSyncLoopForTest(); |
103 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); | 103 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); |
104 | 104 |
105 // Now corrupt the database. | 105 // Now corrupt the database. |
(...skipping 26 matching lines...) Expand all Loading... |
132 SyncUnrecoverableErrorChecker checker(sync_service); | 132 SyncUnrecoverableErrorChecker checker(sync_service); |
133 checker.Wait(); | 133 checker.Wait(); |
134 ASSERT_TRUE(!checker.TimedOut()); | 134 ASSERT_TRUE(!checker.TimedOut()); |
135 ASSERT_TRUE(sync_service->HasUnrecoverableError()); | 135 ASSERT_TRUE(sync_service->HasUnrecoverableError()); |
136 | 136 |
137 // Wait until the sync loop has processed any existing tasks and see that the | 137 // Wait until the sync loop has processed any existing tasks and see that the |
138 // directory no longer exists. | 138 // directory no longer exists. |
139 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); | 139 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); |
140 ASSERT_FALSE(base::DirectoryExists(directory_path)); | 140 ASSERT_FALSE(base::DirectoryExists(directory_path)); |
141 } | 141 } |
OLD | NEW |