OLD | NEW |
---|---|
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 <cstring> | |
14 | |
13 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
14 #include "webrtc/base/gunit.h" | 16 #include "webrtc/base/gunit.h" |
15 | 17 |
16 namespace webrtc { | 18 namespace webrtc { |
17 | 19 |
18 class RTCTestStats : public RTCStats { | 20 class RTCTestStats : public RTCStats { |
19 public: | 21 public: |
20 RTCTestStats(const std::string& id, int64_t timestamp_us) | 22 RTCTestStats(const std::string& id, int64_t timestamp_us) |
21 : RTCStats(id, timestamp_us), | 23 : RTCStats(id, timestamp_us), |
22 m_int32("mInt32"), | 24 m_int32("mInt32"), |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 stats.m_sequence_static_string = std::vector<const char*>(); | 125 stats.m_sequence_static_string = std::vector<const char*>(); |
124 stats.m_sequence_string = std::vector<std::string>(); | 126 stats.m_sequence_string = std::vector<std::string>(); |
125 for (const RTCStatsMemberInterface* member : members) { | 127 for (const RTCStatsMemberInterface* member : members) { |
126 EXPECT_TRUE(member->is_defined()); | 128 EXPECT_TRUE(member->is_defined()); |
127 } | 129 } |
128 EXPECT_EQ(*stats.m_int32, static_cast<int32_t>(123)); | 130 EXPECT_EQ(*stats.m_int32, static_cast<int32_t>(123)); |
129 EXPECT_EQ(*stats.m_uint32, static_cast<uint32_t>(123)); | 131 EXPECT_EQ(*stats.m_uint32, static_cast<uint32_t>(123)); |
130 EXPECT_EQ(*stats.m_int64, static_cast<int64_t>(123)); | 132 EXPECT_EQ(*stats.m_int64, static_cast<int64_t>(123)); |
131 EXPECT_EQ(*stats.m_uint64, static_cast<uint64_t>(123)); | 133 EXPECT_EQ(*stats.m_uint64, static_cast<uint64_t>(123)); |
132 EXPECT_EQ(*stats.m_double, 123.0); | 134 EXPECT_EQ(*stats.m_double, 123.0); |
133 EXPECT_EQ(*stats.m_static_string, "123"); | 135 EXPECT_EQ(strcmp(*stats.m_static_string, "123"), 0); |
nisse-webrtc
2016/09/14 07:53:07
Makes me think: Do you really need stats using the
hbos
2016/09/14 08:21:15
I think you're right, having two different string
| |
134 EXPECT_EQ(*stats.m_string, std::string("123")); | 136 EXPECT_EQ(*stats.m_string, std::string("123")); |
135 EXPECT_EQ(*stats.m_sequence_int32, std::vector<int32_t>()); | 137 EXPECT_EQ(*stats.m_sequence_int32, std::vector<int32_t>()); |
136 EXPECT_EQ(*stats.m_sequence_uint32, std::vector<uint32_t>()); | 138 EXPECT_EQ(*stats.m_sequence_uint32, std::vector<uint32_t>()); |
137 EXPECT_EQ(*stats.m_sequence_int64, std::vector<int64_t>()); | 139 EXPECT_EQ(*stats.m_sequence_int64, std::vector<int64_t>()); |
138 EXPECT_EQ(*stats.m_sequence_uint64, std::vector<uint64_t>()); | 140 EXPECT_EQ(*stats.m_sequence_uint64, std::vector<uint64_t>()); |
139 EXPECT_EQ(*stats.m_sequence_double, std::vector<double>()); | 141 EXPECT_EQ(*stats.m_sequence_double, std::vector<double>()); |
140 EXPECT_EQ(*stats.m_sequence_static_string, std::vector<const char*>()); | 142 EXPECT_EQ(*stats.m_sequence_static_string, std::vector<const char*>()); |
nisse-webrtc
2016/09/14 07:53:07
Can you change to non-empty sequences for all thes
hbos
2016/09/14 08:21:15
Done.
nisse-webrtc
2016/09/14 08:36:42
Not all, could you add a unique value each also to
hbos
2016/09/14 09:42:48
Oh right, done.
| |
141 EXPECT_EQ(*stats.m_sequence_string, std::vector<std::string>()); | 143 EXPECT_EQ(*stats.m_sequence_string, std::vector<std::string>()); |
142 int32_t numbers[] = { 4, 8, 15, 16, 23, 42 }; | 144 int32_t numbers[] = { 4, 8, 15, 16, 23, 42 }; |
143 std::vector<int32_t> numbers_sequence(&numbers[0], &numbers[5]); | 145 std::vector<int32_t> numbers_sequence(&numbers[0], &numbers[5]); |
144 stats.m_sequence_int32->insert(stats.m_sequence_int32->end(), | 146 stats.m_sequence_int32->insert(stats.m_sequence_int32->end(), |
145 numbers_sequence.begin(), | 147 numbers_sequence.begin(), |
146 numbers_sequence.end()); | 148 numbers_sequence.end()); |
147 EXPECT_EQ(*stats.m_sequence_int32, numbers_sequence); | 149 EXPECT_EQ(*stats.m_sequence_int32, numbers_sequence); |
148 } | 150 } |
149 | 151 |
150 TEST(RTCStatsTest, RTCStatsGrandChild) { | 152 TEST(RTCStatsTest, RTCStatsGrandChild) { |
(...skipping 24 matching lines...) Expand all Loading... | |
175 } | 177 } |
176 | 178 |
177 TEST(RTCStatsDeathTest, InvalidCasting) { | 179 TEST(RTCStatsDeathTest, InvalidCasting) { |
178 RTCGrandChildStats stats("grandchild", 0.0); | 180 RTCGrandChildStats stats("grandchild", 0.0); |
179 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); | 181 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); |
180 } | 182 } |
181 | 183 |
182 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 184 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
183 | 185 |
184 } // namespace webrtc | 186 } // namespace webrtc |
OLD | NEW |