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

Side by Side Diff: webrtc/api/rtcstats_integrationtest.cc

Issue 2593623002: Improve rtcstats_integrationtest.cc by sanity checking values. (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | 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 <functional>
11 #include <set> 12 #include <set>
12 #include <vector> 13 #include <vector>
13 14
14 #include "webrtc/api/datachannelinterface.h" 15 #include "webrtc/api/datachannelinterface.h"
15 #include "webrtc/api/peerconnectioninterface.h" 16 #include "webrtc/api/peerconnectioninterface.h"
16 #include "webrtc/api/stats/rtcstats_objects.h" 17 #include "webrtc/api/stats/rtcstats_objects.h"
17 #include "webrtc/api/stats/rtcstatsreport.h" 18 #include "webrtc/api/stats/rtcstatsreport.h"
18 #include "webrtc/api/test/peerconnectiontestwrapper.h" 19 #include "webrtc/api/test/peerconnectiontestwrapper.h"
19 #include "webrtc/api/test/rtcstatsobtainer.h" 20 #include "webrtc/api/test/rtcstatsobtainer.h"
20 #include "webrtc/base/checks.h" 21 #include "webrtc/base/checks.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 115 }
115 116
116 void MarkMemberTested( 117 void MarkMemberTested(
117 const RTCStatsMemberInterface& member, bool test_successful) { 118 const RTCStatsMemberInterface& member, bool test_successful) {
118 untested_members_.erase(&member); 119 untested_members_.erase(&member);
119 all_tests_successful_ &= test_successful; 120 all_tests_successful_ &= test_successful;
120 } 121 }
121 122
122 void TestMemberIsDefined(const RTCStatsMemberInterface& member) { 123 void TestMemberIsDefined(const RTCStatsMemberInterface& member) {
123 EXPECT_TRUE(member.is_defined()) << 124 EXPECT_TRUE(member.is_defined()) <<
124 stats_->type() << "." << member.name() << "[" << stats_->id() << 125 stats_->type() << "." << member.name() << "[" << stats_->id() <<
125 "] was undefined."; 126 "] was undefined.";
126 MarkMemberTested(member, member.is_defined()); 127 MarkMemberTested(member, member.is_defined());
127 } 128 }
128 129
129 void TestMemberIsUndefined(const RTCStatsMemberInterface& member) { 130 void TestMemberIsUndefined(const RTCStatsMemberInterface& member) {
130 EXPECT_FALSE(member.is_defined()) << 131 EXPECT_FALSE(member.is_defined()) <<
131 stats_->type() << "." << member.name() << "[" << stats_->id() << 132 stats_->type() << "." << member.name() << "[" << stats_->id() <<
132 "] was defined (" << member.ValueToString() << ")."; 133 "] was defined (" << member.ValueToString() << ").";
133 MarkMemberTested(member, !member.is_defined()); 134 MarkMemberTested(member, !member.is_defined());
134 } 135 }
135 136
137 void TestMemberIsPositive(const RTCStatsMemberInterface& member) {
138 TestMemberSign(member, "positive", [](int sign) { return sign == 1; });
hta-webrtc 2016/12/20 15:19:18 This seems like a huge amount of machinery for say
hbos 2016/12/21 10:41:14 Not quite, I have to do MarkMemberTested and EXPEC
139 }
140
141 void TestMemberIsNonNegative(const RTCStatsMemberInterface& member) {
142 TestMemberSign(member, "non-negative", [](int sign) { return sign >= 0; });
143 }
144
136 void TestMemberIsIDReference( 145 void TestMemberIsIDReference(
137 const RTCStatsMemberInterface& member, 146 const RTCStatsMemberInterface& member,
138 const char* expected_type) { 147 const char* expected_type) {
139 TestMemberIsIDReference(member, expected_type, false); 148 TestMemberIsIDReference(member, expected_type, false);
140 } 149 }
141 150
142 void TestMemberIsOptionalIDReference( 151 void TestMemberIsOptionalIDReference(
143 const RTCStatsMemberInterface& member, 152 const RTCStatsMemberInterface& member,
144 const char* expected_type) { 153 const char* expected_type) {
145 TestMemberIsIDReference(member, expected_type, true); 154 TestMemberIsIDReference(member, expected_type, true);
146 } 155 }
147 156
148 bool ExpectAllMembersSuccessfullyTested() { 157 bool ExpectAllMembersSuccessfullyTested() {
149 if (untested_members_.empty()) 158 if (untested_members_.empty())
150 return all_tests_successful_; 159 return all_tests_successful_;
151 for (const RTCStatsMemberInterface* member : untested_members_) { 160 for (const RTCStatsMemberInterface* member : untested_members_) {
152 EXPECT_TRUE(false) << 161 EXPECT_TRUE(false) <<
153 stats_->type() << "." << member->name() << "[" << stats_->id() << 162 stats_->type() << "." << member->name() << "[" << stats_->id() <<
154 "] was not tested."; 163 "] was not tested.";
155 } 164 }
156 return false; 165 return false;
157 } 166 }
158 167
159 private: 168 private:
169 void TestMemberSign(const RTCStatsMemberInterface& member,
170 const char* sign_requirement,
171 std::function<bool(int)> sign_check) {
172 EXPECT_TRUE(member.is_defined()) <<
173 stats_->type() << "." << member.name() << "[" << stats_->id() <<
174 "] was undefined.";
175 if (!member.is_defined()) {
176 MarkMemberTested(member, false);
177 return;
178 }
179 rtc::Optional<int> sign;
180 switch (member.type()) {
181 case RTCStatsMemberInterface::kInt32:
182 sign = rtc::Optional<int>(Sign(
183 **static_cast<const RTCStatsMember<int32_t>*>(&member)));
184 break;
185 case RTCStatsMemberInterface::kUint32:
186 sign = rtc::Optional<int>(Sign(
187 **static_cast<const RTCStatsMember<uint32_t>*>(&member)));
188 break;
189 case RTCStatsMemberInterface::kInt64:
190 sign = rtc::Optional<int>(Sign(
191 **static_cast<const RTCStatsMember<int64_t>*>(&member)));
192 break;
193 case RTCStatsMemberInterface::kUint64:
194 sign = rtc::Optional<int>(Sign(
195 **static_cast<const RTCStatsMember<uint64_t>*>(&member)));
196 break;
197 case RTCStatsMemberInterface::kDouble:
198 sign = rtc::Optional<int>(Sign(
199 **static_cast<const RTCStatsMember<double>*>(&member)));
200 break;
201 default:
202 break;
203 }
204 if (!sign) {
205 EXPECT_TRUE(false) <<
206 stats_->type() << "." << member.name() << "[" << stats_->id() <<
207 "] is not " << sign_requirement << " because it is not a numeric " <<
208 "value (" << member.ValueToString() << ").";
209 MarkMemberTested(member, false);
210 return;
211 }
212 bool passed_sign_check = sign_check(*sign);
213 EXPECT_TRUE(passed_sign_check) <<
214 stats_->type() << "." << member.name() << "[" << stats_->id() <<
215 "] is not " << sign_requirement << " (" << member.ValueToString() <<
216 ").";
217 MarkMemberTested(member, passed_sign_check);
218 }
219
220 template<typename T>
221 int Sign(T value) {
222 return (value > T(0)) - (value < T(0));
223 }
224
160 void TestMemberIsIDReference( 225 void TestMemberIsIDReference(
161 const RTCStatsMemberInterface& member, 226 const RTCStatsMemberInterface& member,
162 const char* expected_type, 227 const char* expected_type,
163 bool optional) { 228 bool optional) {
164 if (optional && !member.is_defined()) { 229 if (optional && !member.is_defined()) {
165 MarkMemberTested(member, true); 230 MarkMemberTested(member, true);
166 return; 231 return;
167 } 232 }
168 bool valid_reference = false; 233 bool valid_reference = false;
169 if (member.is_defined()) { 234 if (member.is_defined()) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 verifier.TestMemberIsOptionalIDReference( 355 verifier.TestMemberIsOptionalIDReference(
291 certificate.issuer_certificate_id, RTCCertificateStats::kType); 356 certificate.issuer_certificate_id, RTCCertificateStats::kType);
292 return verifier.ExpectAllMembersSuccessfullyTested(); 357 return verifier.ExpectAllMembersSuccessfullyTested();
293 } 358 }
294 359
295 bool VerifyRTCCodecStats( 360 bool VerifyRTCCodecStats(
296 const RTCCodecStats& codec) { 361 const RTCCodecStats& codec) {
297 RTCStatsVerifier verifier(report_, &codec); 362 RTCStatsVerifier verifier(report_, &codec);
298 verifier.TestMemberIsDefined(codec.payload_type); 363 verifier.TestMemberIsDefined(codec.payload_type);
299 verifier.TestMemberIsDefined(codec.codec); 364 verifier.TestMemberIsDefined(codec.codec);
300 verifier.TestMemberIsDefined(codec.clock_rate); 365 verifier.TestMemberIsPositive(codec.clock_rate);
301 verifier.TestMemberIsUndefined(codec.channels); 366 verifier.TestMemberIsUndefined(codec.channels);
302 verifier.TestMemberIsUndefined(codec.parameters); 367 verifier.TestMemberIsUndefined(codec.parameters);
303 verifier.TestMemberIsUndefined(codec.implementation); 368 verifier.TestMemberIsUndefined(codec.implementation);
304 return verifier.ExpectAllMembersSuccessfullyTested(); 369 return verifier.ExpectAllMembersSuccessfullyTested();
305 } 370 }
306 371
307 bool VerifyRTCDataChannelStats( 372 bool VerifyRTCDataChannelStats(
308 const RTCDataChannelStats& data_channel) { 373 const RTCDataChannelStats& data_channel) {
309 RTCStatsVerifier verifier(report_, &data_channel); 374 RTCStatsVerifier verifier(report_, &data_channel);
310 verifier.TestMemberIsDefined(data_channel.label); 375 verifier.TestMemberIsDefined(data_channel.label);
311 verifier.TestMemberIsDefined(data_channel.protocol); 376 verifier.TestMemberIsDefined(data_channel.protocol);
312 verifier.TestMemberIsDefined(data_channel.datachannelid); 377 verifier.TestMemberIsDefined(data_channel.datachannelid);
313 verifier.TestMemberIsDefined(data_channel.state); 378 verifier.TestMemberIsDefined(data_channel.state);
314 verifier.TestMemberIsDefined(data_channel.messages_sent); 379 verifier.TestMemberIsNonNegative(data_channel.messages_sent);
315 verifier.TestMemberIsDefined(data_channel.bytes_sent); 380 verifier.TestMemberIsNonNegative(data_channel.bytes_sent);
316 verifier.TestMemberIsDefined(data_channel.messages_received); 381 verifier.TestMemberIsNonNegative(data_channel.messages_received);
317 verifier.TestMemberIsDefined(data_channel.bytes_received); 382 verifier.TestMemberIsNonNegative(data_channel.bytes_received);
318 return verifier.ExpectAllMembersSuccessfullyTested(); 383 return verifier.ExpectAllMembersSuccessfullyTested();
319 } 384 }
320 385
321 bool VerifyRTCIceCandidatePairStats( 386 bool VerifyRTCIceCandidatePairStats(
322 const RTCIceCandidatePairStats& candidate_pair) { 387 const RTCIceCandidatePairStats& candidate_pair) {
323 RTCStatsVerifier verifier(report_, &candidate_pair); 388 RTCStatsVerifier verifier(report_, &candidate_pair);
324 verifier.TestMemberIsIDReference( 389 verifier.TestMemberIsIDReference(
325 candidate_pair.transport_id, RTCTransportStats::kType); 390 candidate_pair.transport_id, RTCTransportStats::kType);
326 verifier.TestMemberIsIDReference( 391 verifier.TestMemberIsIDReference(
327 candidate_pair.local_candidate_id, RTCLocalIceCandidateStats::kType); 392 candidate_pair.local_candidate_id, RTCLocalIceCandidateStats::kType);
328 verifier.TestMemberIsIDReference( 393 verifier.TestMemberIsIDReference(
329 candidate_pair.remote_candidate_id, RTCRemoteIceCandidateStats::kType); 394 candidate_pair.remote_candidate_id, RTCRemoteIceCandidateStats::kType);
330 verifier.TestMemberIsUndefined(candidate_pair.state); 395 verifier.TestMemberIsUndefined(candidate_pair.state);
331 verifier.TestMemberIsUndefined(candidate_pair.priority); 396 verifier.TestMemberIsUndefined(candidate_pair.priority);
332 verifier.TestMemberIsUndefined(candidate_pair.nominated); 397 verifier.TestMemberIsUndefined(candidate_pair.nominated);
333 verifier.TestMemberIsDefined(candidate_pair.writable); 398 verifier.TestMemberIsDefined(candidate_pair.writable);
334 verifier.TestMemberIsUndefined(candidate_pair.readable); 399 verifier.TestMemberIsUndefined(candidate_pair.readable);
335 verifier.TestMemberIsDefined(candidate_pair.bytes_sent); 400 verifier.TestMemberIsNonNegative(candidate_pair.bytes_sent);
336 verifier.TestMemberIsDefined(candidate_pair.bytes_received); 401 verifier.TestMemberIsNonNegative(candidate_pair.bytes_received);
337 verifier.TestMemberIsUndefined(candidate_pair.total_round_trip_time); 402 verifier.TestMemberIsUndefined(candidate_pair.total_round_trip_time);
338 verifier.TestMemberIsDefined(candidate_pair.current_round_trip_time); 403 verifier.TestMemberIsNonNegative(candidate_pair.current_round_trip_time);
339 verifier.TestMemberIsUndefined(candidate_pair.available_outgoing_bitrate); 404 verifier.TestMemberIsUndefined(candidate_pair.available_outgoing_bitrate);
340 verifier.TestMemberIsUndefined(candidate_pair.available_incoming_bitrate); 405 verifier.TestMemberIsUndefined(candidate_pair.available_incoming_bitrate);
341 verifier.TestMemberIsDefined(candidate_pair.requests_received); 406 verifier.TestMemberIsNonNegative(candidate_pair.requests_received);
342 verifier.TestMemberIsDefined(candidate_pair.requests_sent); 407 verifier.TestMemberIsNonNegative(candidate_pair.requests_sent);
343 verifier.TestMemberIsDefined(candidate_pair.responses_received); 408 verifier.TestMemberIsNonNegative(candidate_pair.responses_received);
344 verifier.TestMemberIsDefined(candidate_pair.responses_sent); 409 verifier.TestMemberIsNonNegative(candidate_pair.responses_sent);
345 verifier.TestMemberIsUndefined(candidate_pair.retransmissions_received); 410 verifier.TestMemberIsUndefined(candidate_pair.retransmissions_received);
346 verifier.TestMemberIsUndefined(candidate_pair.retransmissions_sent); 411 verifier.TestMemberIsUndefined(candidate_pair.retransmissions_sent);
347 verifier.TestMemberIsUndefined(candidate_pair.consent_requests_received); 412 verifier.TestMemberIsUndefined(candidate_pair.consent_requests_received);
348 verifier.TestMemberIsDefined(candidate_pair.consent_requests_sent); 413 verifier.TestMemberIsNonNegative(candidate_pair.consent_requests_sent);
349 verifier.TestMemberIsUndefined(candidate_pair.consent_responses_received); 414 verifier.TestMemberIsUndefined(candidate_pair.consent_responses_received);
350 verifier.TestMemberIsUndefined(candidate_pair.consent_responses_sent); 415 verifier.TestMemberIsUndefined(candidate_pair.consent_responses_sent);
351 return verifier.ExpectAllMembersSuccessfullyTested(); 416 return verifier.ExpectAllMembersSuccessfullyTested();
352 } 417 }
353 418
354 bool VerifyRTCIceCandidateStats( 419 bool VerifyRTCIceCandidateStats(
355 const RTCIceCandidateStats& candidate) { 420 const RTCIceCandidateStats& candidate) {
356 RTCStatsVerifier verifier(report_, &candidate); 421 RTCStatsVerifier verifier(report_, &candidate);
357 verifier.TestMemberIsDefined(candidate.ip); 422 verifier.TestMemberIsDefined(candidate.ip);
358 verifier.TestMemberIsDefined(candidate.port); 423 verifier.TestMemberIsNonNegative(candidate.port);
359 verifier.TestMemberIsDefined(candidate.protocol); 424 verifier.TestMemberIsDefined(candidate.protocol);
360 verifier.TestMemberIsDefined(candidate.candidate_type); 425 verifier.TestMemberIsDefined(candidate.candidate_type);
361 verifier.TestMemberIsDefined(candidate.priority); 426 verifier.TestMemberIsNonNegative(candidate.priority);
362 verifier.TestMemberIsUndefined(candidate.url); 427 verifier.TestMemberIsUndefined(candidate.url);
363 return verifier.ExpectAllMembersSuccessfullyTested(); 428 return verifier.ExpectAllMembersSuccessfullyTested();
364 } 429 }
365 430
366 bool VerifyRTCLocalIceCandidateStats( 431 bool VerifyRTCLocalIceCandidateStats(
367 const RTCLocalIceCandidateStats& local_candidate) { 432 const RTCLocalIceCandidateStats& local_candidate) {
368 return VerifyRTCIceCandidateStats(local_candidate); 433 return VerifyRTCIceCandidateStats(local_candidate);
369 } 434 }
370 435
371 bool VerifyRTCRemoteIceCandidateStats( 436 bool VerifyRTCRemoteIceCandidateStats(
(...skipping 14 matching lines...) Expand all
386 const RTCMediaStreamTrackStats& media_stream_track) { 451 const RTCMediaStreamTrackStats& media_stream_track) {
387 RTCStatsVerifier verifier(report_, &media_stream_track); 452 RTCStatsVerifier verifier(report_, &media_stream_track);
388 verifier.TestMemberIsDefined(media_stream_track.track_identifier); 453 verifier.TestMemberIsDefined(media_stream_track.track_identifier);
389 verifier.TestMemberIsDefined(media_stream_track.remote_source); 454 verifier.TestMemberIsDefined(media_stream_track.remote_source);
390 verifier.TestMemberIsDefined(media_stream_track.ended); 455 verifier.TestMemberIsDefined(media_stream_track.ended);
391 verifier.TestMemberIsDefined(media_stream_track.detached); 456 verifier.TestMemberIsDefined(media_stream_track.detached);
392 verifier.TestMemberIsUndefined(media_stream_track.ssrc_ids); 457 verifier.TestMemberIsUndefined(media_stream_track.ssrc_ids);
393 // Video or audio media stream track? 458 // Video or audio media stream track?
394 if (media_stream_track.frame_width.is_defined()) { 459 if (media_stream_track.frame_width.is_defined()) {
395 // Video-only members 460 // Video-only members
396 verifier.TestMemberIsDefined(media_stream_track.frame_width); 461 verifier.TestMemberIsNonNegative(media_stream_track.frame_width);
397 verifier.TestMemberIsDefined(media_stream_track.frame_height); 462 verifier.TestMemberIsNonNegative(media_stream_track.frame_height);
398 verifier.TestMemberIsUndefined(media_stream_track.frames_per_second); 463 verifier.TestMemberIsUndefined(media_stream_track.frames_per_second);
399 verifier.TestMemberIsUndefined(media_stream_track.frames_sent); 464 verifier.TestMemberIsUndefined(media_stream_track.frames_sent);
400 verifier.TestMemberIsUndefined(media_stream_track.frames_received); 465 verifier.TestMemberIsUndefined(media_stream_track.frames_received);
401 verifier.TestMemberIsUndefined(media_stream_track.frames_decoded); 466 verifier.TestMemberIsUndefined(media_stream_track.frames_decoded);
402 verifier.TestMemberIsUndefined(media_stream_track.frames_dropped); 467 verifier.TestMemberIsUndefined(media_stream_track.frames_dropped);
403 verifier.TestMemberIsUndefined(media_stream_track.frames_corrupted); 468 verifier.TestMemberIsUndefined(media_stream_track.frames_corrupted);
404 verifier.TestMemberIsUndefined(media_stream_track.partial_frames_lost); 469 verifier.TestMemberIsUndefined(media_stream_track.partial_frames_lost);
405 verifier.TestMemberIsUndefined(media_stream_track.full_frames_lost); 470 verifier.TestMemberIsUndefined(media_stream_track.full_frames_lost);
406 // Audio-only members should be undefined 471 // Audio-only members should be undefined
407 verifier.TestMemberIsUndefined(media_stream_track.audio_level); 472 verifier.TestMemberIsUndefined(media_stream_track.audio_level);
(...skipping 21 matching lines...) Expand all
429 verifier.MarkMemberTested(media_stream_track.echo_return_loss, true); 494 verifier.MarkMemberTested(media_stream_track.echo_return_loss, true);
430 verifier.MarkMemberTested( 495 verifier.MarkMemberTested(
431 media_stream_track.echo_return_loss_enhancement, true); 496 media_stream_track.echo_return_loss_enhancement, true);
432 } 497 }
433 return verifier.ExpectAllMembersSuccessfullyTested(); 498 return verifier.ExpectAllMembersSuccessfullyTested();
434 } 499 }
435 500
436 bool VerifyRTCPeerConnectionStats( 501 bool VerifyRTCPeerConnectionStats(
437 const RTCPeerConnectionStats& peer_connection) { 502 const RTCPeerConnectionStats& peer_connection) {
438 RTCStatsVerifier verifier(report_, &peer_connection); 503 RTCStatsVerifier verifier(report_, &peer_connection);
439 verifier.TestMemberIsDefined(peer_connection.data_channels_opened); 504 verifier.TestMemberIsNonNegative(peer_connection.data_channels_opened);
440 verifier.TestMemberIsDefined(peer_connection.data_channels_closed); 505 verifier.TestMemberIsNonNegative(peer_connection.data_channels_closed);
441 return verifier.ExpectAllMembersSuccessfullyTested(); 506 return verifier.ExpectAllMembersSuccessfullyTested();
442 } 507 }
443 508
444 void VerifyRTCRTPStreamStats( 509 void VerifyRTCRTPStreamStats(
445 const RTCRTPStreamStats& stream, RTCStatsVerifier* verifier) { 510 const RTCRTPStreamStats& stream, RTCStatsVerifier* verifier) {
446 verifier->TestMemberIsDefined(stream.ssrc); 511 verifier->TestMemberIsDefined(stream.ssrc);
447 verifier->TestMemberIsUndefined(stream.associate_stats_id); 512 verifier->TestMemberIsUndefined(stream.associate_stats_id);
448 verifier->TestMemberIsDefined(stream.is_remote); 513 verifier->TestMemberIsDefined(stream.is_remote);
449 verifier->TestMemberIsDefined(stream.media_type); 514 verifier->TestMemberIsDefined(stream.media_type);
450 verifier->TestMemberIsUndefined(stream.media_track_id); 515 verifier->TestMemberIsUndefined(stream.media_track_id);
451 verifier->TestMemberIsIDReference( 516 verifier->TestMemberIsIDReference(
452 stream.transport_id, RTCTransportStats::kType); 517 stream.transport_id, RTCTransportStats::kType);
453 verifier->TestMemberIsIDReference(stream.codec_id, RTCCodecStats::kType); 518 verifier->TestMemberIsIDReference(stream.codec_id, RTCCodecStats::kType);
454 if (stream.media_type.is_defined() && *stream.media_type == "video") { 519 if (stream.media_type.is_defined() && *stream.media_type == "video") {
455 verifier->TestMemberIsDefined(stream.fir_count); 520 verifier->TestMemberIsNonNegative(stream.fir_count);
456 verifier->TestMemberIsDefined(stream.pli_count); 521 verifier->TestMemberIsNonNegative(stream.pli_count);
457 verifier->TestMemberIsDefined(stream.nack_count); 522 verifier->TestMemberIsNonNegative(stream.nack_count);
458 } else { 523 } else {
459 verifier->TestMemberIsUndefined(stream.fir_count); 524 verifier->TestMemberIsUndefined(stream.fir_count);
460 verifier->TestMemberIsUndefined(stream.pli_count); 525 verifier->TestMemberIsUndefined(stream.pli_count);
461 verifier->TestMemberIsUndefined(stream.nack_count); 526 verifier->TestMemberIsUndefined(stream.nack_count);
462 } 527 }
463 verifier->TestMemberIsUndefined(stream.sli_count); 528 verifier->TestMemberIsUndefined(stream.sli_count);
464 } 529 }
465 530
466 bool VerifyRTCInboundRTPStreamStats( 531 bool VerifyRTCInboundRTPStreamStats(
467 const RTCInboundRTPStreamStats& inbound_stream) { 532 const RTCInboundRTPStreamStats& inbound_stream) {
468 RTCStatsVerifier verifier(report_, &inbound_stream); 533 RTCStatsVerifier verifier(report_, &inbound_stream);
469 VerifyRTCRTPStreamStats(inbound_stream, &verifier); 534 VerifyRTCRTPStreamStats(inbound_stream, &verifier);
470 verifier.TestMemberIsDefined(inbound_stream.packets_received); 535 verifier.TestMemberIsNonNegative(inbound_stream.packets_received);
471 verifier.TestMemberIsDefined(inbound_stream.bytes_received); 536 verifier.TestMemberIsNonNegative(inbound_stream.bytes_received);
472 verifier.TestMemberIsDefined(inbound_stream.packets_lost); 537 verifier.TestMemberIsNonNegative(inbound_stream.packets_lost);
473 if (inbound_stream.media_type.is_defined() && 538 if (inbound_stream.media_type.is_defined() &&
474 *inbound_stream.media_type == "video") { 539 *inbound_stream.media_type == "video") {
475 verifier.TestMemberIsUndefined(inbound_stream.jitter); 540 verifier.TestMemberIsUndefined(inbound_stream.jitter);
476 } else { 541 } else {
477 verifier.TestMemberIsDefined(inbound_stream.jitter); 542 verifier.TestMemberIsNonNegative(inbound_stream.jitter);
478 } 543 }
479 verifier.TestMemberIsDefined(inbound_stream.fraction_lost); 544 verifier.TestMemberIsNonNegative(inbound_stream.fraction_lost);
480 verifier.TestMemberIsUndefined(inbound_stream.packets_discarded); 545 verifier.TestMemberIsUndefined(inbound_stream.packets_discarded);
481 verifier.TestMemberIsUndefined(inbound_stream.packets_repaired); 546 verifier.TestMemberIsUndefined(inbound_stream.packets_repaired);
482 verifier.TestMemberIsUndefined(inbound_stream.burst_packets_lost); 547 verifier.TestMemberIsUndefined(inbound_stream.burst_packets_lost);
483 verifier.TestMemberIsUndefined(inbound_stream.burst_packets_discarded); 548 verifier.TestMemberIsUndefined(inbound_stream.burst_packets_discarded);
484 verifier.TestMemberIsUndefined(inbound_stream.burst_loss_count); 549 verifier.TestMemberIsUndefined(inbound_stream.burst_loss_count);
485 verifier.TestMemberIsUndefined(inbound_stream.burst_discard_count); 550 verifier.TestMemberIsUndefined(inbound_stream.burst_discard_count);
486 verifier.TestMemberIsUndefined(inbound_stream.burst_loss_rate); 551 verifier.TestMemberIsUndefined(inbound_stream.burst_loss_rate);
487 verifier.TestMemberIsUndefined(inbound_stream.burst_discard_rate); 552 verifier.TestMemberIsUndefined(inbound_stream.burst_discard_rate);
488 verifier.TestMemberIsUndefined(inbound_stream.gap_loss_rate); 553 verifier.TestMemberIsUndefined(inbound_stream.gap_loss_rate);
489 verifier.TestMemberIsUndefined(inbound_stream.gap_discard_rate); 554 verifier.TestMemberIsUndefined(inbound_stream.gap_discard_rate);
490 return verifier.ExpectAllMembersSuccessfullyTested(); 555 return verifier.ExpectAllMembersSuccessfullyTested();
491 } 556 }
492 557
493 bool VerifyRTCOutboundRTPStreamStats( 558 bool VerifyRTCOutboundRTPStreamStats(
494 const RTCOutboundRTPStreamStats& outbound_stream) { 559 const RTCOutboundRTPStreamStats& outbound_stream) {
495 RTCStatsVerifier verifier(report_, &outbound_stream); 560 RTCStatsVerifier verifier(report_, &outbound_stream);
496 VerifyRTCRTPStreamStats(outbound_stream, &verifier); 561 VerifyRTCRTPStreamStats(outbound_stream, &verifier);
497 verifier.TestMemberIsDefined(outbound_stream.packets_sent); 562 verifier.TestMemberIsNonNegative(outbound_stream.packets_sent);
498 verifier.TestMemberIsDefined(outbound_stream.bytes_sent); 563 verifier.TestMemberIsNonNegative(outbound_stream.bytes_sent);
499 verifier.TestMemberIsUndefined(outbound_stream.target_bitrate); 564 verifier.TestMemberIsUndefined(outbound_stream.target_bitrate);
500 // TODO(hbos): Defined in video but not audio case. Why? crbug.com/669877 565 // TODO(hbos): Defined in video but not audio case. Why? crbug.com/669877
501 verifier.MarkMemberTested(outbound_stream.round_trip_time, true); 566 verifier.MarkMemberTested(outbound_stream.round_trip_time, true);
502 return verifier.ExpectAllMembersSuccessfullyTested(); 567 return verifier.ExpectAllMembersSuccessfullyTested();
503 } 568 }
504 569
505 bool VerifyRTCTransportStats( 570 bool VerifyRTCTransportStats(
506 const RTCTransportStats& transport) { 571 const RTCTransportStats& transport) {
507 RTCStatsVerifier verifier(report_, &transport); 572 RTCStatsVerifier verifier(report_, &transport);
508 verifier.TestMemberIsDefined(transport.bytes_sent); 573 verifier.TestMemberIsNonNegative(transport.bytes_sent);
509 verifier.TestMemberIsDefined(transport.bytes_received); 574 verifier.TestMemberIsNonNegative(transport.bytes_received);
510 verifier.TestMemberIsOptionalIDReference( 575 verifier.TestMemberIsOptionalIDReference(
511 transport.rtcp_transport_stats_id, RTCTransportStats::kType); 576 transport.rtcp_transport_stats_id, RTCTransportStats::kType);
512 verifier.TestMemberIsDefined(transport.active_connection); 577 verifier.TestMemberIsDefined(transport.active_connection);
513 verifier.TestMemberIsIDReference( 578 verifier.TestMemberIsIDReference(
514 transport.selected_candidate_pair_id, RTCIceCandidatePairStats::kType); 579 transport.selected_candidate_pair_id, RTCIceCandidatePairStats::kType);
515 verifier.TestMemberIsIDReference( 580 verifier.TestMemberIsIDReference(
516 transport.local_certificate_id, RTCCertificateStats::kType); 581 transport.local_certificate_id, RTCCertificateStats::kType);
517 verifier.TestMemberIsIDReference( 582 verifier.TestMemberIsIDReference(
518 transport.remote_certificate_id, RTCCertificateStats::kType); 583 transport.remote_certificate_id, RTCCertificateStats::kType);
519 return verifier.ExpectAllMembersSuccessfullyTested(); 584 return verifier.ExpectAllMembersSuccessfullyTested();
(...skipping 26 matching lines...) Expand all
546 // This will destroy the peer connection. 611 // This will destroy the peer connection.
547 caller_ = nullptr; 612 caller_ = nullptr;
548 // Any pending stats requests should have completed in the act of destroying 613 // Any pending stats requests should have completed in the act of destroying
549 // the peer connection. 614 // the peer connection.
550 EXPECT_TRUE(stats_obtainer->report()); 615 EXPECT_TRUE(stats_obtainer->report());
551 } 616 }
552 617
553 } // namespace 618 } // namespace
554 619
555 } // namespace webrtc 620 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698