OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/dns/serial_worker.h" | 5 #include "net/dns/serial_worker.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/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 std::string breakpoint_; | 134 std::string breakpoint_; |
135 }; | 135 }; |
136 | 136 |
137 TEST_F(SerialWorkerTest, ExecuteAndSerializeReads) { | 137 TEST_F(SerialWorkerTest, ExecuteAndSerializeReads) { |
138 for (int i = 0; i < 3; ++i) { | 138 for (int i = 0; i < 3; ++i) { |
139 ++input_value_; | 139 ++input_value_; |
140 worker_->WorkNow(); | 140 worker_->WorkNow(); |
141 WaitForWork(); | 141 WaitForWork(); |
142 RunUntilBreak("OnWorkFinished"); | 142 RunUntilBreak("OnWorkFinished"); |
143 | 143 |
144 message_loop_->AssertIdle(); | 144 EXPECT_TRUE(message_loop_->IsIdleForTesting()); |
145 } | 145 } |
146 | 146 |
147 // Schedule two calls. OnWork checks if it is called serially. | 147 // Schedule two calls. OnWork checks if it is called serially. |
148 ++input_value_; | 148 ++input_value_; |
149 worker_->WorkNow(); | 149 worker_->WorkNow(); |
150 // read is blocked, so this will have to induce re-work | 150 // read is blocked, so this will have to induce re-work |
151 worker_->WorkNow(); | 151 worker_->WorkNow(); |
152 WaitForWork(); | 152 WaitForWork(); |
153 WaitForWork(); | 153 WaitForWork(); |
154 RunUntilBreak("OnWorkFinished"); | 154 RunUntilBreak("OnWorkFinished"); |
155 | 155 |
156 // No more tasks should remain. | 156 // No more tasks should remain. |
157 message_loop_->AssertIdle(); | 157 EXPECT_TRUE(message_loop_->IsIdleForTesting()); |
158 } | 158 } |
159 | 159 |
160 } // namespace | 160 } // namespace |
161 | 161 |
162 } // namespace net | 162 } // namespace net |
163 | 163 |
OLD | NEW |