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

Unified Diff: webrtc/p2p/base/port_unittest.cc

Issue 2719523002: RTCIceCandidatePairStats.[total/current]RoundTripTime collected. (Closed)
Patch Set: Created 3 years, 10 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
Index: webrtc/p2p/base/port_unittest.cc
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
index 9714280b93cc648127b7ef1c9d8e2557007a2337..347aa564dbb4f23dbeee156521d4865cd32545bb 100644
--- a/webrtc/p2p/base/port_unittest.cc
+++ b/webrtc/p2p/base/port_unittest.cc
@@ -1788,6 +1788,44 @@ TEST_F(PortTest, TestSendStunMessage) {
EXPECT_EQ(2U, retransmit_attr->value());
}
+TEST_F(PortTest, TestRoundTripTime) {
+ std::unique_ptr<TestPort> lport(
+ CreateTestPort(kLocalAddr1, "lfrag", "lpass"));
+ std::unique_ptr<TestPort> rport(
+ CreateTestPort(kLocalAddr2, "rfrag", "rpass"));
+ lport->SetIceRole(cricket::ICEROLE_CONTROLLING);
+ lport->SetIceTiebreaker(kTiebreaker1);
+ rport->SetIceRole(cricket::ICEROLE_CONTROLLED);
+ rport->SetIceTiebreaker(kTiebreaker2);
+
+ lport->PrepareAddress();
+ rport->PrepareAddress();
+ ASSERT_FALSE(rport->Candidates().empty());
+ Connection* lconn = lport->CreateConnection(
+ rport->Candidates()[0], Port::ORIGIN_MESSAGE);
+
+ EXPECT_FALSE(lconn->stats().total_round_trip_time_ms);
+ EXPECT_FALSE(lconn->stats().current_round_trip_time_ms);
+
+ lconn->ReceivedPingResponse(10, "id");
Taylor Brandstetter 2017/02/25 01:31:29 ReceivedPingResponse is something that *should* be
pthatcher1 2017/02/27 18:07:21 I agree. TestHandleStunMessage is an example of h
hbos 2017/02/27 19:51:34 I updated the test to use Ping much like the real
+ ASSERT_TRUE(lconn->stats().total_round_trip_time_ms);
+ ASSERT_TRUE(lconn->stats().current_round_trip_time_ms);
+ EXPECT_EQ(*lconn->stats().total_round_trip_time_ms, 10u);
+ EXPECT_EQ(*lconn->stats().current_round_trip_time_ms, 10u);
+
+ lconn->ReceivedPingResponse(20, "id");
+ ASSERT_TRUE(lconn->stats().total_round_trip_time_ms);
+ ASSERT_TRUE(lconn->stats().current_round_trip_time_ms);
+ EXPECT_EQ(*lconn->stats().total_round_trip_time_ms, 30u);
+ EXPECT_EQ(*lconn->stats().current_round_trip_time_ms, 20u);
+
+ lconn->ReceivedPingResponse(30, "id");
+ ASSERT_TRUE(lconn->stats().total_round_trip_time_ms);
+ ASSERT_TRUE(lconn->stats().current_round_trip_time_ms);
+ EXPECT_EQ(*lconn->stats().total_round_trip_time_ms, 60u);
+ EXPECT_EQ(*lconn->stats().current_round_trip_time_ms, 30u);
+}
+
TEST_F(PortTest, TestUseCandidateAttribute) {
std::unique_ptr<TestPort> lport(
CreateTestPort(kLocalAddr1, "lfrag", "lpass"));

Powered by Google App Engine
This is Rietveld 408576698