OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "device/serial/buffer.h" | 9 #include "device/serial/buffer.h" |
10 #include "device/serial/data_receiver.h" | 10 #include "device/serial/data_receiver.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 EVENT_RECEIVE_COMPLETE, | 24 EVENT_RECEIVE_COMPLETE, |
25 EVENT_ERROR, | 25 EVENT_ERROR, |
26 }; | 26 }; |
27 | 27 |
28 DataSourceTest() | 28 DataSourceTest() |
29 : error_(0), seen_connection_error_(false), expected_event_(EVENT_NONE) {} | 29 : error_(0), seen_connection_error_(false), expected_event_(EVENT_NONE) {} |
30 | 30 |
31 void SetUp() override { | 31 void SetUp() override { |
32 message_loop_.reset(new base::MessageLoop); | 32 message_loop_.reset(new base::MessageLoop); |
33 mojo::InterfacePtr<serial::DataSource> source_sender_handle; | 33 mojo::InterfacePtr<serial::DataSource> source_sender_handle; |
34 source_sender_ = mojo::WeakBindToProxy( | 34 mojo::InterfacePtr<serial::DataSourceClient> source_sender_client_handle; |
35 new DataSourceSender( | 35 mojo::InterfaceRequest<serial::DataSourceClient> |
36 base::Bind(&DataSourceTest::CanWriteData, base::Unretained(this)), | 36 source_sender_client_request = |
37 base::Bind(&DataSourceTest::OnError, base::Unretained(this))), | 37 mojo::GetProxy(&source_sender_client_handle); |
38 &source_sender_handle); | 38 source_sender_ = new DataSourceSender( |
39 receiver_ = new DataReceiver(source_sender_handle.Pass(), 100, kFatalError); | 39 mojo::GetProxy(&source_sender_handle), |
| 40 source_sender_client_handle.Pass(), |
| 41 base::Bind(&DataSourceTest::CanWriteData, base::Unretained(this)), |
| 42 base::Bind(&DataSourceTest::OnError, base::Unretained(this))); |
| 43 receiver_ = |
| 44 new DataReceiver(source_sender_handle.Pass(), |
| 45 source_sender_client_request.Pass(), 100, kFatalError); |
40 } | 46 } |
41 | 47 |
42 void TearDown() override { | 48 void TearDown() override { |
43 write_buffer_.reset(); | 49 write_buffer_.reset(); |
44 buffer_.reset(); | 50 buffer_.reset(); |
45 message_loop_.reset(); | 51 message_loop_.reset(); |
46 } | 52 } |
47 | 53 |
48 void OnError() { | 54 void OnError() { |
49 seen_connection_error_ = true; | 55 seen_connection_error_ = true; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // Test that the receiver shutting down is correctly reported to the source. | 249 // Test that the receiver shutting down is correctly reported to the source. |
244 TEST_F(DataSourceTest, ReceiverShutdown) { | 250 TEST_F(DataSourceTest, ReceiverShutdown) { |
245 Receive(); | 251 Receive(); |
246 receiver_ = NULL; | 252 receiver_ = NULL; |
247 EXPECT_EQ(kFatalError, error_); | 253 EXPECT_EQ(kFatalError, error_); |
248 WaitForEvent(EVENT_ERROR); | 254 WaitForEvent(EVENT_ERROR); |
249 EXPECT_TRUE(seen_connection_error_); | 255 EXPECT_TRUE(seen_connection_error_); |
250 } | 256 } |
251 | 257 |
252 } // namespace device | 258 } // namespace device |
OLD | NEW |