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/buffer.h" | 10 #include "device/serial/buffer.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 enum Event { | 21 enum Event { |
22 EVENT_NONE, | 22 EVENT_NONE, |
23 EVENT_WRITE_BUFFER_READY, | 23 EVENT_WRITE_BUFFER_READY, |
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 virtual void SetUp() OVERRIDE { | 31 virtual 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 source_sender_ = mojo::WeakBindToProxy( |
35 new DataSourceSender( | 35 new DataSourceSender( |
36 base::Bind(&DataSourceTest::CanWriteData, base::Unretained(this)), | 36 base::Bind(&DataSourceTest::CanWriteData, base::Unretained(this)), |
37 base::Bind(&DataSourceTest::OnError, base::Unretained(this))), | 37 base::Bind(&DataSourceTest::OnError, base::Unretained(this))), |
38 &source_sender_handle); | 38 &source_sender_handle); |
39 receiver_ = new DataReceiver(source_sender_handle.Pass(), 100, kFatalError); | 39 receiver_ = new DataReceiver(source_sender_handle.Pass(), 100, kFatalError); |
40 } | 40 } |
41 | 41 |
42 virtual void TearDown() OVERRIDE { | 42 virtual void TearDown() override { |
43 write_buffer_.reset(); | 43 write_buffer_.reset(); |
44 buffer_.reset(); | 44 buffer_.reset(); |
45 message_loop_.reset(); | 45 message_loop_.reset(); |
46 } | 46 } |
47 | 47 |
48 void OnError() { | 48 void OnError() { |
49 seen_connection_error_ = true; | 49 seen_connection_error_ = true; |
50 EventReceived(EVENT_ERROR); | 50 EventReceived(EVENT_ERROR); |
51 } | 51 } |
52 | 52 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // Test that the receiver shutting down is correctly reported to the source. | 243 // Test that the receiver shutting down is correctly reported to the source. |
244 TEST_F(DataSourceTest, ReceiverShutdown) { | 244 TEST_F(DataSourceTest, ReceiverShutdown) { |
245 Receive(); | 245 Receive(); |
246 receiver_ = NULL; | 246 receiver_ = NULL; |
247 EXPECT_EQ(kFatalError, error_); | 247 EXPECT_EQ(kFatalError, error_); |
248 WaitForEvent(EVENT_ERROR); | 248 WaitForEvent(EVENT_ERROR); |
249 EXPECT_TRUE(seen_connection_error_); | 249 EXPECT_TRUE(seen_connection_error_); |
250 } | 250 } |
251 | 251 |
252 } // namespace device | 252 } // namespace device |
OLD | NEW |