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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_) | 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(); |
61 run_loop.Run(); | 61 run_loop.Run(); |
62 } | 62 } |
63 | 63 |
(...skipping 340 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 |