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 "device/serial/serial_connection.h" | 5 #include "device/serial/serial_connection.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 stop_run_loop_ = run_loop.QuitClosure(); | 138 stop_run_loop_ = run_loop.QuitClosure(); |
139 run_loop.Run(); | 139 run_loop.Run(); |
140 } | 140 } |
141 | 141 |
142 void EventReceived(Event event) { | 142 void EventReceived(Event event) { |
143 if (event != expected_event_) | 143 if (event != expected_event_) |
144 return; | 144 return; |
145 expected_event_ = EVENT_NONE; | 145 expected_event_ = EVENT_NONE; |
146 ASSERT_TRUE(message_loop_); | 146 ASSERT_TRUE(message_loop_); |
147 ASSERT_TRUE(!stop_run_loop_.is_null()); | 147 ASSERT_TRUE(!stop_run_loop_.is_null()); |
148 message_loop_->PostTask(FROM_HERE, stop_run_loop_); | 148 message_loop_->task_runner()->PostTask(FROM_HERE, stop_run_loop_); |
149 } | 149 } |
150 | 150 |
151 scoped_refptr<SerialIoHandler> CreateIoHandler() { | 151 scoped_refptr<SerialIoHandler> CreateIoHandler() { |
152 io_handler_ = new TestSerialIoHandler; | 152 io_handler_ = new TestSerialIoHandler; |
153 return io_handler_; | 153 return io_handler_; |
154 } | 154 } |
155 | 155 |
156 void OnDataSent(uint32_t bytes_sent) { | 156 void OnDataSent(uint32_t bytes_sent) { |
157 bytes_sent_ += bytes_sent; | 157 bytes_sent_ += bytes_sent; |
158 send_error_ = serial::SendError::NONE; | 158 send_error_ = serial::SendError::NONE; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 WaitForEvent(EVENT_DATA_SENT); | 332 WaitForEvent(EVENT_DATA_SENT); |
333 EXPECT_EQ(serial::SendError::NONE, send_error_); | 333 EXPECT_EQ(serial::SendError::NONE, send_error_); |
334 EXPECT_EQ(4, bytes_sent_); | 334 EXPECT_EQ(4, bytes_sent_); |
335 ASSERT_NO_FATAL_FAILURE(Receive()); | 335 ASSERT_NO_FATAL_FAILURE(Receive()); |
336 WaitForEvent(EVENT_DATA_RECEIVED); | 336 WaitForEvent(EVENT_DATA_RECEIVED); |
337 EXPECT_EQ("data", data_received_); | 337 EXPECT_EQ("data", data_received_); |
338 EXPECT_EQ(serial::ReceiveError::NONE, receive_error_); | 338 EXPECT_EQ(serial::ReceiveError::NONE, receive_error_); |
339 } | 339 } |
340 | 340 |
341 } // namespace device | 341 } // namespace device |
OLD | NEW |