OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "jingle/glue/chrome_async_socket.h" | 5 #include "jingle/glue/chrome_async_socket.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/message_loop/message_pump_default.h" |
14 #include "jingle/glue/resolving_client_socket_factory.h" | 15 #include "jingle/glue/resolving_client_socket_factory.h" |
15 #include "net/base/address_list.h" | 16 #include "net/base/address_list.h" |
16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
17 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
18 #include "net/cert/mock_cert_verifier.h" | 19 #include "net/cert/mock_cert_verifier.h" |
19 #include "net/http/transport_security_state.h" | 20 #include "net/http/transport_security_state.h" |
20 #include "net/socket/socket_test_util.h" | 21 #include "net/socket/socket_test_util.h" |
21 #include "net/socket/ssl_client_socket.h" | 22 #include "net/socket/ssl_client_socket.h" |
22 #include "net/ssl/ssl_config_service.h" | 23 #include "net/ssl/ssl_config_service.h" |
23 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 scoped_ptr<net::CertVerifier> cert_verifier_; | 137 scoped_ptr<net::CertVerifier> cert_verifier_; |
137 scoped_ptr<net::TransportSecurityState> transport_security_state_; | 138 scoped_ptr<net::TransportSecurityState> transport_security_state_; |
138 }; | 139 }; |
139 | 140 |
140 class ChromeAsyncSocketTest | 141 class ChromeAsyncSocketTest |
141 : public testing::Test, | 142 : public testing::Test, |
142 public sigslot::has_slots<> { | 143 public sigslot::has_slots<> { |
143 protected: | 144 protected: |
144 ChromeAsyncSocketTest() | 145 ChromeAsyncSocketTest() |
145 : ssl_socket_data_provider_(net::ASYNC, net::OK), | 146 : ssl_socket_data_provider_(net::ASYNC, net::OK), |
146 addr_("localhost", 35) {} | 147 addr_("localhost", 35) { |
| 148 // GTest death tests execute in a fork()ed but not exec()ed process. |
| 149 // On OS X a CoreFoundation-backed message loop will exit with a |
| 150 // __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONA
LITY___YOU_MUST_EXEC__ |
| 151 // when called. |
| 152 // Explicitly create a MessagePumpDefault which can run in this enivronment. |
| 153 scoped_ptr<base::MessagePump> pump(new base::MessagePumpDefault()); |
| 154 message_loop_.reset(new base::MessageLoop(pump.Pass())); |
| 155 } |
147 | 156 |
148 virtual ~ChromeAsyncSocketTest() {} | 157 virtual ~ChromeAsyncSocketTest() {} |
149 | 158 |
150 virtual void SetUp() { | 159 virtual void SetUp() { |
151 scoped_ptr<net::MockClientSocketFactory> mock_client_socket_factory( | 160 scoped_ptr<net::MockClientSocketFactory> mock_client_socket_factory( |
152 new net::MockClientSocketFactory()); | 161 new net::MockClientSocketFactory()); |
153 mock_client_socket_factory->AddSocketDataProvider( | 162 mock_client_socket_factory->AddSocketDataProvider( |
154 &async_socket_data_provider_); | 163 &async_socket_data_provider_); |
155 mock_client_socket_factory->AddSSLSocketDataProvider( | 164 mock_client_socket_factory->AddSSLSocketDataProvider( |
156 &ssl_socket_data_provider_); | 165 &ssl_socket_data_provider_); |
(...skipping 18 matching lines...) Expand all Loading... |
175 chrome_async_socket_->SignalClosed.connect( | 184 chrome_async_socket_->SignalClosed.connect( |
176 this, &ChromeAsyncSocketTest::OnClose); | 185 this, &ChromeAsyncSocketTest::OnClose); |
177 chrome_async_socket_->SignalRead.connect( | 186 chrome_async_socket_->SignalRead.connect( |
178 this, &ChromeAsyncSocketTest::OnRead); | 187 this, &ChromeAsyncSocketTest::OnRead); |
179 chrome_async_socket_->SignalError.connect( | 188 chrome_async_socket_->SignalError.connect( |
180 this, &ChromeAsyncSocketTest::OnError); | 189 this, &ChromeAsyncSocketTest::OnError); |
181 } | 190 } |
182 | 191 |
183 virtual void TearDown() { | 192 virtual void TearDown() { |
184 // Run any tasks that we forgot to pump. | 193 // Run any tasks that we forgot to pump. |
185 message_loop_.RunUntilIdle(); | 194 message_loop_->RunUntilIdle(); |
186 ExpectClosed(); | 195 ExpectClosed(); |
187 ExpectNoSignal(); | 196 ExpectNoSignal(); |
188 chrome_async_socket_.reset(); | 197 chrome_async_socket_.reset(); |
189 } | 198 } |
190 | 199 |
191 enum Signal { | 200 enum Signal { |
192 SIGNAL_CONNECT, | 201 SIGNAL_CONNECT, |
193 SIGNAL_SSL_CONNECT, | 202 SIGNAL_SSL_CONNECT, |
194 SIGNAL_CLOSE, | 203 SIGNAL_CLOSE, |
195 SIGNAL_READ, | 204 SIGNAL_READ, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 344 |
336 // Open/close utility functions. | 345 // Open/close utility functions. |
337 | 346 |
338 void DoOpenClosed() { | 347 void DoOpenClosed() { |
339 ExpectClosed(); | 348 ExpectClosed(); |
340 async_socket_data_provider_.set_connect_data( | 349 async_socket_data_provider_.set_connect_data( |
341 net::MockConnect(net::SYNCHRONOUS, net::OK)); | 350 net::MockConnect(net::SYNCHRONOUS, net::OK)); |
342 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); | 351 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); |
343 ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING); | 352 ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING); |
344 | 353 |
345 message_loop_.RunUntilIdle(); | 354 message_loop_->RunUntilIdle(); |
346 // We may not necessarily be open; may have been other events | 355 // We may not necessarily be open; may have been other events |
347 // queued up. | 356 // queued up. |
348 ExpectSignalSocketState( | 357 ExpectSignalSocketState( |
349 SignalSocketState::NoError( | 358 SignalSocketState::NoError( |
350 SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN)); | 359 SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN)); |
351 } | 360 } |
352 | 361 |
353 void DoCloseOpened(SignalSocketState expected_signal_socket_state) { | 362 void DoCloseOpened(SignalSocketState expected_signal_socket_state) { |
354 // We may be in an error state, so just compare state(). | 363 // We may be in an error state, so just compare state(). |
355 EXPECT_EQ(ChromeAsyncSocket::STATE_OPEN, chrome_async_socket_->state()); | 364 EXPECT_EQ(ChromeAsyncSocket::STATE_OPEN, chrome_async_socket_->state()); |
356 EXPECT_TRUE(chrome_async_socket_->Close()); | 365 EXPECT_TRUE(chrome_async_socket_->Close()); |
357 ExpectSignalSocketState(expected_signal_socket_state); | 366 ExpectSignalSocketState(expected_signal_socket_state); |
358 ExpectNonErrorState(ChromeAsyncSocket::STATE_CLOSED); | 367 ExpectNonErrorState(ChromeAsyncSocket::STATE_CLOSED); |
359 } | 368 } |
360 | 369 |
361 void DoCloseOpenedNoError() { | 370 void DoCloseOpenedNoError() { |
362 DoCloseOpened( | 371 DoCloseOpened( |
363 SignalSocketState::NoError( | 372 SignalSocketState::NoError( |
364 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED)); | 373 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED)); |
365 } | 374 } |
366 | 375 |
367 void DoSSLOpenClosed() { | 376 void DoSSLOpenClosed() { |
368 const char kDummyData[] = "dummy_data"; | 377 const char kDummyData[] = "dummy_data"; |
369 async_socket_data_provider_.AddRead(net::MockRead(kDummyData)); | 378 async_socket_data_provider_.AddRead(net::MockRead(kDummyData)); |
370 DoOpenClosed(); | 379 DoOpenClosed(); |
371 ExpectReadSignal(); | 380 ExpectReadSignal(); |
372 EXPECT_EQ(kDummyData, DrainRead(1)); | 381 EXPECT_EQ(kDummyData, DrainRead(1)); |
373 | 382 |
374 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); | 383 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); |
375 message_loop_.RunUntilIdle(); | 384 message_loop_->RunUntilIdle(); |
376 ExpectSSLConnectSignal(); | 385 ExpectSSLConnectSignal(); |
377 ExpectNoSignal(); | 386 ExpectNoSignal(); |
378 ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN); | 387 ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN); |
379 } | 388 } |
380 | 389 |
381 void DoSSLCloseOpened(SignalSocketState expected_signal_socket_state) { | 390 void DoSSLCloseOpened(SignalSocketState expected_signal_socket_state) { |
382 // We may be in an error state, so just compare state(). | 391 // We may be in an error state, so just compare state(). |
383 EXPECT_EQ(ChromeAsyncSocket::STATE_TLS_OPEN, | 392 EXPECT_EQ(ChromeAsyncSocket::STATE_TLS_OPEN, |
384 chrome_async_socket_->state()); | 393 chrome_async_socket_->state()); |
385 EXPECT_TRUE(chrome_async_socket_->Close()); | 394 EXPECT_TRUE(chrome_async_socket_->Close()); |
(...skipping 22 matching lines...) Expand all Loading... |
408 } | 417 } |
409 if (len_read == 0U) { | 418 if (len_read == 0U) { |
410 break; | 419 break; |
411 } | 420 } |
412 read.append(buf.get(), len_read); | 421 read.append(buf.get(), len_read); |
413 } | 422 } |
414 return read; | 423 return read; |
415 } | 424 } |
416 | 425 |
417 // ChromeAsyncSocket expects a message loop. | 426 // ChromeAsyncSocket expects a message loop. |
418 base::MessageLoop message_loop_; | 427 scoped_ptr<base::MessageLoop> message_loop_; |
419 | 428 |
420 AsyncSocketDataProvider async_socket_data_provider_; | 429 AsyncSocketDataProvider async_socket_data_provider_; |
421 net::SSLSocketDataProvider ssl_socket_data_provider_; | 430 net::SSLSocketDataProvider ssl_socket_data_provider_; |
422 | 431 |
423 scoped_ptr<ChromeAsyncSocket> chrome_async_socket_; | 432 scoped_ptr<ChromeAsyncSocket> chrome_async_socket_; |
424 std::deque<SignalSocketState> signal_socket_states_; | 433 std::deque<SignalSocketState> signal_socket_states_; |
425 const talk_base::SocketAddress addr_; | 434 const talk_base::SocketAddress addr_; |
426 | 435 |
427 private: | 436 private: |
428 DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocketTest); | 437 DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocketTest); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 512 |
504 TEST_F(ChromeAsyncSocketTest, ImmediateConnectCloseBeforeRead) { | 513 TEST_F(ChromeAsyncSocketTest, ImmediateConnectCloseBeforeRead) { |
505 DoOpenClosed(); | 514 DoOpenClosed(); |
506 | 515 |
507 EXPECT_TRUE(chrome_async_socket_->Close()); | 516 EXPECT_TRUE(chrome_async_socket_->Close()); |
508 ExpectClosed(); | 517 ExpectClosed(); |
509 ExpectSignalSocketState( | 518 ExpectSignalSocketState( |
510 SignalSocketState::NoError( | 519 SignalSocketState::NoError( |
511 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED)); | 520 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED)); |
512 | 521 |
513 message_loop_.RunUntilIdle(); | 522 message_loop_->RunUntilIdle(); |
514 } | 523 } |
515 | 524 |
516 TEST_F(ChromeAsyncSocketTest, HangingConnect) { | 525 TEST_F(ChromeAsyncSocketTest, HangingConnect) { |
517 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); | 526 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); |
518 ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING); | 527 ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING); |
519 ExpectNoSignal(); | 528 ExpectNoSignal(); |
520 | 529 |
521 EXPECT_TRUE(chrome_async_socket_->Close()); | 530 EXPECT_TRUE(chrome_async_socket_->Close()); |
522 ExpectClosed(); | 531 ExpectClosed(); |
523 ExpectSignalSocketState( | 532 ExpectSignalSocketState( |
524 SignalSocketState::NoError( | 533 SignalSocketState::NoError( |
525 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED)); | 534 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED)); |
526 } | 535 } |
527 | 536 |
528 TEST_F(ChromeAsyncSocketTest, PendingConnect) { | 537 TEST_F(ChromeAsyncSocketTest, PendingConnect) { |
529 async_socket_data_provider_.set_connect_data( | 538 async_socket_data_provider_.set_connect_data( |
530 net::MockConnect(net::ASYNC, net::OK)); | 539 net::MockConnect(net::ASYNC, net::OK)); |
531 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); | 540 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); |
532 ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING); | 541 ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING); |
533 ExpectNoSignal(); | 542 ExpectNoSignal(); |
534 | 543 |
535 message_loop_.RunUntilIdle(); | 544 message_loop_->RunUntilIdle(); |
536 ExpectNonErrorState(ChromeAsyncSocket::STATE_OPEN); | 545 ExpectNonErrorState(ChromeAsyncSocket::STATE_OPEN); |
537 ExpectSignalSocketState( | 546 ExpectSignalSocketState( |
538 SignalSocketState::NoError( | 547 SignalSocketState::NoError( |
539 SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN)); | 548 SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN)); |
540 ExpectNoSignal(); | 549 ExpectNoSignal(); |
541 | 550 |
542 message_loop_.RunUntilIdle(); | 551 message_loop_->RunUntilIdle(); |
543 | 552 |
544 DoCloseOpenedNoError(); | 553 DoCloseOpenedNoError(); |
545 } | 554 } |
546 | 555 |
547 // After this no need to test successful pending connect so | 556 // After this no need to test successful pending connect so |
548 // thoroughly. | 557 // thoroughly. |
549 | 558 |
550 TEST_F(ChromeAsyncSocketTest, PendingConnectCloseBeforeRead) { | 559 TEST_F(ChromeAsyncSocketTest, PendingConnectCloseBeforeRead) { |
551 async_socket_data_provider_.set_connect_data( | 560 async_socket_data_provider_.set_connect_data( |
552 net::MockConnect(net::ASYNC, net::OK)); | 561 net::MockConnect(net::ASYNC, net::OK)); |
553 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); | 562 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); |
554 | 563 |
555 message_loop_.RunUntilIdle(); | 564 message_loop_->RunUntilIdle(); |
556 ExpectSignalSocketState( | 565 ExpectSignalSocketState( |
557 SignalSocketState::NoError( | 566 SignalSocketState::NoError( |
558 SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN)); | 567 SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN)); |
559 | 568 |
560 DoCloseOpenedNoError(); | 569 DoCloseOpenedNoError(); |
561 | 570 |
562 message_loop_.RunUntilIdle(); | 571 message_loop_->RunUntilIdle(); |
563 } | 572 } |
564 | 573 |
565 TEST_F(ChromeAsyncSocketTest, PendingConnectError) { | 574 TEST_F(ChromeAsyncSocketTest, PendingConnectError) { |
566 async_socket_data_provider_.set_connect_data( | 575 async_socket_data_provider_.set_connect_data( |
567 net::MockConnect(net::ASYNC, net::ERR_TIMED_OUT)); | 576 net::MockConnect(net::ASYNC, net::ERR_TIMED_OUT)); |
568 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); | 577 EXPECT_TRUE(chrome_async_socket_->Connect(addr_)); |
569 | 578 |
570 message_loop_.RunUntilIdle(); | 579 message_loop_->RunUntilIdle(); |
571 | 580 |
572 ExpectSignalSocketState( | 581 ExpectSignalSocketState( |
573 SignalSocketState( | 582 SignalSocketState( |
574 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED, | 583 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED, |
575 ChromeAsyncSocket::ERROR_WINSOCK, net::ERR_TIMED_OUT)); | 584 ChromeAsyncSocket::ERROR_WINSOCK, net::ERR_TIMED_OUT)); |
576 } | 585 } |
577 | 586 |
578 // After this we can assume Connect() and Close() work as expected. | 587 // After this we can assume Connect() and Close() work as expected. |
579 | 588 |
580 TEST_F(ChromeAsyncSocketTest, EmptyRead) { | 589 TEST_F(ChromeAsyncSocketTest, EmptyRead) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 631 |
623 TEST_F(ChromeAsyncSocketTest, Read) { | 632 TEST_F(ChromeAsyncSocketTest, Read) { |
624 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 633 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
625 DoOpenClosed(); | 634 DoOpenClosed(); |
626 | 635 |
627 ExpectReadSignal(); | 636 ExpectReadSignal(); |
628 ExpectNoSignal(); | 637 ExpectNoSignal(); |
629 | 638 |
630 EXPECT_EQ(kReadData, DrainRead(1)); | 639 EXPECT_EQ(kReadData, DrainRead(1)); |
631 | 640 |
632 message_loop_.RunUntilIdle(); | 641 message_loop_->RunUntilIdle(); |
633 | 642 |
634 DoCloseOpenedNoError(); | 643 DoCloseOpenedNoError(); |
635 } | 644 } |
636 | 645 |
637 TEST_F(ChromeAsyncSocketTest, ReadTwice) { | 646 TEST_F(ChromeAsyncSocketTest, ReadTwice) { |
638 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 647 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
639 DoOpenClosed(); | 648 DoOpenClosed(); |
640 | 649 |
641 ExpectReadSignal(); | 650 ExpectReadSignal(); |
642 ExpectNoSignal(); | 651 ExpectNoSignal(); |
643 | 652 |
644 EXPECT_EQ(kReadData, DrainRead(1)); | 653 EXPECT_EQ(kReadData, DrainRead(1)); |
645 | 654 |
646 message_loop_.RunUntilIdle(); | 655 message_loop_->RunUntilIdle(); |
647 | 656 |
648 const char kReadData2[] = "mydatatoread2"; | 657 const char kReadData2[] = "mydatatoread2"; |
649 async_socket_data_provider_.AddRead(net::MockRead(kReadData2)); | 658 async_socket_data_provider_.AddRead(net::MockRead(kReadData2)); |
650 | 659 |
651 ExpectReadSignal(); | 660 ExpectReadSignal(); |
652 ExpectNoSignal(); | 661 ExpectNoSignal(); |
653 | 662 |
654 EXPECT_EQ(kReadData2, DrainRead(1)); | 663 EXPECT_EQ(kReadData2, DrainRead(1)); |
655 | 664 |
656 DoCloseOpenedNoError(); | 665 DoCloseOpenedNoError(); |
657 } | 666 } |
658 | 667 |
659 TEST_F(ChromeAsyncSocketTest, ReadError) { | 668 TEST_F(ChromeAsyncSocketTest, ReadError) { |
660 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 669 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
661 DoOpenClosed(); | 670 DoOpenClosed(); |
662 | 671 |
663 ExpectReadSignal(); | 672 ExpectReadSignal(); |
664 ExpectNoSignal(); | 673 ExpectNoSignal(); |
665 | 674 |
666 EXPECT_EQ(kReadData, DrainRead(1)); | 675 EXPECT_EQ(kReadData, DrainRead(1)); |
667 | 676 |
668 message_loop_.RunUntilIdle(); | 677 message_loop_->RunUntilIdle(); |
669 | 678 |
670 async_socket_data_provider_.AddRead( | 679 async_socket_data_provider_.AddRead( |
671 net::MockRead(net::SYNCHRONOUS, net::ERR_TIMED_OUT)); | 680 net::MockRead(net::SYNCHRONOUS, net::ERR_TIMED_OUT)); |
672 | 681 |
673 ExpectSignalSocketState( | 682 ExpectSignalSocketState( |
674 SignalSocketState( | 683 SignalSocketState( |
675 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED, | 684 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED, |
676 ChromeAsyncSocket::ERROR_WINSOCK, net::ERR_TIMED_OUT)); | 685 ChromeAsyncSocket::ERROR_WINSOCK, net::ERR_TIMED_OUT)); |
677 } | 686 } |
678 | 687 |
(...skipping 13 matching lines...) Expand all Loading... |
692 | 701 |
693 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 702 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
694 | 703 |
695 ExpectSignalSocketState( | 704 ExpectSignalSocketState( |
696 SignalSocketState::NoError( | 705 SignalSocketState::NoError( |
697 SIGNAL_READ, ChromeAsyncSocket::STATE_OPEN)); | 706 SIGNAL_READ, ChromeAsyncSocket::STATE_OPEN)); |
698 ExpectNoSignal(); | 707 ExpectNoSignal(); |
699 | 708 |
700 EXPECT_EQ(kReadData, DrainRead(1)); | 709 EXPECT_EQ(kReadData, DrainRead(1)); |
701 | 710 |
702 message_loop_.RunUntilIdle(); | 711 message_loop_->RunUntilIdle(); |
703 | 712 |
704 DoCloseOpenedNoError(); | 713 DoCloseOpenedNoError(); |
705 } | 714 } |
706 | 715 |
707 TEST_F(ChromeAsyncSocketTest, PendingEmptyRead) { | 716 TEST_F(ChromeAsyncSocketTest, PendingEmptyRead) { |
708 DoOpenClosed(); | 717 DoOpenClosed(); |
709 | 718 |
710 ExpectNoSignal(); | 719 ExpectNoSignal(); |
711 | 720 |
712 async_socket_data_provider_.AddRead(net::MockRead("")); | 721 async_socket_data_provider_.AddRead(net::MockRead("")); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 async_socket_data_provider_.AddWrite( | 757 async_socket_data_provider_.AddWrite( |
749 net::MockWrite(net::SYNCHRONOUS, kWriteData, 3)); | 758 net::MockWrite(net::SYNCHRONOUS, kWriteData, 3)); |
750 async_socket_data_provider_.AddWrite( | 759 async_socket_data_provider_.AddWrite( |
751 net::MockWrite(net::SYNCHRONOUS, kWriteData + 3, 5)); | 760 net::MockWrite(net::SYNCHRONOUS, kWriteData + 3, 5)); |
752 async_socket_data_provider_.AddWrite( | 761 async_socket_data_provider_.AddWrite( |
753 net::MockWrite(net::SYNCHRONOUS, | 762 net::MockWrite(net::SYNCHRONOUS, |
754 kWriteData + 8, arraysize(kWriteData) - 8)); | 763 kWriteData + 8, arraysize(kWriteData) - 8)); |
755 DoOpenClosed(); | 764 DoOpenClosed(); |
756 | 765 |
757 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); | 766 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); |
758 message_loop_.RunUntilIdle(); | 767 message_loop_->RunUntilIdle(); |
759 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); | 768 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); |
760 message_loop_.RunUntilIdle(); | 769 message_loop_->RunUntilIdle(); |
761 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, | 770 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, |
762 arraysize(kWriteData) - 8)); | 771 arraysize(kWriteData) - 8)); |
763 message_loop_.RunUntilIdle(); | 772 message_loop_->RunUntilIdle(); |
764 | 773 |
765 ExpectNoSignal(); | 774 ExpectNoSignal(); |
766 | 775 |
767 DoCloseOpenedNoError(); | 776 DoCloseOpenedNoError(); |
768 } | 777 } |
769 | 778 |
770 TEST_F(ChromeAsyncSocketTest, AsyncWrite) { | 779 TEST_F(ChromeAsyncSocketTest, AsyncWrite) { |
771 DoOpenClosed(); | 780 DoOpenClosed(); |
772 | 781 |
773 async_socket_data_provider_.AddWrite( | 782 async_socket_data_provider_.AddWrite( |
774 net::MockWrite(net::ASYNC, kWriteData, 3)); | 783 net::MockWrite(net::ASYNC, kWriteData, 3)); |
775 async_socket_data_provider_.AddWrite( | 784 async_socket_data_provider_.AddWrite( |
776 net::MockWrite(net::ASYNC, kWriteData + 3, 5)); | 785 net::MockWrite(net::ASYNC, kWriteData + 3, 5)); |
777 async_socket_data_provider_.AddWrite( | 786 async_socket_data_provider_.AddWrite( |
778 net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8)); | 787 net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8)); |
779 | 788 |
780 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); | 789 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); |
781 message_loop_.RunUntilIdle(); | 790 message_loop_->RunUntilIdle(); |
782 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); | 791 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); |
783 message_loop_.RunUntilIdle(); | 792 message_loop_->RunUntilIdle(); |
784 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, | 793 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, |
785 arraysize(kWriteData) - 8)); | 794 arraysize(kWriteData) - 8)); |
786 message_loop_.RunUntilIdle(); | 795 message_loop_->RunUntilIdle(); |
787 | 796 |
788 ExpectNoSignal(); | 797 ExpectNoSignal(); |
789 | 798 |
790 DoCloseOpenedNoError(); | 799 DoCloseOpenedNoError(); |
791 } | 800 } |
792 | 801 |
793 TEST_F(ChromeAsyncSocketTest, AsyncWriteError) { | 802 TEST_F(ChromeAsyncSocketTest, AsyncWriteError) { |
794 DoOpenClosed(); | 803 DoOpenClosed(); |
795 | 804 |
796 async_socket_data_provider_.AddWrite( | 805 async_socket_data_provider_.AddWrite( |
797 net::MockWrite(net::ASYNC, kWriteData, 3)); | 806 net::MockWrite(net::ASYNC, kWriteData, 3)); |
798 async_socket_data_provider_.AddWrite( | 807 async_socket_data_provider_.AddWrite( |
799 net::MockWrite(net::ASYNC, kWriteData + 3, 5)); | 808 net::MockWrite(net::ASYNC, kWriteData + 3, 5)); |
800 async_socket_data_provider_.AddWrite( | 809 async_socket_data_provider_.AddWrite( |
801 net::MockWrite(net::ASYNC, net::ERR_TIMED_OUT)); | 810 net::MockWrite(net::ASYNC, net::ERR_TIMED_OUT)); |
802 | 811 |
803 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); | 812 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); |
804 message_loop_.RunUntilIdle(); | 813 message_loop_->RunUntilIdle(); |
805 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); | 814 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); |
806 message_loop_.RunUntilIdle(); | 815 message_loop_->RunUntilIdle(); |
807 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, | 816 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, |
808 arraysize(kWriteData) - 8)); | 817 arraysize(kWriteData) - 8)); |
809 message_loop_.RunUntilIdle(); | 818 message_loop_->RunUntilIdle(); |
810 | 819 |
811 ExpectSignalSocketState( | 820 ExpectSignalSocketState( |
812 SignalSocketState( | 821 SignalSocketState( |
813 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED, | 822 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED, |
814 ChromeAsyncSocket::ERROR_WINSOCK, net::ERR_TIMED_OUT)); | 823 ChromeAsyncSocket::ERROR_WINSOCK, net::ERR_TIMED_OUT)); |
815 } | 824 } |
816 | 825 |
817 TEST_F(ChromeAsyncSocketTest, LargeWrite) { | 826 TEST_F(ChromeAsyncSocketTest, LargeWrite) { |
818 EXPECT_DEBUG_DEATH({ | 827 EXPECT_DEBUG_DEATH({ |
819 DoOpenClosed(); | 828 DoOpenClosed(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 ChromeAsyncSocket::STATE_CLOSED)); | 876 ChromeAsyncSocket::STATE_CLOSED)); |
868 ExpectNonErrorState(ChromeAsyncSocket::STATE_CLOSED); | 877 ExpectNonErrorState(ChromeAsyncSocket::STATE_CLOSED); |
869 } | 878 } |
870 | 879 |
871 TEST_F(ChromeAsyncSocketTest, ImmediateSSLConnect) { | 880 TEST_F(ChromeAsyncSocketTest, ImmediateSSLConnect) { |
872 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 881 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
873 DoOpenClosed(); | 882 DoOpenClosed(); |
874 ExpectReadSignal(); | 883 ExpectReadSignal(); |
875 | 884 |
876 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); | 885 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); |
877 message_loop_.RunUntilIdle(); | 886 message_loop_->RunUntilIdle(); |
878 ExpectSSLConnectSignal(); | 887 ExpectSSLConnectSignal(); |
879 ExpectNoSignal(); | 888 ExpectNoSignal(); |
880 ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN); | 889 ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN); |
881 | 890 |
882 DoSSLCloseOpenedNoError(); | 891 DoSSLCloseOpenedNoError(); |
883 } | 892 } |
884 | 893 |
885 TEST_F(ChromeAsyncSocketTest, DoubleSSLConnect) { | 894 TEST_F(ChromeAsyncSocketTest, DoubleSSLConnect) { |
886 EXPECT_DEBUG_DEATH({ | 895 EXPECT_DEBUG_DEATH({ |
887 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 896 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
888 DoOpenClosed(); | 897 DoOpenClosed(); |
889 ExpectReadSignal(); | 898 ExpectReadSignal(); |
890 | 899 |
891 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); | 900 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); |
892 message_loop_.RunUntilIdle(); | 901 message_loop_->RunUntilIdle(); |
893 ExpectSSLConnectSignal(); | 902 ExpectSSLConnectSignal(); |
894 ExpectNoSignal(); | 903 ExpectNoSignal(); |
895 ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN); | 904 ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN); |
896 | 905 |
897 EXPECT_FALSE(chrome_async_socket_->StartTls("fakedomain.com")); | 906 EXPECT_FALSE(chrome_async_socket_->StartTls("fakedomain.com")); |
898 | 907 |
899 DoSSLCloseOpened( | 908 DoSSLCloseOpened( |
900 SignalSocketState(SIGNAL_CLOSE, | 909 SignalSocketState(SIGNAL_CLOSE, |
901 ChromeAsyncSocket::STATE_CLOSED, | 910 ChromeAsyncSocket::STATE_CLOSED, |
902 ChromeAsyncSocket::ERROR_WRONGSTATE, | 911 ChromeAsyncSocket::ERROR_WRONGSTATE, |
903 net::OK)); | 912 net::OK)); |
904 }, "wrong state"); | 913 }, "wrong state"); |
905 } | 914 } |
906 | 915 |
907 TEST_F(ChromeAsyncSocketTest, FailedSSLConnect) { | 916 TEST_F(ChromeAsyncSocketTest, FailedSSLConnect) { |
908 ssl_socket_data_provider_.connect = | 917 ssl_socket_data_provider_.connect = |
909 net::MockConnect(net::ASYNC, net::ERR_CERT_COMMON_NAME_INVALID), | 918 net::MockConnect(net::ASYNC, net::ERR_CERT_COMMON_NAME_INVALID), |
910 | 919 |
911 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 920 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
912 DoOpenClosed(); | 921 DoOpenClosed(); |
913 ExpectReadSignal(); | 922 ExpectReadSignal(); |
914 | 923 |
915 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); | 924 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); |
916 message_loop_.RunUntilIdle(); | 925 message_loop_->RunUntilIdle(); |
917 ExpectSignalSocketState( | 926 ExpectSignalSocketState( |
918 SignalSocketState( | 927 SignalSocketState( |
919 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED, | 928 SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED, |
920 ChromeAsyncSocket::ERROR_WINSOCK, | 929 ChromeAsyncSocket::ERROR_WINSOCK, |
921 net::ERR_CERT_COMMON_NAME_INVALID)); | 930 net::ERR_CERT_COMMON_NAME_INVALID)); |
922 | 931 |
923 EXPECT_TRUE(chrome_async_socket_->Close()); | 932 EXPECT_TRUE(chrome_async_socket_->Close()); |
924 ExpectClosed(); | 933 ExpectClosed(); |
925 } | 934 } |
926 | 935 |
927 TEST_F(ChromeAsyncSocketTest, ReadDuringSSLConnecting) { | 936 TEST_F(ChromeAsyncSocketTest, ReadDuringSSLConnecting) { |
928 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 937 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
929 DoOpenClosed(); | 938 DoOpenClosed(); |
930 ExpectReadSignal(); | 939 ExpectReadSignal(); |
931 EXPECT_EQ(kReadData, DrainRead(1)); | 940 EXPECT_EQ(kReadData, DrainRead(1)); |
932 | 941 |
933 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); | 942 EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com")); |
934 ExpectNoSignal(); | 943 ExpectNoSignal(); |
935 | 944 |
936 // Shouldn't do anything. | 945 // Shouldn't do anything. |
937 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 946 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
938 | 947 |
939 char buf[4096]; | 948 char buf[4096]; |
940 size_t len_read = 10000U; | 949 size_t len_read = 10000U; |
941 EXPECT_TRUE(chrome_async_socket_->Read(buf, sizeof(buf), &len_read)); | 950 EXPECT_TRUE(chrome_async_socket_->Read(buf, sizeof(buf), &len_read)); |
942 EXPECT_EQ(0U, len_read); | 951 EXPECT_EQ(0U, len_read); |
943 | 952 |
944 message_loop_.RunUntilIdle(); | 953 message_loop_->RunUntilIdle(); |
945 ExpectSSLConnectSignal(); | 954 ExpectSSLConnectSignal(); |
946 ExpectSSLReadSignal(); | 955 ExpectSSLReadSignal(); |
947 ExpectNoSignal(); | 956 ExpectNoSignal(); |
948 ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN); | 957 ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN); |
949 | 958 |
950 len_read = 10000U; | 959 len_read = 10000U; |
951 EXPECT_TRUE(chrome_async_socket_->Read(buf, sizeof(buf), &len_read)); | 960 EXPECT_TRUE(chrome_async_socket_->Read(buf, sizeof(buf), &len_read)); |
952 EXPECT_EQ(kReadData, std::string(buf, len_read)); | 961 EXPECT_EQ(kReadData, std::string(buf, len_read)); |
953 | 962 |
954 DoSSLCloseOpenedNoError(); | 963 DoSSLCloseOpenedNoError(); |
(...skipping 10 matching lines...) Expand all Loading... |
965 | 974 |
966 async_socket_data_provider_.AddWrite( | 975 async_socket_data_provider_.AddWrite( |
967 net::MockWrite(net::ASYNC, kWriteData, 3)); | 976 net::MockWrite(net::ASYNC, kWriteData, 3)); |
968 | 977 |
969 // Shouldn't do anything. | 978 // Shouldn't do anything. |
970 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); | 979 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); |
971 | 980 |
972 // TODO(akalin): Figure out how to test that the write happens | 981 // TODO(akalin): Figure out how to test that the write happens |
973 // *after* the SSL connect. | 982 // *after* the SSL connect. |
974 | 983 |
975 message_loop_.RunUntilIdle(); | 984 message_loop_->RunUntilIdle(); |
976 ExpectSSLConnectSignal(); | 985 ExpectSSLConnectSignal(); |
977 ExpectNoSignal(); | 986 ExpectNoSignal(); |
978 | 987 |
979 message_loop_.RunUntilIdle(); | 988 message_loop_->RunUntilIdle(); |
980 | 989 |
981 DoSSLCloseOpenedNoError(); | 990 DoSSLCloseOpenedNoError(); |
982 } | 991 } |
983 | 992 |
984 TEST_F(ChromeAsyncSocketTest, SSLConnectDuringPendingRead) { | 993 TEST_F(ChromeAsyncSocketTest, SSLConnectDuringPendingRead) { |
985 EXPECT_DEBUG_DEATH({ | 994 EXPECT_DEBUG_DEATH({ |
986 DoOpenClosed(); | 995 DoOpenClosed(); |
987 | 996 |
988 EXPECT_FALSE(chrome_async_socket_->StartTls("fakedomain.com")); | 997 EXPECT_FALSE(chrome_async_socket_->StartTls("fakedomain.com")); |
989 | 998 |
990 DoCloseOpened( | 999 DoCloseOpened( |
991 SignalSocketState(SIGNAL_CLOSE, | 1000 SignalSocketState(SIGNAL_CLOSE, |
992 ChromeAsyncSocket::STATE_CLOSED, | 1001 ChromeAsyncSocket::STATE_CLOSED, |
993 ChromeAsyncSocket::ERROR_WRONGSTATE, | 1002 ChromeAsyncSocket::ERROR_WRONGSTATE, |
994 net::OK)); | 1003 net::OK)); |
995 }, "wrong state"); | 1004 }, "wrong state"); |
996 } | 1005 } |
997 | 1006 |
998 TEST_F(ChromeAsyncSocketTest, SSLConnectDuringPostedWrite) { | 1007 TEST_F(ChromeAsyncSocketTest, SSLConnectDuringPostedWrite) { |
999 EXPECT_DEBUG_DEATH({ | 1008 EXPECT_DEBUG_DEATH({ |
1000 DoOpenClosed(); | 1009 DoOpenClosed(); |
1001 | 1010 |
1002 async_socket_data_provider_.AddWrite( | 1011 async_socket_data_provider_.AddWrite( |
1003 net::MockWrite(net::ASYNC, kWriteData, 3)); | 1012 net::MockWrite(net::ASYNC, kWriteData, 3)); |
1004 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); | 1013 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); |
1005 | 1014 |
1006 EXPECT_FALSE(chrome_async_socket_->StartTls("fakedomain.com")); | 1015 EXPECT_FALSE(chrome_async_socket_->StartTls("fakedomain.com")); |
1007 | 1016 |
1008 message_loop_.RunUntilIdle(); | 1017 message_loop_->RunUntilIdle(); |
1009 | 1018 |
1010 DoCloseOpened( | 1019 DoCloseOpened( |
1011 SignalSocketState(SIGNAL_CLOSE, | 1020 SignalSocketState(SIGNAL_CLOSE, |
1012 ChromeAsyncSocket::STATE_CLOSED, | 1021 ChromeAsyncSocket::STATE_CLOSED, |
1013 ChromeAsyncSocket::ERROR_WRONGSTATE, | 1022 ChromeAsyncSocket::ERROR_WRONGSTATE, |
1014 net::OK)); | 1023 net::OK)); |
1015 }, "wrong state"); | 1024 }, "wrong state"); |
1016 } | 1025 } |
1017 | 1026 |
1018 // After this we can assume SSL connect works as expected. | 1027 // After this we can assume SSL connect works as expected. |
1019 | 1028 |
1020 TEST_F(ChromeAsyncSocketTest, SSLRead) { | 1029 TEST_F(ChromeAsyncSocketTest, SSLRead) { |
1021 DoSSLOpenClosed(); | 1030 DoSSLOpenClosed(); |
1022 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); | 1031 async_socket_data_provider_.AddRead(net::MockRead(kReadData)); |
1023 message_loop_.RunUntilIdle(); | 1032 message_loop_->RunUntilIdle(); |
1024 | 1033 |
1025 ExpectSSLReadSignal(); | 1034 ExpectSSLReadSignal(); |
1026 ExpectNoSignal(); | 1035 ExpectNoSignal(); |
1027 | 1036 |
1028 EXPECT_EQ(kReadData, DrainRead(1)); | 1037 EXPECT_EQ(kReadData, DrainRead(1)); |
1029 | 1038 |
1030 message_loop_.RunUntilIdle(); | 1039 message_loop_->RunUntilIdle(); |
1031 | 1040 |
1032 DoSSLCloseOpenedNoError(); | 1041 DoSSLCloseOpenedNoError(); |
1033 } | 1042 } |
1034 | 1043 |
1035 TEST_F(ChromeAsyncSocketTest, SSLSyncWrite) { | 1044 TEST_F(ChromeAsyncSocketTest, SSLSyncWrite) { |
1036 async_socket_data_provider_.AddWrite( | 1045 async_socket_data_provider_.AddWrite( |
1037 net::MockWrite(net::SYNCHRONOUS, kWriteData, 3)); | 1046 net::MockWrite(net::SYNCHRONOUS, kWriteData, 3)); |
1038 async_socket_data_provider_.AddWrite( | 1047 async_socket_data_provider_.AddWrite( |
1039 net::MockWrite(net::SYNCHRONOUS, kWriteData + 3, 5)); | 1048 net::MockWrite(net::SYNCHRONOUS, kWriteData + 3, 5)); |
1040 async_socket_data_provider_.AddWrite( | 1049 async_socket_data_provider_.AddWrite( |
1041 net::MockWrite(net::SYNCHRONOUS, | 1050 net::MockWrite(net::SYNCHRONOUS, |
1042 kWriteData + 8, arraysize(kWriteData) - 8)); | 1051 kWriteData + 8, arraysize(kWriteData) - 8)); |
1043 DoSSLOpenClosed(); | 1052 DoSSLOpenClosed(); |
1044 | 1053 |
1045 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); | 1054 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); |
1046 message_loop_.RunUntilIdle(); | 1055 message_loop_->RunUntilIdle(); |
1047 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); | 1056 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); |
1048 message_loop_.RunUntilIdle(); | 1057 message_loop_->RunUntilIdle(); |
1049 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, | 1058 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, |
1050 arraysize(kWriteData) - 8)); | 1059 arraysize(kWriteData) - 8)); |
1051 message_loop_.RunUntilIdle(); | 1060 message_loop_->RunUntilIdle(); |
1052 | 1061 |
1053 ExpectNoSignal(); | 1062 ExpectNoSignal(); |
1054 | 1063 |
1055 DoSSLCloseOpenedNoError(); | 1064 DoSSLCloseOpenedNoError(); |
1056 } | 1065 } |
1057 | 1066 |
1058 TEST_F(ChromeAsyncSocketTest, SSLAsyncWrite) { | 1067 TEST_F(ChromeAsyncSocketTest, SSLAsyncWrite) { |
1059 DoSSLOpenClosed(); | 1068 DoSSLOpenClosed(); |
1060 | 1069 |
1061 async_socket_data_provider_.AddWrite( | 1070 async_socket_data_provider_.AddWrite( |
1062 net::MockWrite(net::ASYNC, kWriteData, 3)); | 1071 net::MockWrite(net::ASYNC, kWriteData, 3)); |
1063 async_socket_data_provider_.AddWrite( | 1072 async_socket_data_provider_.AddWrite( |
1064 net::MockWrite(net::ASYNC, kWriteData + 3, 5)); | 1073 net::MockWrite(net::ASYNC, kWriteData + 3, 5)); |
1065 async_socket_data_provider_.AddWrite( | 1074 async_socket_data_provider_.AddWrite( |
1066 net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8)); | 1075 net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8)); |
1067 | 1076 |
1068 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); | 1077 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3)); |
1069 message_loop_.RunUntilIdle(); | 1078 message_loop_->RunUntilIdle(); |
1070 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); | 1079 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5)); |
1071 message_loop_.RunUntilIdle(); | 1080 message_loop_->RunUntilIdle(); |
1072 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, | 1081 EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8, |
1073 arraysize(kWriteData) - 8)); | 1082 arraysize(kWriteData) - 8)); |
1074 message_loop_.RunUntilIdle(); | 1083 message_loop_->RunUntilIdle(); |
1075 | 1084 |
1076 ExpectNoSignal(); | 1085 ExpectNoSignal(); |
1077 | 1086 |
1078 DoSSLCloseOpenedNoError(); | 1087 DoSSLCloseOpenedNoError(); |
1079 } | 1088 } |
1080 | 1089 |
1081 } // namespace | 1090 } // namespace |
1082 | 1091 |
1083 } // namespace jingle_glue | 1092 } // namespace jingle_glue |
OLD | NEW |