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

Side by Side Diff: webrtc/stats/rtcstatscollector_unittest.cc

Issue 2290203002: Delete Timing class, timing.h, and update all users. (Closed)
Patch Set: Rename to rtc::TimeUTCMicros, and use it. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 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 "webrtc/stats/rtcstatscollector.h" 11 #include "webrtc/stats/rtcstatscollector.h"
12 12
13 #include <memory> 13 #include <memory>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/api/jsepsessiondescription.h" 17 #include "webrtc/api/jsepsessiondescription.h"
18 #include "webrtc/api/rtcstats_objects.h" 18 #include "webrtc/api/rtcstats_objects.h"
19 #include "webrtc/api/rtcstatsreport.h" 19 #include "webrtc/api/rtcstatsreport.h"
20 #include "webrtc/api/test/mock_datachannel.h" 20 #include "webrtc/api/test/mock_datachannel.h"
21 #include "webrtc/api/test/mock_peerconnection.h" 21 #include "webrtc/api/test/mock_peerconnection.h"
22 #include "webrtc/api/test/mock_webrtcsession.h" 22 #include "webrtc/api/test/mock_webrtcsession.h"
23 #include "webrtc/base/checks.h" 23 #include "webrtc/base/checks.h"
24 #include "webrtc/base/fakeclock.h" 24 #include "webrtc/base/fakeclock.h"
25 #include "webrtc/base/gunit.h" 25 #include "webrtc/base/gunit.h"
26 #include "webrtc/base/logging.h" 26 #include "webrtc/base/logging.h"
27 #include "webrtc/base/timedelta.h" 27 #include "webrtc/base/timedelta.h"
28 #include "webrtc/base/timeutils.h" 28 #include "webrtc/base/timeutils.h"
29 #include "webrtc/base/timing.h"
30 #include "webrtc/media/base/fakemediaengine.h" 29 #include "webrtc/media/base/fakemediaengine.h"
31 30
32 using testing::Return; 31 using testing::Return;
33 using testing::ReturnRef; 32 using testing::ReturnRef;
34 33
35 namespace webrtc { 34 namespace webrtc {
36 35
37 class RTCStatsCollectorTester : public SetSessionDescriptionObserver { 36 class RTCStatsCollectorTester : public SetSessionDescriptionObserver {
38 public: 37 public:
39 RTCStatsCollectorTester() 38 RTCStatsCollectorTester()
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 EXPECT_TRUE(c); 101 EXPECT_TRUE(c);
103 EXPECT_NE(b.get(), c.get()); 102 EXPECT_NE(b.get(), c.get());
104 // Invalidate cache by advancing time. 103 // Invalidate cache by advancing time.
105 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(51)); 104 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(51));
106 rtc::scoped_refptr<const RTCStatsReport> d = collector_.GetStatsReport(); 105 rtc::scoped_refptr<const RTCStatsReport> d = collector_.GetStatsReport();
107 EXPECT_TRUE(d); 106 EXPECT_TRUE(d);
108 EXPECT_NE(c.get(), d.get()); 107 EXPECT_NE(c.get(), d.get());
109 } 108 }
110 109
111 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { 110 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) {
112 int64_t before = static_cast<int64_t>( 111 int64_t before = rtc::TimeUTCMicros();
113 rtc::Timing::WallTimeNow() * rtc::kNumMicrosecsPerSec);
114 rtc::scoped_refptr<const RTCStatsReport> report = collector_.GetStatsReport(); 112 rtc::scoped_refptr<const RTCStatsReport> report = collector_.GetStatsReport();
115 int64_t after = static_cast<int64_t>( 113 int64_t after = rtc::TimeUTCMicros();
116 rtc::Timing::WallTimeNow() * rtc::kNumMicrosecsPerSec);
117 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), 114 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(),
118 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; 115 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats.";
119 const RTCStats* stats = report->Get("RTCPeerConnection"); 116 const RTCStats* stats = report->Get("RTCPeerConnection");
120 EXPECT_TRUE(stats); 117 EXPECT_TRUE(stats);
121 EXPECT_LE(before, stats->timestamp_us()); 118 EXPECT_LE(before, stats->timestamp_us());
122 EXPECT_LE(stats->timestamp_us(), after); 119 EXPECT_LE(stats->timestamp_us(), after);
123 { 120 {
124 // Expected stats with no data channels 121 // Expected stats with no data channels
125 const RTCPeerConnectionStats& pcstats = 122 const RTCPeerConnectionStats& pcstats =
126 stats->cast_to<RTCPeerConnectionStats>(); 123 stats->cast_to<RTCPeerConnectionStats>();
(...skipping 23 matching lines...) Expand all
150 // open/closed, we would expect opened >= closed and (opened - closed) to be 147 // open/closed, we would expect opened >= closed and (opened - closed) to be
151 // the number currently open. crbug.com/636818. 148 // the number currently open. crbug.com/636818.
152 const RTCPeerConnectionStats& pcstats = 149 const RTCPeerConnectionStats& pcstats =
153 stats->cast_to<RTCPeerConnectionStats>(); 150 stats->cast_to<RTCPeerConnectionStats>();
154 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); 151 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1));
155 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); 152 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3));
156 } 153 }
157 } 154 }
158 155
159 } // namespace webrtc 156 } // namespace webrtc
OLDNEW
« webrtc/media/base/rtpdataengine_unittest.cc ('K') | « webrtc/stats/rtcstatscollector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698