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/data_sender.h" | 9 #include "device/serial/data_sender.h" |
10 #include "device/serial/data_sink_receiver.h" | 10 #include "device/serial/data_sink_receiver.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 : bytes_sent_(0), | 31 : bytes_sent_(0), |
32 send_error_(0), | 32 send_error_(0), |
33 has_send_error_(false), | 33 has_send_error_(false), |
34 cancel_error_(0), | 34 cancel_error_(0), |
35 seen_connection_error_(false), | 35 seen_connection_error_(false), |
36 expected_event_(EVENT_NONE) {} | 36 expected_event_(EVENT_NONE) {} |
37 | 37 |
38 void SetUp() override { | 38 void SetUp() override { |
39 message_loop_.reset(new base::MessageLoop); | 39 message_loop_.reset(new base::MessageLoop); |
40 mojo::InterfacePtr<serial::DataSink> sink_handle; | 40 mojo::InterfacePtr<serial::DataSink> sink_handle; |
41 sink_receiver_ = mojo::WeakBindToProxy( | 41 sink_receiver_ = new DataSinkReceiver( |
42 new DataSinkReceiver( | 42 mojo::GetProxy(&sink_handle), |
43 base::Bind(&DataSinkTest::OnDataToRead, base::Unretained(this)), | 43 base::Bind(&DataSinkTest::OnDataToRead, base::Unretained(this)), |
44 base::Bind(&DataSinkTest::OnCancel, base::Unretained(this)), | 44 base::Bind(&DataSinkTest::OnCancel, base::Unretained(this)), |
45 base::Bind(&DataSinkTest::OnError, base::Unretained(this))), | 45 base::Bind(&DataSinkTest::OnError, base::Unretained(this))); |
46 &sink_handle); | |
47 sender_.reset(new DataSender(sink_handle.Pass(), kBufferSize, kFatalError)); | 46 sender_.reset(new DataSender(sink_handle.Pass(), kBufferSize, kFatalError)); |
48 } | 47 } |
49 | 48 |
50 void TearDown() override { | 49 void TearDown() override { |
51 read_buffer_.reset(); | 50 read_buffer_.reset(); |
52 message_loop_.reset(); | 51 message_loop_.reset(); |
53 if (sink_receiver_.get()) | 52 if (sink_receiver_.get()) |
54 EXPECT_TRUE(sink_receiver_->HasOneRef()); | 53 EXPECT_TRUE(sink_receiver_->HasOneRef()); |
55 } | 54 } |
56 | 55 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 sender_.reset(); | 403 sender_.reset(); |
405 ExpectSendError(0, kFatalError); | 404 ExpectSendError(0, kFatalError); |
406 ExpectSendError(0, kFatalError); | 405 ExpectSendError(0, kFatalError); |
407 ExpectCancelResult(); | 406 ExpectCancelResult(); |
408 if (!seen_connection_error_) | 407 if (!seen_connection_error_) |
409 WaitForEvent(EVENT_ERROR); | 408 WaitForEvent(EVENT_ERROR); |
410 EXPECT_TRUE(seen_connection_error_); | 409 EXPECT_TRUE(seen_connection_error_); |
411 } | 410 } |
412 | 411 |
413 } // namespace device | 412 } // namespace device |
OLD | NEW |