OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/nss_util.h" | 7 #include "base/nss_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 net::CompletionCallbackImpl<UDPChannelTester> read_cb_; | 541 net::CompletionCallbackImpl<UDPChannelTester> read_cb_; |
542 int write_errors_; | 542 int write_errors_; |
543 int read_errors_; | 543 int read_errors_; |
544 int packets_sent_; | 544 int packets_sent_; |
545 int packets_received_; | 545 int packets_received_; |
546 int broken_packets_; | 546 int broken_packets_; |
547 }; | 547 }; |
548 | 548 |
549 // Mac needs to implement X509Certificate::CreateSelfSigned to enable these | 549 // Mac needs to implement X509Certificate::CreateSelfSigned to enable these |
550 // tests. | 550 // tests. |
551 // TODO(hclam): Run these tests on Windows. | 551 #if defined(USE_NSS) || defined(OS_WIN) |
552 #if defined(USE_NSS) | |
553 | 552 |
554 // Verify that we can create and destory server objects without a connection. | 553 // Verify that we can create and destory server objects without a connection. |
555 TEST_F(JingleSessionTest, CreateAndDestoy) { | 554 TEST_F(JingleSessionTest, CreateAndDestoy) { |
556 if (!base::CheckNSSVersion("3.12.8")) | |
557 return; | |
558 | |
559 CreateServerPair(); | 555 CreateServerPair(); |
560 } | 556 } |
561 | 557 |
562 // Verify that incoming session can be rejected, and that the status | 558 // Verify that incoming session can be rejected, and that the status |
563 // of the connection is set to CLOSED in this case. | 559 // of the connection is set to CLOSED in this case. |
564 TEST_F(JingleSessionTest, RejectConnection) { | 560 TEST_F(JingleSessionTest, RejectConnection) { |
565 if (!base::CheckNSSVersion("3.12.8")) | |
566 return; | |
567 | |
568 CreateServerPair(); | 561 CreateServerPair(); |
569 | 562 |
570 // Reject incoming session. | 563 // Reject incoming session. |
571 EXPECT_CALL(host_server_callback_, OnIncomingSession(_, _)) | 564 EXPECT_CALL(host_server_callback_, OnIncomingSession(_, _)) |
572 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE)); | 565 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE)); |
573 | 566 |
574 base::WaitableEvent done_event(false, false); | 567 base::WaitableEvent done_event(false, false); |
575 EXPECT_CALL(client_connection_callback_, | 568 EXPECT_CALL(client_connection_callback_, |
576 OnStateChange(Session::CONNECTING)) | 569 OnStateChange(Session::CONNECTING)) |
577 .Times(1); | 570 .Times(1); |
578 EXPECT_CALL(client_connection_callback_, | 571 EXPECT_CALL(client_connection_callback_, |
579 OnStateChange(Session::CLOSED)) | 572 OnStateChange(Session::CLOSED)) |
580 .Times(1) | 573 .Times(1) |
581 .WillOnce(InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)); | 574 .WillOnce(InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)); |
582 | 575 |
583 client_session_ = client_server_->Connect( | 576 client_session_ = client_server_->Connect( |
584 SessionManagerPair::kHostJid, | 577 SessionManagerPair::kHostJid, |
585 kTestToken, | 578 kTestToken, |
586 CandidateSessionConfig::CreateDefault(), | 579 CandidateSessionConfig::CreateDefault(), |
587 NewCallback(&client_connection_callback_, | 580 NewCallback(&client_connection_callback_, |
588 &MockSessionCallback::OnStateChange)); | 581 &MockSessionCallback::OnStateChange)); |
589 | 582 |
590 ASSERT_TRUE( | 583 ASSERT_TRUE( |
591 done_event.TimedWait(base::TimeDelta::FromMilliseconds( | 584 done_event.TimedWait(base::TimeDelta::FromMilliseconds( |
592 TestTimeouts::action_max_timeout_ms()))); | 585 TestTimeouts::action_max_timeout_ms()))); |
593 } | 586 } |
594 | 587 |
595 // Verify that we can connect two endpoints. | 588 // Verify that we can connect two endpoints. |
596 TEST_F(JingleSessionTest, Connect) { | 589 TEST_F(JingleSessionTest, Connect) { |
597 if (!base::CheckNSSVersion("3.12.8")) | |
598 return; | |
599 | |
600 CreateServerPair(); | 590 CreateServerPair(); |
601 ASSERT_TRUE(InitiateConnection()); | 591 ASSERT_TRUE(InitiateConnection()); |
602 } | 592 } |
603 | 593 |
604 // Verify that data can be transmitted over the event channel. | 594 // Verify that data can be transmitted over the event channel. |
605 TEST_F(JingleSessionTest, TestControlChannel) { | 595 TEST_F(JingleSessionTest, TestControlChannel) { |
606 if (!base::CheckNSSVersion("3.12.8")) | |
607 return; | |
608 | |
609 CreateServerPair(); | 596 CreateServerPair(); |
610 ASSERT_TRUE(InitiateConnection()); | 597 ASSERT_TRUE(InitiateConnection()); |
611 scoped_refptr<TCPChannelTester> tester( | 598 scoped_refptr<TCPChannelTester> tester( |
612 new TCPChannelTester(thread_.message_loop(), host_session_, | 599 new TCPChannelTester(thread_.message_loop(), host_session_, |
613 client_session_)); | 600 client_session_)); |
614 tester->Start(ChannelTesterBase::CONTROL); | 601 tester->Start(ChannelTesterBase::CONTROL); |
615 ASSERT_TRUE(tester->WaitFinished()); | 602 ASSERT_TRUE(tester->WaitFinished()); |
616 tester->CheckResults(); | 603 tester->CheckResults(); |
617 | 604 |
618 // Connections must be closed while |tester| still exists. | 605 // Connections must be closed while |tester| still exists. |
619 CloseSessions(); | 606 CloseSessions(); |
620 } | 607 } |
621 | 608 |
622 // Verify that data can be transmitted over the video channel. | 609 // Verify that data can be transmitted over the video channel. |
623 TEST_F(JingleSessionTest, TestVideoChannel) { | 610 TEST_F(JingleSessionTest, TestVideoChannel) { |
624 if (!base::CheckNSSVersion("3.12.8")) | |
625 return; | |
626 | |
627 CreateServerPair(); | 611 CreateServerPair(); |
628 ASSERT_TRUE(InitiateConnection()); | 612 ASSERT_TRUE(InitiateConnection()); |
629 scoped_refptr<TCPChannelTester> tester( | 613 scoped_refptr<TCPChannelTester> tester( |
630 new TCPChannelTester(thread_.message_loop(), host_session_, | 614 new TCPChannelTester(thread_.message_loop(), host_session_, |
631 client_session_)); | 615 client_session_)); |
632 tester->Start(ChannelTesterBase::VIDEO); | 616 tester->Start(ChannelTesterBase::VIDEO); |
633 ASSERT_TRUE(tester->WaitFinished()); | 617 ASSERT_TRUE(tester->WaitFinished()); |
634 tester->CheckResults(); | 618 tester->CheckResults(); |
635 | 619 |
636 // Connections must be closed while |tester| still exists. | 620 // Connections must be closed while |tester| still exists. |
637 CloseSessions(); | 621 CloseSessions(); |
638 } | 622 } |
639 | 623 |
640 // Verify that data can be transmitted over the event channel. | 624 // Verify that data can be transmitted over the event channel. |
641 TEST_F(JingleSessionTest, TestEventChannel) { | 625 TEST_F(JingleSessionTest, TestEventChannel) { |
642 if (!base::CheckNSSVersion("3.12.8")) | |
643 return; | |
644 | |
645 CreateServerPair(); | 626 CreateServerPair(); |
646 ASSERT_TRUE(InitiateConnection()); | 627 ASSERT_TRUE(InitiateConnection()); |
647 scoped_refptr<TCPChannelTester> tester( | 628 scoped_refptr<TCPChannelTester> tester( |
648 new TCPChannelTester(thread_.message_loop(), host_session_, | 629 new TCPChannelTester(thread_.message_loop(), host_session_, |
649 client_session_)); | 630 client_session_)); |
650 tester->Start(ChannelTesterBase::EVENT); | 631 tester->Start(ChannelTesterBase::EVENT); |
651 ASSERT_TRUE(tester->WaitFinished()); | 632 ASSERT_TRUE(tester->WaitFinished()); |
652 tester->CheckResults(); | 633 tester->CheckResults(); |
653 | 634 |
654 // Connections must be closed while |tester| still exists. | 635 // Connections must be closed while |tester| still exists. |
655 CloseSessions(); | 636 CloseSessions(); |
656 } | 637 } |
657 | 638 |
658 // Verify that data can be transmitted over the video RTP channel. | 639 // Verify that data can be transmitted over the video RTP channel. |
659 TEST_F(JingleSessionTest, TestVideoRtpChannel) { | 640 TEST_F(JingleSessionTest, TestVideoRtpChannel) { |
660 if (!base::CheckNSSVersion("3.12.8")) | |
661 return; | |
662 | |
663 CreateServerPair(); | 641 CreateServerPair(); |
664 ASSERT_TRUE(InitiateConnection()); | 642 ASSERT_TRUE(InitiateConnection()); |
665 scoped_refptr<UDPChannelTester> tester( | 643 scoped_refptr<UDPChannelTester> tester( |
666 new UDPChannelTester(thread_.message_loop(), host_session_, | 644 new UDPChannelTester(thread_.message_loop(), host_session_, |
667 client_session_)); | 645 client_session_)); |
668 tester->Start(ChannelTesterBase::VIDEO_RTP); | 646 tester->Start(ChannelTesterBase::VIDEO_RTP); |
669 ASSERT_TRUE(tester->WaitFinished()); | 647 ASSERT_TRUE(tester->WaitFinished()); |
670 tester->CheckResults(); | 648 tester->CheckResults(); |
671 | 649 |
672 // Connections must be closed while |tester| still exists. | 650 // Connections must be closed while |tester| still exists. |
673 CloseSessions(); | 651 CloseSessions(); |
674 } | 652 } |
675 | 653 |
676 #endif | 654 #endif |
677 | 655 |
678 } // namespace protocol | 656 } // namespace protocol |
679 } // namespace remoting | 657 } // namespace remoting |
OLD | NEW |