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

Side by Side Diff: webrtc/p2p/base/port_unittest.cc

Issue 1940493002: Add Stats to Stun ping. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 10
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); 1645 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL);
1646 1646
1647 // Save a copy of the BINDING-REQUEST for use below. 1647 // Save a copy of the BINDING-REQUEST for use below.
1648 std::unique_ptr<IceMessage> request(CopyStunMessage(msg)); 1648 std::unique_ptr<IceMessage> request(CopyStunMessage(msg));
1649 1649
1650 // Respond with a BINDING-RESPONSE. 1650 // Respond with a BINDING-RESPONSE.
1651 rport->SendBindingResponse(request.get(), lport->Candidates()[0].address()); 1651 rport->SendBindingResponse(request.get(), lport->Candidates()[0].address());
1652 msg = rport->last_stun_msg(); 1652 msg = rport->last_stun_msg();
1653 ASSERT_TRUE(msg != NULL); 1653 ASSERT_TRUE(msg != NULL);
1654 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); 1654 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type());
1655 1655 // Received a BINDING-RESPONSE.
1656 lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
1657 rport->last_stun_buf()->size(), rtc::PacketTime());
1658 // Verify the STUN Stats.
1659 EXPECT_EQ(1U, lconn->sent_ping_requests());
1660 EXPECT_EQ(1U, lconn->recv_ping_responses());
1656 1661
1657 EXPECT_FALSE(msg->IsLegacy()); 1662 EXPECT_FALSE(msg->IsLegacy());
1658 const StunAddressAttribute* addr_attr = msg->GetAddress( 1663 const StunAddressAttribute* addr_attr = msg->GetAddress(
1659 STUN_ATTR_XOR_MAPPED_ADDRESS); 1664 STUN_ATTR_XOR_MAPPED_ADDRESS);
1660 ASSERT_TRUE(addr_attr != NULL); 1665 ASSERT_TRUE(addr_attr != NULL);
1661 EXPECT_EQ(lport->Candidates()[0].address(), addr_attr->GetAddress()); 1666 EXPECT_EQ(lport->Candidates()[0].address(), addr_attr->GetAddress());
1662 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); 1667 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL);
1663 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( 1668 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity(
1664 rport->last_stun_buf()->data<char>(), rport->last_stun_buf()->size(), 1669 rport->last_stun_buf()->data<char>(), rport->last_stun_buf()->size(),
1665 "rpass")); 1670 "rpass"));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 msg->GetUInt64(STUN_ATTR_ICE_CONTROLLED); 1721 msg->GetUInt64(STUN_ATTR_ICE_CONTROLLED);
1717 ASSERT_TRUE(ice_controlled_attr != NULL); 1722 ASSERT_TRUE(ice_controlled_attr != NULL);
1718 EXPECT_EQ(rport->IceTiebreaker(), ice_controlled_attr->value()); 1723 EXPECT_EQ(rport->IceTiebreaker(), ice_controlled_attr->value());
1719 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); 1724 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL);
1720 1725
1721 // Request should include ping count. 1726 // Request should include ping count.
1722 const StunUInt32Attribute* retransmit_attr = 1727 const StunUInt32Attribute* retransmit_attr =
1723 msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); 1728 msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT);
1724 ASSERT_TRUE(retransmit_attr != NULL); 1729 ASSERT_TRUE(retransmit_attr != NULL);
1725 EXPECT_EQ(2U, retransmit_attr->value()); 1730 EXPECT_EQ(2U, retransmit_attr->value());
1731 EXPECT_EQ(3U, rconn->sent_ping_requests());
1726 1732
1727 // Respond with a BINDING-RESPONSE. 1733 // Respond with a BINDING-RESPONSE.
1728 request.reset(CopyStunMessage(msg)); 1734 request.reset(CopyStunMessage(msg));
1729 lport->SendBindingResponse(request.get(), rport->Candidates()[0].address()); 1735 lport->SendBindingResponse(request.get(), rport->Candidates()[0].address());
1730 msg = lport->last_stun_msg(); 1736 msg = lport->last_stun_msg();
1731 1737
1732 // Response should include same ping count. 1738 // Response should include same ping count.
1733 retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); 1739 retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT);
1734 ASSERT_TRUE(retransmit_attr != NULL); 1740 ASSERT_TRUE(retransmit_attr != NULL);
1735 EXPECT_EQ(2U, retransmit_attr->value()); 1741 EXPECT_EQ(2U, retransmit_attr->value());
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 std::unique_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); 2585 std::unique_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1));
2580 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); 2586 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME));
2581 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME)); 2587 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME));
2582 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); 2588 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME));
2583 2589
2584 std::unique_ptr<Port> turn_port( 2590 std::unique_ptr<Port> turn_port(
2585 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); 2591 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP));
2586 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME)); 2592 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME));
2587 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME)); 2593 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME));
2588 } 2594 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698