summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/stats/rtc_stats_unittest.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /third_party/libwebrtc/stats/rtc_stats_unittest.cc
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/stats/rtc_stats_unittest.cc')
-rw-r--r--third_party/libwebrtc/stats/rtc_stats_unittest.cc101
1 files changed, 37 insertions, 64 deletions
diff --git a/third_party/libwebrtc/stats/rtc_stats_unittest.cc b/third_party/libwebrtc/stats/rtc_stats_unittest.cc
index fd90692875..555360f07f 100644
--- a/third_party/libwebrtc/stats/rtc_stats_unittest.cc
+++ b/third_party/libwebrtc/stats/rtc_stats_unittest.cc
@@ -15,6 +15,7 @@
#include <cstring>
#include <iostream>
+#include "absl/types/optional.h"
#include "rtc_base/checks.h"
#include "rtc_base/strings/json.h"
#include "stats/test/rtc_test_stats.h"
@@ -46,7 +47,7 @@ class RTCChildStats : public RTCStats {
RTCChildStats(const std::string& id, Timestamp timestamp)
: RTCStats(id, timestamp) {}
- RTCStatsMember<int32_t> child_int;
+ absl::optional<int32_t> child_int;
};
WEBRTC_RTCSTATS_IMPL(RTCChildStats,
@@ -61,7 +62,7 @@ class RTCGrandChildStats : public RTCChildStats {
RTCGrandChildStats(const std::string& id, Timestamp timestamp)
: RTCChildStats(id, timestamp) {}
- RTCStatsMember<int32_t> grandchild_int;
+ absl::optional<int32_t> grandchild_int;
};
WEBRTC_RTCSTATS_IMPL(RTCGrandChildStats,
@@ -166,7 +167,8 @@ TEST(RTCStatsTest, EqualityOperator) {
stats_with_all_values.m_map_string_double = std::map<std::string, double>();
EXPECT_NE(stats_with_all_values, empty_stats);
EXPECT_EQ(stats_with_all_values, stats_with_all_values);
- EXPECT_NE(stats_with_all_values.m_int32, stats_with_all_values.m_uint32);
+ EXPECT_NE(stats_with_all_values.GetAttribute(stats_with_all_values.m_int32),
+ stats_with_all_values.GetAttribute(stats_with_all_values.m_uint32));
RTCTestStats one_member_different[] = {
stats_with_all_values, stats_with_all_values, stats_with_all_values,
@@ -392,71 +394,42 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) {
TEST(RTCStatsTest, IsSequence) {
RTCTestStats stats("statsId", Timestamp::Micros(42));
- EXPECT_FALSE(stats.m_bool.is_sequence());
- EXPECT_FALSE(stats.m_int32.is_sequence());
- EXPECT_FALSE(stats.m_uint32.is_sequence());
- EXPECT_FALSE(stats.m_int64.is_sequence());
- EXPECT_FALSE(stats.m_uint64.is_sequence());
- EXPECT_FALSE(stats.m_double.is_sequence());
- EXPECT_FALSE(stats.m_string.is_sequence());
- EXPECT_TRUE(stats.m_sequence_bool.is_sequence());
- EXPECT_TRUE(stats.m_sequence_int32.is_sequence());
- EXPECT_TRUE(stats.m_sequence_uint32.is_sequence());
- EXPECT_TRUE(stats.m_sequence_int64.is_sequence());
- EXPECT_TRUE(stats.m_sequence_uint64.is_sequence());
- EXPECT_TRUE(stats.m_sequence_double.is_sequence());
- EXPECT_TRUE(stats.m_sequence_string.is_sequence());
- EXPECT_FALSE(stats.m_map_string_uint64.is_sequence());
- EXPECT_FALSE(stats.m_map_string_double.is_sequence());
-}
-
-TEST(RTCStatsTest, Type) {
- RTCTestStats stats("statsId", Timestamp::Micros(42));
- EXPECT_EQ(RTCStatsMemberInterface::kBool, stats.m_bool.type());
- EXPECT_EQ(RTCStatsMemberInterface::kInt32, stats.m_int32.type());
- EXPECT_EQ(RTCStatsMemberInterface::kUint32, stats.m_uint32.type());
- EXPECT_EQ(RTCStatsMemberInterface::kInt64, stats.m_int64.type());
- EXPECT_EQ(RTCStatsMemberInterface::kUint64, stats.m_uint64.type());
- EXPECT_EQ(RTCStatsMemberInterface::kDouble, stats.m_double.type());
- EXPECT_EQ(RTCStatsMemberInterface::kString, stats.m_string.type());
- EXPECT_EQ(RTCStatsMemberInterface::kSequenceBool,
- stats.m_sequence_bool.type());
- EXPECT_EQ(RTCStatsMemberInterface::kSequenceInt32,
- stats.m_sequence_int32.type());
- EXPECT_EQ(RTCStatsMemberInterface::kSequenceUint32,
- stats.m_sequence_uint32.type());
- EXPECT_EQ(RTCStatsMemberInterface::kSequenceInt64,
- stats.m_sequence_int64.type());
- EXPECT_EQ(RTCStatsMemberInterface::kSequenceUint64,
- stats.m_sequence_uint64.type());
- EXPECT_EQ(RTCStatsMemberInterface::kSequenceDouble,
- stats.m_sequence_double.type());
- EXPECT_EQ(RTCStatsMemberInterface::kSequenceString,
- stats.m_sequence_string.type());
- EXPECT_EQ(RTCStatsMemberInterface::kMapStringUint64,
- stats.m_map_string_uint64.type());
- EXPECT_EQ(RTCStatsMemberInterface::kMapStringDouble,
- stats.m_map_string_double.type());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_bool).is_sequence());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_int32).is_sequence());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_uint32).is_sequence());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_int64).is_sequence());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_uint64).is_sequence());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_double).is_sequence());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_string).is_sequence());
+ EXPECT_TRUE(stats.GetAttribute(stats.m_sequence_bool).is_sequence());
+ EXPECT_TRUE(stats.GetAttribute(stats.m_sequence_int32).is_sequence());
+ EXPECT_TRUE(stats.GetAttribute(stats.m_sequence_uint32).is_sequence());
+ EXPECT_TRUE(stats.GetAttribute(stats.m_sequence_int64).is_sequence());
+ EXPECT_TRUE(stats.GetAttribute(stats.m_sequence_uint64).is_sequence());
+ EXPECT_TRUE(stats.GetAttribute(stats.m_sequence_double).is_sequence());
+ EXPECT_TRUE(stats.GetAttribute(stats.m_sequence_string).is_sequence());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_map_string_uint64).is_sequence());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_map_string_double).is_sequence());
}
TEST(RTCStatsTest, IsString) {
RTCTestStats stats("statsId", Timestamp::Micros(42));
- EXPECT_TRUE(stats.m_string.is_string());
- EXPECT_FALSE(stats.m_bool.is_string());
- EXPECT_FALSE(stats.m_int32.is_string());
- EXPECT_FALSE(stats.m_uint32.is_string());
- EXPECT_FALSE(stats.m_int64.is_string());
- EXPECT_FALSE(stats.m_uint64.is_string());
- EXPECT_FALSE(stats.m_double.is_string());
- EXPECT_FALSE(stats.m_sequence_bool.is_string());
- EXPECT_FALSE(stats.m_sequence_int32.is_string());
- EXPECT_FALSE(stats.m_sequence_uint32.is_string());
- EXPECT_FALSE(stats.m_sequence_int64.is_string());
- EXPECT_FALSE(stats.m_sequence_uint64.is_string());
- EXPECT_FALSE(stats.m_sequence_double.is_string());
- EXPECT_FALSE(stats.m_sequence_string.is_string());
- EXPECT_FALSE(stats.m_map_string_uint64.is_string());
- EXPECT_FALSE(stats.m_map_string_double.is_string());
+ EXPECT_TRUE(stats.GetAttribute(stats.m_string).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_bool).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_int32).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_uint32).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_int64).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_uint64).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_double).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_sequence_bool).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_sequence_int32).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_sequence_uint32).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_sequence_int64).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_sequence_uint64).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_sequence_double).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_sequence_string).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_map_string_uint64).is_string());
+ EXPECT_FALSE(stats.GetAttribute(stats.m_map_string_double).is_string());
}
TEST(RTCStatsTest, AttributeToString) {