Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/browser/sync/test/integration/single_client_directory_sync_test.cc

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 13 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
14 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h" 14 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h"
15 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
16 #include "chrome/browser/sync/test/integration/sync_test.h" 15 #include "chrome/browser/sync/test/integration/sync_test.h"
16 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h "
17 #include "components/browser_sync/profile_sync_service.h" 17 #include "components/browser_sync/profile_sync_service.h"
18 #include "components/sync/syncable/directory.h" 18 #include "components/sync/syncable/directory.h"
19 #include "components/sync/test/directory_backing_store_corruption_testing.h" 19 #include "components/sync/test/directory_backing_store_corruption_testing.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "url/gurl.h" 21 #include "url/gurl.h"
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 using sync_integration_test_util::AwaitCommitActivityCompletion;
25 using syncer::syncable::corruption_testing::kNumEntriesRequiredForCorruption; 24 using syncer::syncable::corruption_testing::kNumEntriesRequiredForCorruption;
26 using syncer::syncable::corruption_testing::CorruptDatabase; 25 using syncer::syncable::corruption_testing::CorruptDatabase;
27 26
28 class SingleClientDirectorySyncTest : public SyncTest { 27 class SingleClientDirectorySyncTest : public SyncTest {
29 public: 28 public:
30 SingleClientDirectorySyncTest() : SyncTest(SINGLE_CLIENT) {} 29 SingleClientDirectorySyncTest() : SyncTest(SINGLE_CLIENT) {}
31 ~SingleClientDirectorySyncTest() override {} 30 ~SingleClientDirectorySyncTest() override {}
32 31
33 private: 32 private:
34 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest); 33 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // Verify that when the sync directory's backing store becomes corrupted, we 84 // Verify that when the sync directory's backing store becomes corrupted, we
86 // trigger an unrecoverable error and delete the database. 85 // trigger an unrecoverable error and delete the database.
87 // 86 //
88 // If this test fails, see the definition of kNumEntriesRequiredForCorruption 87 // If this test fails, see the definition of kNumEntriesRequiredForCorruption
89 // for one possible cause. 88 // for one possible cause.
90 IN_PROC_BROWSER_TEST_F(SingleClientDirectorySyncTest, 89 IN_PROC_BROWSER_TEST_F(SingleClientDirectorySyncTest,
91 DeleteDirectoryWhenCorrupted) { 90 DeleteDirectoryWhenCorrupted) {
92 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 91 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
93 // Sync and wait for syncing to complete. 92 // Sync and wait for syncing to complete.
94 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 93 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
95 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); 94 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
96 ASSERT_TRUE(bookmarks_helper::ModelMatchesVerifier(0)); 95 ASSERT_TRUE(bookmarks_helper::ModelMatchesVerifier(0));
97 96
98 // Flush the directory to the backing store and wait until the flush 97 // Flush the directory to the backing store and wait until the flush
99 // completes. 98 // completes.
100 browser_sync::ProfileSyncService* sync_service = GetSyncService(0); 99 browser_sync::ProfileSyncService* sync_service = GetSyncService(0);
101 sync_service->FlushDirectory(); 100 sync_service->FlushDirectory();
102 base::MessageLoop* sync_loop = sync_service->GetSyncLoopForTest(); 101 base::MessageLoop* sync_loop = sync_service->GetSyncLoopForTest();
103 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); 102 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop));
104 103
105 // Now corrupt the database. 104 // Now corrupt the database.
(...skipping 16 matching lines...) Expand all
122 "oooooooooooooooooooogle.com"); 121 "oooooooooooooooooooogle.com");
123 const bookmarks::BookmarkNode* top = bookmarks_helper::AddFolder( 122 const bookmarks::BookmarkNode* top = bookmarks_helper::AddFolder(
124 0, bookmarks_helper::GetOtherNode(0), 0, "top"); 123 0, bookmarks_helper::GetOtherNode(0), 0, "top");
125 for (int i = 0; i < kNumEntriesRequiredForCorruption; ++i) { 124 for (int i = 0; i < kNumEntriesRequiredForCorruption; ++i) {
126 ASSERT_TRUE( 125 ASSERT_TRUE(
127 bookmarks_helper::AddURL(0, top, 0, base::Int64ToString(i), url)); 126 bookmarks_helper::AddURL(0, top, 0, base::Int64ToString(i), url));
128 } 127 }
129 sync_service->FlushDirectory(); 128 sync_service->FlushDirectory();
130 129
131 // Wait for an unrecoverable error to occur. 130 // Wait for an unrecoverable error to occur.
132 SyncUnrecoverableErrorChecker checker(sync_service); 131 ASSERT_TRUE(SyncUnrecoverableErrorChecker(sync_service).Wait());
133 checker.Wait();
134 ASSERT_TRUE(!checker.TimedOut());
135 ASSERT_TRUE(sync_service->HasUnrecoverableError()); 132 ASSERT_TRUE(sync_service->HasUnrecoverableError());
136 133
137 // Wait until the sync loop has processed any existing tasks and see that the 134 // Wait until the sync loop has processed any existing tasks and see that the
138 // directory no longer exists. 135 // directory no longer exists.
139 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); 136 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop));
140 ASSERT_FALSE(base::DirectoryExists(directory_path)); 137 ASSERT_FALSE(base::DirectoryExists(directory_path));
141 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698