Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: device/serial/serial_connection_unittest.cc

Issue 646063003: Change data pipe wrappers used by SerialConnection to use message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 TEST_F(SerialConnectionTest, Flush) { 262 TEST_F(SerialConnectionTest, Flush) {
263 ASSERT_EQ(0, io_handler_->flushes()); 263 ASSERT_EQ(0, io_handler_->flushes());
264 connection_->Flush(base::Bind(&SerialConnectionTest::StoreSuccess, 264 connection_->Flush(base::Bind(&SerialConnectionTest::StoreSuccess,
265 base::Unretained(this), 265 base::Unretained(this),
266 EVENT_FLUSHED)); 266 EVENT_FLUSHED));
267 WaitForEvent(EVENT_FLUSHED); 267 WaitForEvent(EVENT_FLUSHED);
268 ASSERT_TRUE(success_); 268 ASSERT_TRUE(success_);
269 EXPECT_EQ(1, io_handler_->flushes()); 269 EXPECT_EQ(1, io_handler_->flushes());
270 } 270 }
271 271
272 TEST_F(SerialConnectionTest, Disconnect) { 272 TEST_F(SerialConnectionTest, DisconnectWithSend) {
273 connection_.reset(); 273 connection_.reset();
274 io_handler_->set_send_callback(base::Bind(base::DoNothing)); 274 io_handler_->set_send_callback(base::Bind(base::DoNothing));
275 ASSERT_NO_FATAL_FAILURE(Send("data")); 275 ASSERT_NO_FATAL_FAILURE(Send("data"));
276 WaitForEvent(EVENT_SEND_ERROR); 276 WaitForEvent(EVENT_SEND_ERROR);
277 EXPECT_EQ(serial::SEND_ERROR_DISCONNECTED, send_error_); 277 EXPECT_EQ(serial::SEND_ERROR_DISCONNECTED, send_error_);
278 EXPECT_EQ(0, bytes_sent_); 278 EXPECT_EQ(0, bytes_sent_);
279 EXPECT_TRUE(io_handler_->HasOneRef());
raymes 2014/10/17 02:11:10 Hmm, what does this check?
Sam McNally 2014/10/20 05:12:59 This checks that the connection object has actuall
280 }
281
282 TEST_F(SerialConnectionTest, DisconnectWithReceive) {
283 connection_.reset();
raymes 2014/10/17 02:11:10 And how come this is needed now?
Sam McNally 2014/10/20 05:12:59 Timing is different when data goes over the contro
279 ASSERT_NO_FATAL_FAILURE(Receive()); 284 ASSERT_NO_FATAL_FAILURE(Receive());
280 WaitForEvent(EVENT_RECEIVE_ERROR); 285 WaitForEvent(EVENT_RECEIVE_ERROR);
281 EXPECT_EQ(serial::RECEIVE_ERROR_DISCONNECTED, receive_error_); 286 EXPECT_EQ(serial::RECEIVE_ERROR_DISCONNECTED, receive_error_);
282 EXPECT_EQ("", data_received_); 287 EXPECT_EQ("", data_received_);
283 EXPECT_TRUE(io_handler_->HasOneRef()); 288 EXPECT_TRUE(io_handler_->HasOneRef());
284 } 289 }
285 290
286 TEST_F(SerialConnectionTest, Echo) { 291 TEST_F(SerialConnectionTest, Echo) {
287 ASSERT_NO_FATAL_FAILURE(Send("data")); 292 ASSERT_NO_FATAL_FAILURE(Send("data"));
288 WaitForEvent(EVENT_DATA_SENT); 293 WaitForEvent(EVENT_DATA_SENT);
(...skipping 29 matching lines...) Expand all
318 WaitForEvent(EVENT_DATA_SENT); 323 WaitForEvent(EVENT_DATA_SENT);
319 EXPECT_EQ(serial::SEND_ERROR_NONE, send_error_); 324 EXPECT_EQ(serial::SEND_ERROR_NONE, send_error_);
320 EXPECT_EQ(4, bytes_sent_); 325 EXPECT_EQ(4, bytes_sent_);
321 ASSERT_NO_FATAL_FAILURE(Receive()); 326 ASSERT_NO_FATAL_FAILURE(Receive());
322 WaitForEvent(EVENT_DATA_RECEIVED); 327 WaitForEvent(EVENT_DATA_RECEIVED);
323 EXPECT_EQ("data", data_received_); 328 EXPECT_EQ("data", data_received_);
324 EXPECT_EQ(serial::RECEIVE_ERROR_NONE, receive_error_); 329 EXPECT_EQ(serial::RECEIVE_ERROR_NONE, receive_error_);
325 } 330 }
326 331
327 } // namespace device 332 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698