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

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

Issue 2387343002: RTCStatsMember<bool> and RTCStatsMember<std::vector<bool>> added. (Closed)
Patch Set: Removed spaces between RTCStatsMember and variable name Created 4 years, 2 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.cc ('k') | webrtc/stats/test/rtcteststats.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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 RTCStatsMember<int32_t> grandchild_int; 44 RTCStatsMember<int32_t> grandchild_int;
45 }; 45 };
46 46
47 const char RTCGrandChildStats::kType[] = "grandchild-stats"; 47 const char RTCGrandChildStats::kType[] = "grandchild-stats";
48 48
49 TEST(RTCStatsTest, RTCStatsAndMembers) { 49 TEST(RTCStatsTest, RTCStatsAndMembers) {
50 RTCTestStats stats("testId", 42); 50 RTCTestStats stats("testId", 42);
51 EXPECT_EQ(stats.id(), "testId"); 51 EXPECT_EQ(stats.id(), "testId");
52 EXPECT_EQ(stats.timestamp_us(), static_cast<int64_t>(42)); 52 EXPECT_EQ(stats.timestamp_us(), static_cast<int64_t>(42));
53 std::vector<const RTCStatsMemberInterface*> members = stats.Members(); 53 std::vector<const RTCStatsMemberInterface*> members = stats.Members();
54 EXPECT_EQ(members.size(), static_cast<size_t>(12)); 54 EXPECT_EQ(members.size(), static_cast<size_t>(14));
55 for (const RTCStatsMemberInterface* member : members) { 55 for (const RTCStatsMemberInterface* member : members) {
56 EXPECT_FALSE(member->is_defined()); 56 EXPECT_FALSE(member->is_defined());
57 } 57 }
58 stats.m_bool = true;
58 stats.m_int32 = 123; 59 stats.m_int32 = 123;
59 stats.m_uint32 = 123; 60 stats.m_uint32 = 123;
60 stats.m_int64 = 123; 61 stats.m_int64 = 123;
61 stats.m_uint64 = 123; 62 stats.m_uint64 = 123;
62 stats.m_double = 123.0; 63 stats.m_double = 123.0;
63 stats.m_string = std::string("123"); 64 stats.m_string = std::string("123");
64 65
66 std::vector<bool> sequence_bool;
67 sequence_bool.push_back(true);
65 std::vector<int32_t> sequence_int32; 68 std::vector<int32_t> sequence_int32;
66 sequence_int32.push_back(static_cast<int32_t>(1)); 69 sequence_int32.push_back(static_cast<int32_t>(1));
67 std::vector<uint32_t> sequence_uint32; 70 std::vector<uint32_t> sequence_uint32;
68 sequence_uint32.push_back(static_cast<uint32_t>(2)); 71 sequence_uint32.push_back(static_cast<uint32_t>(2));
69 std::vector<int64_t> sequence_int64; 72 std::vector<int64_t> sequence_int64;
70 sequence_int64.push_back(static_cast<int64_t>(3)); 73 sequence_int64.push_back(static_cast<int64_t>(3));
71 std::vector<uint64_t> sequence_uint64; 74 std::vector<uint64_t> sequence_uint64;
72 sequence_uint64.push_back(static_cast<uint64_t>(4)); 75 sequence_uint64.push_back(static_cast<uint64_t>(4));
73 std::vector<double> sequence_double; 76 std::vector<double> sequence_double;
74 sequence_double.push_back(5.0); 77 sequence_double.push_back(5.0);
75 std::vector<std::string> sequence_string; 78 std::vector<std::string> sequence_string;
76 sequence_string.push_back(std::string("six")); 79 sequence_string.push_back(std::string("six"));
77 80
81 stats.m_sequence_bool = sequence_bool;
78 stats.m_sequence_int32 = sequence_int32; 82 stats.m_sequence_int32 = sequence_int32;
79 stats.m_sequence_uint32 = sequence_uint32; 83 stats.m_sequence_uint32 = sequence_uint32;
80 EXPECT_FALSE(stats.m_sequence_int64.is_defined()); 84 EXPECT_FALSE(stats.m_sequence_int64.is_defined());
81 stats.m_sequence_int64 = sequence_int64; 85 stats.m_sequence_int64 = sequence_int64;
82 stats.m_sequence_uint64 = sequence_uint64; 86 stats.m_sequence_uint64 = sequence_uint64;
83 stats.m_sequence_double = sequence_double; 87 stats.m_sequence_double = sequence_double;
84 stats.m_sequence_string = sequence_string; 88 stats.m_sequence_string = sequence_string;
85 for (const RTCStatsMemberInterface* member : members) { 89 for (const RTCStatsMemberInterface* member : members) {
86 EXPECT_TRUE(member->is_defined()); 90 EXPECT_TRUE(member->is_defined());
87 } 91 }
92 EXPECT_EQ(*stats.m_bool, true);
88 EXPECT_EQ(*stats.m_int32, static_cast<int32_t>(123)); 93 EXPECT_EQ(*stats.m_int32, static_cast<int32_t>(123));
89 EXPECT_EQ(*stats.m_uint32, static_cast<uint32_t>(123)); 94 EXPECT_EQ(*stats.m_uint32, static_cast<uint32_t>(123));
90 EXPECT_EQ(*stats.m_int64, static_cast<int64_t>(123)); 95 EXPECT_EQ(*stats.m_int64, static_cast<int64_t>(123));
91 EXPECT_EQ(*stats.m_uint64, static_cast<uint64_t>(123)); 96 EXPECT_EQ(*stats.m_uint64, static_cast<uint64_t>(123));
92 EXPECT_EQ(*stats.m_double, 123.0); 97 EXPECT_EQ(*stats.m_double, 123.0);
93 EXPECT_EQ(*stats.m_string, std::string("123")); 98 EXPECT_EQ(*stats.m_string, std::string("123"));
99 EXPECT_EQ(*stats.m_sequence_bool, sequence_bool);
94 EXPECT_EQ(*stats.m_sequence_int32, sequence_int32); 100 EXPECT_EQ(*stats.m_sequence_int32, sequence_int32);
95 EXPECT_EQ(*stats.m_sequence_uint32, sequence_uint32); 101 EXPECT_EQ(*stats.m_sequence_uint32, sequence_uint32);
96 EXPECT_EQ(*stats.m_sequence_int64, sequence_int64); 102 EXPECT_EQ(*stats.m_sequence_int64, sequence_int64);
97 EXPECT_EQ(*stats.m_sequence_uint64, sequence_uint64); 103 EXPECT_EQ(*stats.m_sequence_uint64, sequence_uint64);
98 EXPECT_EQ(*stats.m_sequence_double, sequence_double); 104 EXPECT_EQ(*stats.m_sequence_double, sequence_double);
99 EXPECT_EQ(*stats.m_sequence_string, sequence_string); 105 EXPECT_EQ(*stats.m_sequence_string, sequence_string);
100 106
101 int32_t numbers[] = { 4, 8, 15, 16, 23, 42 }; 107 int32_t numbers[] = { 4, 8, 15, 16, 23, 42 };
102 std::vector<int32_t> numbers_sequence(&numbers[0], &numbers[6]); 108 std::vector<int32_t> numbers_sequence(&numbers[0], &numbers[6]);
103 stats.m_sequence_int32->clear(); 109 stats.m_sequence_int32->clear();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 141 }
136 142
137 TEST(RTCStatsDeathTest, InvalidCasting) { 143 TEST(RTCStatsDeathTest, InvalidCasting) {
138 RTCGrandChildStats stats("grandchild", 0.0); 144 RTCGrandChildStats stats("grandchild", 0.0);
139 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); 145 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), "");
140 } 146 }
141 147
142 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 148 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
143 149
144 } // namespace webrtc 150 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/stats/rtcstats.cc ('k') | webrtc/stats/test/rtcteststats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698