Chromium Code Reviews

Side by Side Diff: webrtc/video/call_stats_unittest.cc

Issue 1669623004: Use CallStats for RTT in Call, rather than VideoSendStream::GetRtt() (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Cleanup Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 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 10
(...skipping 27 matching lines...)
38 virtual void SetUp() { call_stats_.reset(new CallStats(&fake_clock_)); } 38 virtual void SetUp() { call_stats_.reset(new CallStats(&fake_clock_)); }
39 SimulatedClock fake_clock_; 39 SimulatedClock fake_clock_;
40 rtc::scoped_ptr<CallStats> call_stats_; 40 rtc::scoped_ptr<CallStats> call_stats_;
41 }; 41 };
42 42
43 TEST_F(CallStatsTest, AddAndTriggerCallback) { 43 TEST_F(CallStatsTest, AddAndTriggerCallback) {
44 MockStatsObserver stats_observer; 44 MockStatsObserver stats_observer;
45 RtcpRttStats* rtcp_rtt_stats = call_stats_->rtcp_rtt_stats(); 45 RtcpRttStats* rtcp_rtt_stats = call_stats_->rtcp_rtt_stats();
46 call_stats_->RegisterStatsObserver(&stats_observer); 46 call_stats_->RegisterStatsObserver(&stats_observer);
47 fake_clock_.AdvanceTimeMilliseconds(1000); 47 fake_clock_.AdvanceTimeMilliseconds(1000);
48 EXPECT_EQ(0, rtcp_rtt_stats->LastProcessedRtt()); 48 EXPECT_EQ(-1, rtcp_rtt_stats->LastProcessedRtt());
49 49
50 const int64_t kRtt = 25; 50 const int64_t kRtt = 25;
51 rtcp_rtt_stats->OnRttUpdate(kRtt); 51 rtcp_rtt_stats->OnRttUpdate(kRtt);
52 EXPECT_CALL(stats_observer, OnRttUpdate(kRtt, kRtt)).Times(1); 52 EXPECT_CALL(stats_observer, OnRttUpdate(kRtt, kRtt)).Times(1);
53 call_stats_->Process(); 53 call_stats_->Process();
54 EXPECT_EQ(kRtt, rtcp_rtt_stats->LastProcessedRtt()); 54 EXPECT_EQ(kRtt, rtcp_rtt_stats->LastProcessedRtt());
55 55
56 const int64_t kRttTimeOutMs = 1500 + 10; 56 const int64_t kRttTimeOutMs = 1500 + 10;
57 fake_clock_.AdvanceTimeMilliseconds(kRttTimeOutMs); 57 fake_clock_.AdvanceTimeMilliseconds(kRttTimeOutMs);
58 EXPECT_CALL(stats_observer, OnRttUpdate(_, _)).Times(0); 58 EXPECT_CALL(stats_observer, OnRttUpdate(_, _)).Times(0);
59 call_stats_->Process(); 59 call_stats_->Process();
60 EXPECT_EQ(0, rtcp_rtt_stats->LastProcessedRtt()); 60 EXPECT_EQ(-1, rtcp_rtt_stats->LastProcessedRtt());
61 61
62 call_stats_->DeregisterStatsObserver(&stats_observer); 62 call_stats_->DeregisterStatsObserver(&stats_observer);
63 } 63 }
64 64
65 TEST_F(CallStatsTest, ProcessTime) { 65 TEST_F(CallStatsTest, ProcessTime) {
66 MockStatsObserver stats_observer; 66 MockStatsObserver stats_observer;
67 call_stats_->RegisterStatsObserver(&stats_observer); 67 call_stats_->RegisterStatsObserver(&stats_observer);
68 RtcpRttStats* rtcp_rtt_stats = call_stats_->rtcp_rtt_stats(); 68 RtcpRttStats* rtcp_rtt_stats = call_stats_->rtcp_rtt_stats();
69 rtcp_rtt_stats->OnRttUpdate(100); 69 rtcp_rtt_stats->OnRttUpdate(100);
70 70
(...skipping 124 matching lines...)
195 rtcp_rtt_stats->OnRttUpdate(kRttLow); 195 rtcp_rtt_stats->OnRttUpdate(kRttLow);
196 rtcp_rtt_stats->OnRttUpdate(kRttHigh); 196 rtcp_rtt_stats->OnRttUpdate(kRttHigh);
197 EXPECT_CALL(stats_observer, OnRttUpdate(kAvgRtt, kRttHigh)).Times(1); 197 EXPECT_CALL(stats_observer, OnRttUpdate(kAvgRtt, kRttHigh)).Times(1);
198 call_stats_->Process(); 198 call_stats_->Process();
199 EXPECT_EQ(kAvgRtt, rtcp_rtt_stats->LastProcessedRtt()); 199 EXPECT_EQ(kAvgRtt, rtcp_rtt_stats->LastProcessedRtt());
200 200
201 call_stats_->DeregisterStatsObserver(&stats_observer); 201 call_stats_->DeregisterStatsObserver(&stats_observer);
202 } 202 }
203 203
204 } // namespace webrtc 204 } // namespace webrtc
OLDNEW

Powered by Google App Engine