OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 scoped_refptr<base::SingleThreadTaskRunner> sender_runner_; | 180 scoped_refptr<base::SingleThreadTaskRunner> sender_runner_; |
181 base::Closure get_sender_notification_; | 181 base::Closure get_sender_notification_; |
182 }; | 182 }; |
183 | 183 |
184 class BindTaskRunnerTest : public testing::Test { | 184 class BindTaskRunnerTest : public testing::Test { |
185 protected: | 185 protected: |
186 void SetUp() override { | 186 void SetUp() override { |
187 binding_task_runner_ = scoped_refptr<TestTaskRunner>(new TestTaskRunner); | 187 binding_task_runner_ = scoped_refptr<TestTaskRunner>(new TestTaskRunner); |
188 ptr_task_runner_ = scoped_refptr<TestTaskRunner>(new TestTaskRunner); | 188 ptr_task_runner_ = scoped_refptr<TestTaskRunner>(new TestTaskRunner); |
189 | 189 |
190 auto request = GetProxy(&ptr_, ptr_task_runner_); | 190 auto request = MakeRequest(&ptr_, ptr_task_runner_); |
191 impl_.reset(new ImplType(std::move(request), binding_task_runner_)); | 191 impl_.reset(new ImplType(std::move(request), binding_task_runner_)); |
192 } | 192 } |
193 | 193 |
194 base::MessageLoop loop_; | 194 base::MessageLoop loop_; |
195 scoped_refptr<TestTaskRunner> binding_task_runner_; | 195 scoped_refptr<TestTaskRunner> binding_task_runner_; |
196 scoped_refptr<TestTaskRunner> ptr_task_runner_; | 196 scoped_refptr<TestTaskRunner> ptr_task_runner_; |
197 | 197 |
198 IntegerSenderPtr ptr_; | 198 IntegerSenderPtr ptr_; |
199 using ImplType = | 199 using ImplType = |
200 IntegerSenderImpl<Binding<IntegerSender>, IntegerSenderRequest>; | 200 IntegerSenderImpl<Binding<IntegerSender>, IntegerSenderRequest>; |
201 std::unique_ptr<ImplType> impl_; | 201 std::unique_ptr<ImplType> impl_; |
202 }; | 202 }; |
203 | 203 |
204 class AssociatedBindTaskRunnerTest : public testing::Test { | 204 class AssociatedBindTaskRunnerTest : public testing::Test { |
205 protected: | 205 protected: |
206 void SetUp() override { | 206 void SetUp() override { |
207 connection_binding_task_runner_ = | 207 connection_binding_task_runner_ = |
208 scoped_refptr<TestTaskRunner>(new TestTaskRunner); | 208 scoped_refptr<TestTaskRunner>(new TestTaskRunner); |
209 connection_ptr_task_runner_ = | 209 connection_ptr_task_runner_ = |
210 scoped_refptr<TestTaskRunner>(new TestTaskRunner); | 210 scoped_refptr<TestTaskRunner>(new TestTaskRunner); |
211 sender_binding_task_runner_ = | 211 sender_binding_task_runner_ = |
212 scoped_refptr<TestTaskRunner>(new TestTaskRunner); | 212 scoped_refptr<TestTaskRunner>(new TestTaskRunner); |
213 sender_ptr_task_runner_ = scoped_refptr<TestTaskRunner>(new TestTaskRunner); | 213 sender_ptr_task_runner_ = scoped_refptr<TestTaskRunner>(new TestTaskRunner); |
214 | 214 |
215 auto connection_request = | 215 auto connection_request = |
216 GetProxy(&connection_ptr_, connection_ptr_task_runner_); | 216 MakeRequest(&connection_ptr_, connection_ptr_task_runner_); |
217 connection_impl_.reset(new IntegerSenderConnectionImpl( | 217 connection_impl_.reset(new IntegerSenderConnectionImpl( |
218 std::move(connection_request), connection_binding_task_runner_, | 218 std::move(connection_request), connection_binding_task_runner_, |
219 sender_binding_task_runner_)); | 219 sender_binding_task_runner_)); |
220 | 220 |
221 connection_impl_->set_get_sender_notification( | 221 connection_impl_->set_get_sender_notification( |
222 base::Bind(&AssociatedBindTaskRunnerTest::QuitTaskRunner, | 222 base::Bind(&AssociatedBindTaskRunnerTest::QuitTaskRunner, |
223 base::Unretained(this))); | 223 base::Unretained(this))); |
224 | 224 |
225 connection_ptr_->GetSender(GetProxy(&sender_ptr_, | 225 connection_ptr_->GetSender(MakeRequest(&sender_ptr_, |
226 connection_ptr_.associated_group(), | 226 connection_ptr_.associated_group(), |
227 sender_ptr_task_runner_)); | 227 sender_ptr_task_runner_)); |
228 connection_binding_task_runner_->Run(); | 228 connection_binding_task_runner_->Run(); |
229 } | 229 } |
230 | 230 |
231 void QuitTaskRunner() { | 231 void QuitTaskRunner() { |
232 connection_binding_task_runner_->Quit(); | 232 connection_binding_task_runner_->Quit(); |
233 } | 233 } |
234 | 234 |
235 base::MessageLoop loop_; | 235 base::MessageLoop loop_; |
236 scoped_refptr<TestTaskRunner> connection_binding_task_runner_; | 236 scoped_refptr<TestTaskRunner> connection_binding_task_runner_; |
237 scoped_refptr<TestTaskRunner> connection_ptr_task_runner_; | 237 scoped_refptr<TestTaskRunner> connection_ptr_task_runner_; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 EXPECT_TRUE(sender_impl_error); | 386 EXPECT_TRUE(sender_impl_error); |
387 connection_ptr_task_runner_->Run(); | 387 connection_ptr_task_runner_->Run(); |
388 EXPECT_TRUE(connection_ptr_error); | 388 EXPECT_TRUE(connection_ptr_error); |
389 sender_ptr_task_runner_->Run(); | 389 sender_ptr_task_runner_->Run(); |
390 EXPECT_TRUE(sender_ptr_error); | 390 EXPECT_TRUE(sender_ptr_error); |
391 } | 391 } |
392 | 392 |
393 } // namespace | 393 } // namespace |
394 } // namespace test | 394 } // namespace test |
395 } // namespace mojo | 395 } // namespace mojo |
OLD | NEW |