| OLD | NEW |
| 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 |
| 11 #include <memory> |
| 12 |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 #include "webrtc/base/scoped_ptr.h" | |
| 15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 16 #include "webrtc/system_wrappers/include/metrics.h" | 17 #include "webrtc/system_wrappers/include/metrics.h" |
| 17 #include "webrtc/system_wrappers/include/tick_util.h" | 18 #include "webrtc/system_wrappers/include/tick_util.h" |
| 18 #include "webrtc/test/histogram.h" | 19 #include "webrtc/test/histogram.h" |
| 19 #include "webrtc/video/call_stats.h" | 20 #include "webrtc/video/call_stats.h" |
| 20 | 21 |
| 21 using ::testing::_; | 22 using ::testing::_; |
| 22 using ::testing::AnyNumber; | 23 using ::testing::AnyNumber; |
| 23 using ::testing::Return; | 24 using ::testing::Return; |
| 24 | 25 |
| 25 namespace webrtc { | 26 namespace webrtc { |
| 26 | 27 |
| 27 class MockStatsObserver : public CallStatsObserver { | 28 class MockStatsObserver : public CallStatsObserver { |
| 28 public: | 29 public: |
| 29 MockStatsObserver() {} | 30 MockStatsObserver() {} |
| 30 virtual ~MockStatsObserver() {} | 31 virtual ~MockStatsObserver() {} |
| 31 | 32 |
| 32 MOCK_METHOD2(OnRttUpdate, void(int64_t, int64_t)); | 33 MOCK_METHOD2(OnRttUpdate, void(int64_t, int64_t)); |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 class CallStatsTest : public ::testing::Test { | 36 class CallStatsTest : public ::testing::Test { |
| 36 public: | 37 public: |
| 37 CallStatsTest() : fake_clock_(12345) {} | 38 CallStatsTest() : fake_clock_(12345) {} |
| 38 | 39 |
| 39 protected: | 40 protected: |
| 40 virtual void SetUp() { call_stats_.reset(new CallStats(&fake_clock_)); } | 41 virtual void SetUp() { call_stats_.reset(new CallStats(&fake_clock_)); } |
| 41 SimulatedClock fake_clock_; | 42 SimulatedClock fake_clock_; |
| 42 rtc::scoped_ptr<CallStats> call_stats_; | 43 std::unique_ptr<CallStats> call_stats_; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 TEST_F(CallStatsTest, AddAndTriggerCallback) { | 46 TEST_F(CallStatsTest, AddAndTriggerCallback) { |
| 46 MockStatsObserver stats_observer; | 47 MockStatsObserver stats_observer; |
| 47 RtcpRttStats* rtcp_rtt_stats = call_stats_->rtcp_rtt_stats(); | 48 RtcpRttStats* rtcp_rtt_stats = call_stats_->rtcp_rtt_stats(); |
| 48 call_stats_->RegisterStatsObserver(&stats_observer); | 49 call_stats_->RegisterStatsObserver(&stats_observer); |
| 49 fake_clock_.AdvanceTimeMilliseconds(1000); | 50 fake_clock_.AdvanceTimeMilliseconds(1000); |
| 50 EXPECT_EQ(-1, rtcp_rtt_stats->LastProcessedRtt()); | 51 EXPECT_EQ(-1, rtcp_rtt_stats->LastProcessedRtt()); |
| 51 | 52 |
| 52 const int64_t kRtt = 25; | 53 const int64_t kRtt = 25; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 call_stats_->Process(); | 213 call_stats_->Process(); |
| 213 call_stats_.reset(); | 214 call_stats_.reset(); |
| 214 | 215 |
| 215 EXPECT_EQ(1, test::NumHistogramSamples( | 216 EXPECT_EQ(1, test::NumHistogramSamples( |
| 216 "WebRTC.Video.AverageRoundTripTimeInMilliseconds")); | 217 "WebRTC.Video.AverageRoundTripTimeInMilliseconds")); |
| 217 EXPECT_EQ(kRtt, test::LastHistogramSample( | 218 EXPECT_EQ(kRtt, test::LastHistogramSample( |
| 218 "WebRTC.Video.AverageRoundTripTimeInMilliseconds")); | 219 "WebRTC.Video.AverageRoundTripTimeInMilliseconds")); |
| 219 } | 220 } |
| 220 | 221 |
| 221 } // namespace webrtc | 222 } // namespace webrtc |
| OLD | NEW |