OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #if defined(WEBRTC_POSIX) | 10 #if defined(WEBRTC_POSIX) |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 EXPECT_TRUE(conn1->receiving()); | 378 EXPECT_TRUE(conn1->receiving()); |
379 EXPECT_TRUE(conn2->receiving()); | 379 EXPECT_TRUE(conn2->receiving()); |
380 EXPECT_EQ(Connection::STATE_WRITE_INIT, conn1->write_state()); | 380 EXPECT_EQ(Connection::STATE_WRITE_INIT, conn1->write_state()); |
381 | 381 |
382 // Send another ping from UDP to TURN. | 382 // Send another ping from UDP to TURN. |
383 conn1->Ping(0); | 383 conn1->Ping(0); |
384 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn1->write_state(), kTimeout); | 384 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn1->write_state(), kTimeout); |
385 EXPECT_TRUE(conn2->receiving()); | 385 EXPECT_TRUE(conn2->receiving()); |
386 } | 386 } |
387 | 387 |
388 void TestRefreshCreatePermissionRequest() { | |
389 ASSERT_TRUE(turn_port_ != NULL); | |
390 turn_port_->PrepareAddress(); | |
391 ASSERT_TRUE_WAIT(turn_ready_, kTimeout); | |
392 CreateUdpPort(); | |
393 udp_port_->PrepareAddress(); | |
394 ASSERT_TRUE_WAIT(udp_ready_, kTimeout); | |
395 | |
396 Connection* conn = turn_port_->CreateConnection(udp_port_->Candidates()[0], | |
397 Port::ORIGIN_MESSAGE); | |
398 ASSERT_TRUE(conn != NULL); | |
399 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout); | |
400 turn_create_permission_success_ = false; | |
401 // A create-permission-request should be pending. | |
402 turn_port_->FlushRequests(); | |
403 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout); | |
pthatcher1
2015/11/11 20:22:09
Unfortunately, this doesn't test *when* the permis
honghaiz3
2015/11/11 23:51:58
It is pretty hard to test that. We don't want to w
| |
404 } | |
405 | |
388 void TestTurnSendData() { | 406 void TestTurnSendData() { |
389 turn_port_->PrepareAddress(); | 407 turn_port_->PrepareAddress(); |
390 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); | 408 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); |
391 CreateUdpPort(); | 409 CreateUdpPort(); |
392 udp_port_->PrepareAddress(); | 410 udp_port_->PrepareAddress(); |
393 EXPECT_TRUE_WAIT(udp_ready_, kTimeout); | 411 EXPECT_TRUE_WAIT(udp_ready_, kTimeout); |
394 // Create connections and send pings. | 412 // Create connections and send pings. |
395 Connection* conn1 = turn_port_->CreateConnection( | 413 Connection* conn1 = turn_port_->CreateConnection( |
396 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); | 414 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); |
397 Connection* conn2 = udp_port_->CreateConnection( | 415 Connection* conn2 = udp_port_->CreateConnection( |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 | 726 |
709 // Run TurnConnectionTest with one-time-use nonce feature. | 727 // Run TurnConnectionTest with one-time-use nonce feature. |
710 // Here server will send a 438 STALE_NONCE error message for | 728 // Here server will send a 438 STALE_NONCE error message for |
711 // every TURN transaction. | 729 // every TURN transaction. |
712 TEST_F(TurnPortTest, TestTurnConnectionUsingOTUNonce) { | 730 TEST_F(TurnPortTest, TestTurnConnectionUsingOTUNonce) { |
713 turn_server_.set_enable_otu_nonce(true); | 731 turn_server_.set_enable_otu_nonce(true); |
714 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); | 732 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); |
715 TestTurnConnection(); | 733 TestTurnConnection(); |
716 } | 734 } |
717 | 735 |
736 // Test that CreatePermissionRequest will be scheduled after the success | |
737 // of the first create permission request. | |
738 TEST_F(TurnPortTest, TestRefreshCreatePermissionRequest) { | |
739 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); | |
740 TestRefreshCreatePermissionRequest(); | |
pthatcher1
2015/11/11 20:22:09
Why did you put this in a separate method? Why no
honghaiz3
2015/11/11 23:51:59
Done.
| |
741 } | |
742 | |
718 // Do a TURN allocation, establish a UDP connection, and send some data. | 743 // Do a TURN allocation, establish a UDP connection, and send some data. |
719 TEST_F(TurnPortTest, TestTurnSendDataTurnUdpToUdp) { | 744 TEST_F(TurnPortTest, TestTurnSendDataTurnUdpToUdp) { |
720 // Create ports and prepare addresses. | 745 // Create ports and prepare addresses. |
721 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); | 746 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); |
722 TestTurnSendData(); | 747 TestTurnSendData(); |
723 EXPECT_EQ(cricket::UDP_PROTOCOL_NAME, | 748 EXPECT_EQ(cricket::UDP_PROTOCOL_NAME, |
724 turn_port_->Candidates()[0].relay_protocol()); | 749 turn_port_->Candidates()[0].relay_protocol()); |
725 } | 750 } |
726 | 751 |
727 // Do a TURN allocation, establish a TCP connection, and send some data. | 752 // Do a TURN allocation, establish a TCP connection, and send some data. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 turn_port_->PrepareAddress(); | 832 turn_port_->PrepareAddress(); |
808 ASSERT_TRUE_WAIT(turn_error_, kTimeout); | 833 ASSERT_TRUE_WAIT(turn_error_, kTimeout); |
809 EXPECT_TRUE(turn_port_->Candidates().empty()); | 834 EXPECT_TRUE(turn_port_->Candidates().empty()); |
810 turn_port_.reset(); | 835 turn_port_.reset(); |
811 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); | 836 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); |
812 // Waiting for above message to be processed. | 837 // Waiting for above message to be processed. |
813 ASSERT_TRUE_WAIT(test_finish_, kTimeout); | 838 ASSERT_TRUE_WAIT(test_finish_, kTimeout); |
814 EXPECT_EQ(last_fd_count, GetFDCount()); | 839 EXPECT_EQ(last_fd_count, GetFDCount()); |
815 } | 840 } |
816 #endif | 841 #endif |
OLD | NEW |