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

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

Issue 2299643002: RTCStatsCollector: timestamps updated. (Closed)
Patch Set: uint64_t -> int64_t timestamps 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
« no previous file with comments | « webrtc/stats/rtcstats_objects.cc ('k') | webrtc/stats/rtcstatscollector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/api/rtcstats.h" 11 #include "webrtc/api/rtcstats.h"
12 12
13 #include "webrtc/base/checks.h" 13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/gunit.h" 14 #include "webrtc/base/gunit.h"
15 15
16 namespace webrtc { 16 namespace webrtc {
17 17
18 class RTCTestStats : public RTCStats { 18 class RTCTestStats : public RTCStats {
19 public: 19 public:
20 RTCTestStats(const std::string& id, double timestamp) 20 RTCTestStats(const std::string& id, int64_t timestamp_us)
21 : RTCStats(id, timestamp), 21 : RTCStats(id, timestamp_us),
22 m_int32("mInt32"), 22 m_int32("mInt32"),
23 m_uint32("mUint32"), 23 m_uint32("mUint32"),
24 m_int64("mInt64"), 24 m_int64("mInt64"),
25 m_uint64("mUint64"), 25 m_uint64("mUint64"),
26 m_double("mDouble"), 26 m_double("mDouble"),
27 m_static_string("mStaticString"), 27 m_static_string("mStaticString"),
28 m_string("mString"), 28 m_string("mString"),
29 m_sequence_int32("mSequenceInt32"), 29 m_sequence_int32("mSequenceInt32"),
30 m_sequence_uint32("mSequenceUint32"), 30 m_sequence_uint32("mSequenceUint32"),
31 m_sequence_int64("mSequenceInt64"), 31 m_sequence_int64("mSequenceInt64"),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 RTCStatsMember<std::vector<uint64_t>> m_sequence_uint64; 65 RTCStatsMember<std::vector<uint64_t>> m_sequence_uint64;
66 RTCStatsMember<std::vector<double>> m_sequence_double; 66 RTCStatsMember<std::vector<double>> m_sequence_double;
67 RTCStatsMember<std::vector<const char*>> m_sequence_static_string; 67 RTCStatsMember<std::vector<const char*>> m_sequence_static_string;
68 RTCStatsMember<std::vector<std::string>> m_sequence_string; 68 RTCStatsMember<std::vector<std::string>> m_sequence_string;
69 }; 69 };
70 70
71 const char RTCTestStats::kType[] = "test-stats"; 71 const char RTCTestStats::kType[] = "test-stats";
72 72
73 class RTCChildStats : public RTCStats { 73 class RTCChildStats : public RTCStats {
74 public: 74 public:
75 RTCChildStats(const std::string& id, double timestamp) 75 RTCChildStats(const std::string& id, int64_t timestamp_us)
76 : RTCStats(id, timestamp), 76 : RTCStats(id, timestamp_us),
77 child_int("childInt") {} 77 child_int("childInt") {}
78 78
79 WEBRTC_RTCSTATS_IMPL(RTCStats, RTCChildStats, 79 WEBRTC_RTCSTATS_IMPL(RTCStats, RTCChildStats,
80 &child_int); 80 &child_int);
81 81
82 RTCStatsMember<int32_t> child_int; 82 RTCStatsMember<int32_t> child_int;
83 }; 83 };
84 84
85 const char RTCChildStats::kType[] = "child-stats"; 85 const char RTCChildStats::kType[] = "child-stats";
86 86
87 class RTCGrandChildStats : public RTCChildStats { 87 class RTCGrandChildStats : public RTCChildStats {
88 public: 88 public:
89 RTCGrandChildStats(const std::string& id, double timestamp) 89 RTCGrandChildStats(const std::string& id, int64_t timestamp_us)
90 : RTCChildStats(id, timestamp), 90 : RTCChildStats(id, timestamp_us),
91 grandchild_int("grandchildInt") {} 91 grandchild_int("grandchildInt") {}
92 92
93 WEBRTC_RTCSTATS_IMPL(RTCChildStats, RTCGrandChildStats, 93 WEBRTC_RTCSTATS_IMPL(RTCChildStats, RTCGrandChildStats,
94 &grandchild_int); 94 &grandchild_int);
95 95
96 RTCStatsMember<int32_t> grandchild_int; 96 RTCStatsMember<int32_t> grandchild_int;
97 }; 97 };
98 98
99 const char RTCGrandChildStats::kType[] = "grandchild-stats"; 99 const char RTCGrandChildStats::kType[] = "grandchild-stats";
100 100
101 TEST(RTCStatsTest, RTCStatsAndMembers) { 101 TEST(RTCStatsTest, RTCStatsAndMembers) {
102 RTCTestStats stats("testId", 42.0); 102 RTCTestStats stats("testId", 42);
103 EXPECT_EQ(stats.id(), "testId"); 103 EXPECT_EQ(stats.id(), "testId");
104 EXPECT_EQ(stats.timestamp(), 42.0); 104 EXPECT_EQ(stats.timestamp_us(), static_cast<int64_t>(42));
105 std::vector<const RTCStatsMemberInterface*> members = stats.Members(); 105 std::vector<const RTCStatsMemberInterface*> members = stats.Members();
106 EXPECT_EQ(members.size(), static_cast<size_t>(14)); 106 EXPECT_EQ(members.size(), static_cast<size_t>(14));
107 for (const RTCStatsMemberInterface* member : members) { 107 for (const RTCStatsMemberInterface* member : members) {
108 EXPECT_FALSE(member->is_defined()); 108 EXPECT_FALSE(member->is_defined());
109 } 109 }
110 stats.m_int32 = 123; 110 stats.m_int32 = 123;
111 stats.m_uint32 = 123; 111 stats.m_uint32 = 123;
112 stats.m_int64 = 123; 112 stats.m_int64 = 123;
113 stats.m_uint64 = 123; 113 stats.m_uint64 = 123;
114 stats.m_double = 123.0; 114 stats.m_double = 123.0;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 176
177 TEST(RTCStatsDeathTest, InvalidCasting) { 177 TEST(RTCStatsDeathTest, InvalidCasting) {
178 RTCGrandChildStats stats("grandchild", 0.0); 178 RTCGrandChildStats stats("grandchild", 0.0);
179 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); 179 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), "");
180 } 180 }
181 181
182 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 182 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
183 183
184 } // namespace webrtc 184 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/stats/rtcstats_objects.cc ('k') | webrtc/stats/rtcstatscollector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698