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

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

Issue 2719523002: RTCIceCandidatePairStats.[total/current]RoundTripTime collected. (Closed)
Patch Set: EXPECT_EQ(expected, actual) 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
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/pc/rtcstats_integrationtest.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 ecd5c416c72a565527fae260aed1652ff9408997..4029118892a9bda579795533e89c571450310cb4 100644
--- a/webrtc/p2p/base/port_unittest.cc
+++ b/webrtc/p2p/base/port_unittest.cc
@@ -222,6 +222,23 @@ class TestPort : public Port {
int type_preference_ = 0;
};
+static void SendPingAndReceiveResponse(
+ Connection* lconn, TestPort* lport, Connection* rconn, TestPort* rport,
+ rtc::ScopedFakeClock* clock, int64_t ms) {
+ lconn->Ping(rtc::TimeMillis());
+ ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout);
+ ASSERT_TRUE(lport->last_stun_buf());
+ rconn->OnReadPacket(lport->last_stun_buf()->data<char>(),
+ lport->last_stun_buf()->size(),
+ rtc::PacketTime());
+ clock->AdvanceTime(rtc::TimeDelta::FromMilliseconds(ms));
+ ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout);
+ ASSERT_TRUE(rport->last_stun_buf());
+ lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
+ rport->last_stun_buf()->size(),
+ rtc::PacketTime());
+}
+
class TestChannel : public sigslot::has_slots<> {
public:
// Takes ownership of |p1| (but not |p2|).
@@ -1844,6 +1861,49 @@ TEST_F(PortTest, TestNomination) {
EXPECT_EQ(rconn->nominated(), rconn->stats().nominated);
}
+TEST_F(PortTest, TestRoundTripTime) {
+ rtc::ScopedFakeClock clock;
+
+ 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(lport->Candidates().empty());
+ ASSERT_FALSE(rport->Candidates().empty());
+ Connection* lconn = lport->CreateConnection(rport->Candidates()[0],
+ Port::ORIGIN_MESSAGE);
+ Connection* rconn = rport->CreateConnection(lport->Candidates()[0],
+ Port::ORIGIN_MESSAGE);
+
+ EXPECT_EQ(0u, lconn->stats().total_round_trip_time_ms);
+ EXPECT_FALSE(lconn->stats().current_round_trip_time_ms);
+
+ SendPingAndReceiveResponse(
+ lconn, lport.get(), rconn, rport.get(), &clock, 10);
+ EXPECT_EQ(10u, lconn->stats().total_round_trip_time_ms);
+ ASSERT_TRUE(lconn->stats().current_round_trip_time_ms);
+ EXPECT_EQ(10u, *lconn->stats().current_round_trip_time_ms);
+
+ SendPingAndReceiveResponse(
+ lconn, lport.get(), rconn, rport.get(), &clock, 20);
+ EXPECT_EQ(30u, lconn->stats().total_round_trip_time_ms);
+ ASSERT_TRUE(lconn->stats().current_round_trip_time_ms);
+ EXPECT_EQ(20u, *lconn->stats().current_round_trip_time_ms);
+
+ SendPingAndReceiveResponse(
+ lconn, lport.get(), rconn, rport.get(), &clock, 30);
+ EXPECT_EQ(60u, lconn->stats().total_round_trip_time_ms);
+ ASSERT_TRUE(lconn->stats().current_round_trip_time_ms);
+ EXPECT_EQ(30u, *lconn->stats().current_round_trip_time_ms);
+}
+
TEST_F(PortTest, TestUseCandidateAttribute) {
std::unique_ptr<TestPort> lport(
CreateTestPort(kLocalAddr1, "lfrag", "lpass"));
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/pc/rtcstats_integrationtest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698