| 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/stats/rtcstats.h" | 11 #include "webrtc/api/stats/rtcstats.h" |
| 12 | 12 |
| 13 #include <cstring> | 13 #include <cstring> |
| 14 | 14 |
| 15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/base/gunit.h" | 16 #include "webrtc/base/gunit.h" |
| 17 #include "webrtc/stats/test/rtcteststats.h" |
| 17 | 18 |
| 18 namespace webrtc { | 19 namespace webrtc { |
| 19 | 20 |
| 20 class RTCTestStats : public RTCStats { | |
| 21 public: | |
| 22 RTCTestStats(const std::string& id, int64_t timestamp_us) | |
| 23 : RTCStats(id, timestamp_us), | |
| 24 m_int32("mInt32"), | |
| 25 m_uint32("mUint32"), | |
| 26 m_int64("mInt64"), | |
| 27 m_uint64("mUint64"), | |
| 28 m_double("mDouble"), | |
| 29 m_string("mString"), | |
| 30 m_sequence_int32("mSequenceInt32"), | |
| 31 m_sequence_uint32("mSequenceUint32"), | |
| 32 m_sequence_int64("mSequenceInt64"), | |
| 33 m_sequence_uint64("mSequenceUint64"), | |
| 34 m_sequence_double("mSequenceDouble"), | |
| 35 m_sequence_string("mSequenceString") { | |
| 36 } | |
| 37 | |
| 38 WEBRTC_RTCSTATS_IMPL(RTCStats, RTCTestStats, | |
| 39 &m_int32, | |
| 40 &m_uint32, | |
| 41 &m_int64, | |
| 42 &m_uint64, | |
| 43 &m_double, | |
| 44 &m_string, | |
| 45 &m_sequence_int32, | |
| 46 &m_sequence_uint32, | |
| 47 &m_sequence_int64, | |
| 48 &m_sequence_uint64, | |
| 49 &m_sequence_double, | |
| 50 &m_sequence_string); | |
| 51 | |
| 52 RTCStatsMember<int32_t> m_int32; | |
| 53 RTCStatsMember<uint32_t> m_uint32; | |
| 54 RTCStatsMember<int64_t> m_int64; | |
| 55 RTCStatsMember<uint64_t> m_uint64; | |
| 56 RTCStatsMember<double> m_double; | |
| 57 RTCStatsMember<std::string> m_string; | |
| 58 | |
| 59 RTCStatsMember<std::vector<int32_t>> m_sequence_int32; | |
| 60 RTCStatsMember<std::vector<uint32_t>> m_sequence_uint32; | |
| 61 RTCStatsMember<std::vector<int64_t>> m_sequence_int64; | |
| 62 RTCStatsMember<std::vector<uint64_t>> m_sequence_uint64; | |
| 63 RTCStatsMember<std::vector<double>> m_sequence_double; | |
| 64 RTCStatsMember<std::vector<std::string>> m_sequence_string; | |
| 65 }; | |
| 66 | |
| 67 const char RTCTestStats::kType[] = "test-stats"; | |
| 68 | |
| 69 class RTCChildStats : public RTCStats { | 21 class RTCChildStats : public RTCStats { |
| 70 public: | 22 public: |
| 71 RTCChildStats(const std::string& id, int64_t timestamp_us) | 23 RTCChildStats(const std::string& id, int64_t timestamp_us) |
| 72 : RTCStats(id, timestamp_us), | 24 : RTCStats(id, timestamp_us), |
| 73 child_int("childInt") {} | 25 child_int("childInt") {} |
| 74 | 26 |
| 75 WEBRTC_RTCSTATS_IMPL(RTCStats, RTCChildStats, | 27 WEBRTC_RTCSTATS_IMPL(RTCStats, RTCChildStats, |
| 76 &child_int); | 28 &child_int); |
| 77 | 29 |
| 78 RTCStatsMember<int32_t> child_int; | 30 RTCStatsMember<int32_t> child_int; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 135 } |
| 184 | 136 |
| 185 TEST(RTCStatsDeathTest, InvalidCasting) { | 137 TEST(RTCStatsDeathTest, InvalidCasting) { |
| 186 RTCGrandChildStats stats("grandchild", 0.0); | 138 RTCGrandChildStats stats("grandchild", 0.0); |
| 187 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); | 139 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); |
| 188 } | 140 } |
| 189 | 141 |
| 190 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 142 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 191 | 143 |
| 192 } // namespace webrtc | 144 } // namespace webrtc |
| OLD | NEW |