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/async_waiter.h" | 9 #include "device/serial/async_waiter.h" |
10 #include "device/serial/data_sender.h" | 10 #include "device/serial/data_sender.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 }; | 28 }; |
29 | 29 |
30 DataSinkTest() | 30 DataSinkTest() |
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 virtual void SetUp() OVERRIDE { | 38 virtual 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_ = mojo::WeakBindToProxy( |
42 new DataSinkReceiver( | 42 new DataSinkReceiver( |
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); | 46 &sink_handle); |
47 sender_.reset(new DataSender(sink_handle.Pass(), kBufferSize, kFatalError)); | 47 sender_.reset(new DataSender(sink_handle.Pass(), kBufferSize, kFatalError)); |
48 } | 48 } |
49 | 49 |
50 virtual void TearDown() OVERRIDE { | 50 virtual void TearDown() override { |
51 read_buffer_.reset(); | 51 read_buffer_.reset(); |
52 message_loop_.reset(); | 52 message_loop_.reset(); |
53 if (sink_receiver_.get()) | 53 if (sink_receiver_.get()) |
54 EXPECT_TRUE(sink_receiver_->HasOneRef()); | 54 EXPECT_TRUE(sink_receiver_->HasOneRef()); |
55 } | 55 } |
56 | 56 |
57 void WaitForEvent(Event event) { | 57 void WaitForEvent(Event event) { |
58 expected_event_ = event; | 58 expected_event_ = event; |
59 base::RunLoop run_loop; | 59 base::RunLoop run_loop; |
60 stop_run_loop_ = run_loop.QuitClosure(); | 60 stop_run_loop_ = run_loop.QuitClosure(); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 sender_.reset(); | 404 sender_.reset(); |
405 ExpectSendError(0, kFatalError); | 405 ExpectSendError(0, kFatalError); |
406 ExpectSendError(0, kFatalError); | 406 ExpectSendError(0, kFatalError); |
407 ExpectCancelResult(); | 407 ExpectCancelResult(); |
408 if (!seen_connection_error_) | 408 if (!seen_connection_error_) |
409 WaitForEvent(EVENT_ERROR); | 409 WaitForEvent(EVENT_ERROR); |
410 EXPECT_TRUE(seen_connection_error_); | 410 EXPECT_TRUE(seen_connection_error_); |
411 } | 411 } |
412 | 412 |
413 } // namespace device | 413 } // namespace device |
OLD | NEW |