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

Unified 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: Rename. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/p2p/base/tcpport.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port_unittest.cc
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
index 43ef084b02e1aa49a970c9d9a10accce7a414236..bf95cde229f51b1693e0c2e2d3a456972916747b 100644
--- a/webrtc/p2p/base/port_unittest.cc
+++ b/webrtc/p2p/base/port_unittest.cc
@@ -1649,12 +1649,21 @@ TEST_F(PortTest, TestSendStunMessage) {
// Save a copy of the BINDING-REQUEST for use below.
std::unique_ptr<IceMessage> request(CopyStunMessage(msg));
- // Respond with a BINDING-RESPONSE.
- rport->SendBindingResponse(request.get(), lport->Candidates()[0].address());
+ // Receive the BINDING-REQUEST and respond with BINDING-RESPONSE.
+ rconn->OnReadPacket(lport->last_stun_buf()->data<char>(),
+ lport->last_stun_buf()->size(), rtc::PacketTime());
msg = rport->last_stun_msg();
ASSERT_TRUE(msg != NULL);
EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type());
-
+ // Received a BINDING-RESPONSE.
+ lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
+ rport->last_stun_buf()->size(), rtc::PacketTime());
+ // Verify the STUN Stats.
+ EXPECT_EQ(1U, lconn->stats().sent_ping_requests_total);
+ EXPECT_EQ(1U, lconn->stats().sent_ping_requests_before_first_response);
+ EXPECT_EQ(1U, lconn->stats().recv_ping_responses);
+ EXPECT_EQ(1U, rconn->stats().recv_ping_requests);
+ EXPECT_EQ(1U, rconn->stats().sent_ping_responses);
EXPECT_FALSE(msg->IsLegacy());
const StunAddressAttribute* addr_attr = msg->GetAddress(
@@ -1728,8 +1737,24 @@ TEST_F(PortTest, TestSendStunMessage) {
// Respond with a BINDING-RESPONSE.
request.reset(CopyStunMessage(msg));
- lport->SendBindingResponse(request.get(), rport->Candidates()[0].address());
+ lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
+ rport->last_stun_buf()->size(), rtc::PacketTime());
msg = lport->last_stun_msg();
+ // Receive the BINDING-RESPONSE.
+ rconn->OnReadPacket(lport->last_stun_buf()->data<char>(),
+ lport->last_stun_buf()->size(), rtc::PacketTime());
+
+ // Verify the Stun ping stats.
+ EXPECT_EQ(3U, rconn->stats().sent_ping_requests_total);
+ EXPECT_EQ(3U, rconn->stats().sent_ping_requests_before_first_response);
+ EXPECT_EQ(1U, rconn->stats().recv_ping_responses);
+ EXPECT_EQ(1U, lconn->stats().sent_ping_responses);
+ EXPECT_EQ(1U, lconn->stats().recv_ping_requests);
+ // Ping after receiver the first response
+ rconn->Ping(0);
+ rconn->Ping(0);
+ EXPECT_EQ(5U, rconn->stats().sent_ping_requests_total);
+ EXPECT_EQ(3U, rconn->stats().sent_ping_requests_before_first_response);
// Response should include same ping count.
retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT);
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/p2p/base/tcpport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698