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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 private: | 33 private: |
34 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest); | 34 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest); |
35 }; | 35 }; |
36 | 36 |
37 void SignalEvent(base::WaitableEvent* e) { | 37 void SignalEvent(base::WaitableEvent* e) { |
38 e->Signal(); | 38 e->Signal(); |
39 } | 39 } |
40 | 40 |
41 bool WaitForExistingTasksOnLoop(base::MessageLoop* loop) { | 41 bool WaitForExistingTasksOnLoop(base::MessageLoop* loop) { |
42 base::WaitableEvent e(true, false); | 42 base::WaitableEvent e(base::WaitableEvent::ResetPolicy::MANUAL, |
| 43 base::WaitableEvent::InitialState::NOT_SIGNALED); |
43 loop->task_runner()->PostTask(FROM_HERE, base::Bind(&SignalEvent, &e)); | 44 loop->task_runner()->PostTask(FROM_HERE, base::Bind(&SignalEvent, &e)); |
44 // Timeout stolen from StatusChangeChecker::GetTimeoutDuration(). | 45 // Timeout stolen from StatusChangeChecker::GetTimeoutDuration(). |
45 return e.TimedWait(base::TimeDelta::FromSeconds(45)); | 46 return e.TimedWait(base::TimeDelta::FromSeconds(45)); |
46 } | 47 } |
47 | 48 |
48 // A status change checker that waits for an unrecoverable sync error to occur. | 49 // A status change checker that waits for an unrecoverable sync error to occur. |
49 class SyncUnrecoverableErrorChecker : public SingleClientStatusChangeChecker { | 50 class SyncUnrecoverableErrorChecker : public SingleClientStatusChangeChecker { |
50 public: | 51 public: |
51 explicit SyncUnrecoverableErrorChecker(ProfileSyncService* service) | 52 explicit SyncUnrecoverableErrorChecker(ProfileSyncService* service) |
52 : SingleClientStatusChangeChecker(service) {} | 53 : SingleClientStatusChangeChecker(service) {} |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 SyncUnrecoverableErrorChecker checker(sync_service); | 131 SyncUnrecoverableErrorChecker checker(sync_service); |
131 checker.Wait(); | 132 checker.Wait(); |
132 ASSERT_TRUE(!checker.TimedOut()); | 133 ASSERT_TRUE(!checker.TimedOut()); |
133 ASSERT_TRUE(sync_service->HasUnrecoverableError()); | 134 ASSERT_TRUE(sync_service->HasUnrecoverableError()); |
134 | 135 |
135 // Wait until the sync loop has processed any existing tasks and see that the | 136 // Wait until the sync loop has processed any existing tasks and see that the |
136 // directory no longer exists. | 137 // directory no longer exists. |
137 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); | 138 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); |
138 ASSERT_FALSE(base::DirectoryExists(directory_path)); | 139 ASSERT_FALSE(base::DirectoryExists(directory_path)); |
139 } | 140 } |
OLD | NEW |