OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "sync/internal_api/public/base/cancelation_signal.h" | 5 #include "sync/internal_api/public/base/cancelation_signal.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 event_.Signal(); | 86 event_.Signal(); |
87 } | 87 } |
88 | 88 |
89 bool BlockingTask::WasStarted() { | 89 bool BlockingTask::WasStarted() { |
90 return was_started_; | 90 return was_started_; |
91 } | 91 } |
92 | 92 |
93 class CancelationSignalTest : public ::testing::Test { | 93 class CancelationSignalTest : public ::testing::Test { |
94 public: | 94 public: |
95 CancelationSignalTest(); | 95 CancelationSignalTest(); |
96 virtual ~CancelationSignalTest(); | 96 ~CancelationSignalTest() override; |
97 | 97 |
98 // Starts the blocking task on a background thread. Does not wait for the | 98 // Starts the blocking task on a background thread. Does not wait for the |
99 // task to start. | 99 // task to start. |
100 void StartBlockingTaskAsync(); | 100 void StartBlockingTaskAsync(); |
101 | 101 |
102 // Starts the blocking task on a background thread. Does not return until | 102 // Starts the blocking task on a background thread. Does not return until |
103 // the task has been started. | 103 // the task has been started. |
104 void StartBlockingTaskAndWaitForItToStart(); | 104 void StartBlockingTaskAndWaitForItToStart(); |
105 | 105 |
106 // Cancels the blocking task. | 106 // Cancels the blocking task. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // progress. | 177 // progress. |
178 TEST_F(CancelationSignalTest, Cancel) { | 178 TEST_F(CancelationSignalTest, Cancel) { |
179 StartBlockingTaskAndWaitForItToStart(); | 179 StartBlockingTaskAndWaitForItToStart(); |
180 | 180 |
181 // Wait for the task to finish and let verify it has been started. | 181 // Wait for the task to finish and let verify it has been started. |
182 CancelBlocking(); | 182 CancelBlocking(); |
183 EXPECT_FALSE(VerifyTaskNotStarted()); | 183 EXPECT_FALSE(VerifyTaskNotStarted()); |
184 } | 184 } |
185 | 185 |
186 } // namespace syncer | 186 } // namespace syncer |
OLD | NEW |