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

Side by Side Diff: talk/app/webrtc/statscollector_unittest.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 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 | « talk/app/webrtc/statscollector.cc ('k') | talk/app/webrtc/statstypes.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 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } // namespace cricket 71 } // namespace cricket
72 72
73 namespace webrtc { 73 namespace webrtc {
74 74
75 // Error return values 75 // Error return values
76 const char kNotFound[] = "NOT FOUND"; 76 const char kNotFound[] = "NOT FOUND";
77 77
78 // Constant names for track identification. 78 // Constant names for track identification.
79 const char kLocalTrackId[] = "local_track_id"; 79 const char kLocalTrackId[] = "local_track_id";
80 const char kRemoteTrackId[] = "remote_track_id"; 80 const char kRemoteTrackId[] = "remote_track_id";
81 const uint32 kSsrcOfTrack = 1234; 81 const uint32_t kSsrcOfTrack = 1234;
82 82
83 class MockWebRtcSession : public webrtc::WebRtcSession { 83 class MockWebRtcSession : public webrtc::WebRtcSession {
84 public: 84 public:
85 explicit MockWebRtcSession(cricket::ChannelManager* channel_manager) 85 explicit MockWebRtcSession(cricket::ChannelManager* channel_manager)
86 : WebRtcSession(channel_manager, rtc::Thread::Current(), 86 : WebRtcSession(channel_manager, rtc::Thread::Current(),
87 rtc::Thread::Current(), NULL, NULL) { 87 rtc::Thread::Current(), NULL, NULL) {
88 } 88 }
89 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); 89 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*());
90 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); 90 MOCK_METHOD0(video_channel, cricket::VideoChannel*());
91 MOCK_CONST_METHOD0(mediastream_signaling, const MediaStreamSignaling*()); 91 MOCK_CONST_METHOD0(mediastream_signaling, const MediaStreamSignaling*());
92 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming 92 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming
93 // track. 93 // track.
94 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32, std::string*)); 94 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*));
95 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32, std::string*)); 95 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*));
96 MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*)); 96 MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*));
97 MOCK_METHOD2(GetLocalCertificate, 97 MOCK_METHOD2(GetLocalCertificate,
98 bool(const std::string& transport_name, 98 bool(const std::string& transport_name,
99 rtc::scoped_refptr<rtc::RTCCertificate>* certificate)); 99 rtc::scoped_refptr<rtc::RTCCertificate>* certificate));
100 MOCK_METHOD2(GetRemoteSSLCertificate, 100 MOCK_METHOD2(GetRemoteSSLCertificate,
101 bool(const std::string& transport_name, 101 bool(const std::string& transport_name,
102 rtc::SSLCertificate** cert)); 102 rtc::SSLCertificate** cert));
103 }; 103 };
104 104
105 class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel { 105 class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 void VerifyVoiceReceiverInfoReport( 295 void VerifyVoiceReceiverInfoReport(
296 const StatsReport* report, 296 const StatsReport* report,
297 const cricket::VoiceReceiverInfo& info) { 297 const cricket::VoiceReceiverInfo& info) {
298 std::string value_in_report; 298 std::string value_in_report;
299 EXPECT_TRUE(GetValue( 299 EXPECT_TRUE(GetValue(
300 report, StatsReport::kStatsValueNameAudioOutputLevel, &value_in_report)); 300 report, StatsReport::kStatsValueNameAudioOutputLevel, &value_in_report));
301 EXPECT_EQ(rtc::ToString<int>(info.audio_level), value_in_report); 301 EXPECT_EQ(rtc::ToString<int>(info.audio_level), value_in_report);
302 EXPECT_TRUE(GetValue( 302 EXPECT_TRUE(GetValue(
303 report, StatsReport::kStatsValueNameBytesReceived, &value_in_report)); 303 report, StatsReport::kStatsValueNameBytesReceived, &value_in_report));
304 EXPECT_EQ(rtc::ToString<int64>(info.bytes_rcvd), value_in_report); 304 EXPECT_EQ(rtc::ToString<int64_t>(info.bytes_rcvd), value_in_report);
305 EXPECT_TRUE(GetValue( 305 EXPECT_TRUE(GetValue(
306 report, StatsReport::kStatsValueNameJitterReceived, &value_in_report)); 306 report, StatsReport::kStatsValueNameJitterReceived, &value_in_report));
307 EXPECT_EQ(rtc::ToString<int>(info.jitter_ms), value_in_report); 307 EXPECT_EQ(rtc::ToString<int>(info.jitter_ms), value_in_report);
308 EXPECT_TRUE(GetValue( 308 EXPECT_TRUE(GetValue(
309 report, StatsReport::kStatsValueNameJitterBufferMs, &value_in_report)); 309 report, StatsReport::kStatsValueNameJitterBufferMs, &value_in_report));
310 EXPECT_EQ(rtc::ToString<int>(info.jitter_buffer_ms), value_in_report); 310 EXPECT_EQ(rtc::ToString<int>(info.jitter_buffer_ms), value_in_report);
311 EXPECT_TRUE(GetValue( 311 EXPECT_TRUE(GetValue(
312 report, StatsReport::kStatsValueNamePreferredJitterBufferMs, 312 report, StatsReport::kStatsValueNamePreferredJitterBufferMs,
313 &value_in_report)); 313 &value_in_report));
314 EXPECT_EQ(rtc::ToString<int>(info.jitter_buffer_preferred_ms), 314 EXPECT_EQ(rtc::ToString<int>(info.jitter_buffer_preferred_ms),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 361
362 void VerifyVoiceSenderInfoReport(const StatsReport* report, 362 void VerifyVoiceSenderInfoReport(const StatsReport* report,
363 const cricket::VoiceSenderInfo& sinfo) { 363 const cricket::VoiceSenderInfo& sinfo) {
364 std::string value_in_report; 364 std::string value_in_report;
365 EXPECT_TRUE(GetValue( 365 EXPECT_TRUE(GetValue(
366 report, StatsReport::kStatsValueNameCodecName, &value_in_report)); 366 report, StatsReport::kStatsValueNameCodecName, &value_in_report));
367 EXPECT_EQ(sinfo.codec_name, value_in_report); 367 EXPECT_EQ(sinfo.codec_name, value_in_report);
368 EXPECT_TRUE(GetValue( 368 EXPECT_TRUE(GetValue(
369 report, StatsReport::kStatsValueNameBytesSent, &value_in_report)); 369 report, StatsReport::kStatsValueNameBytesSent, &value_in_report));
370 EXPECT_EQ(rtc::ToString<int64>(sinfo.bytes_sent), value_in_report); 370 EXPECT_EQ(rtc::ToString<int64_t>(sinfo.bytes_sent), value_in_report);
371 EXPECT_TRUE(GetValue( 371 EXPECT_TRUE(GetValue(
372 report, StatsReport::kStatsValueNamePacketsSent, &value_in_report)); 372 report, StatsReport::kStatsValueNamePacketsSent, &value_in_report));
373 EXPECT_EQ(rtc::ToString<int>(sinfo.packets_sent), value_in_report); 373 EXPECT_EQ(rtc::ToString<int>(sinfo.packets_sent), value_in_report);
374 EXPECT_TRUE(GetValue( 374 EXPECT_TRUE(GetValue(
375 report, StatsReport::kStatsValueNamePacketsLost, &value_in_report)); 375 report, StatsReport::kStatsValueNamePacketsLost, &value_in_report));
376 EXPECT_EQ(rtc::ToString<int>(sinfo.packets_lost), value_in_report); 376 EXPECT_EQ(rtc::ToString<int>(sinfo.packets_lost), value_in_report);
377 EXPECT_TRUE(GetValue( 377 EXPECT_TRUE(GetValue(
378 report, StatsReport::kStatsValueNameRtt, &value_in_report)); 378 report, StatsReport::kStatsValueNameRtt, &value_in_report));
379 EXPECT_EQ(rtc::ToString<int>(sinfo.rtt_ms), value_in_report); 379 EXPECT_EQ(rtc::ToString<int>(sinfo.rtt_ms), value_in_report);
380 EXPECT_TRUE(GetValue( 380 EXPECT_TRUE(GetValue(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 // Verify the existence of the track report. 603 // Verify the existence of the track report.
604 const StatsReport* report = FindNthReportByType( 604 const StatsReport* report = FindNthReportByType(
605 *reports, StatsReport::kStatsReportTypeSsrc, 1); 605 *reports, StatsReport::kStatsReportTypeSsrc, 1);
606 EXPECT_FALSE(report == NULL); 606 EXPECT_FALSE(report == NULL);
607 EXPECT_EQ(stats->GetTimeNow(), report->timestamp()); 607 EXPECT_EQ(stats->GetTimeNow(), report->timestamp());
608 std::string track_id = ExtractSsrcStatsValue( 608 std::string track_id = ExtractSsrcStatsValue(
609 *reports, StatsReport::kStatsValueNameTrackId); 609 *reports, StatsReport::kStatsValueNameTrackId);
610 EXPECT_EQ(audio_track->id(), track_id); 610 EXPECT_EQ(audio_track->id(), track_id);
611 std::string ssrc_id = ExtractSsrcStatsValue( 611 std::string ssrc_id = ExtractSsrcStatsValue(
612 *reports, StatsReport::kStatsValueNameSsrc); 612 *reports, StatsReport::kStatsValueNameSsrc);
613 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 613 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
614 614
615 // Verifies the values in the track report. 615 // Verifies the values in the track report.
616 if (voice_sender_info) { 616 if (voice_sender_info) {
617 UpdateVoiceSenderInfoFromAudioTrack(audio_track, voice_sender_info); 617 UpdateVoiceSenderInfoFromAudioTrack(audio_track, voice_sender_info);
618 VerifyVoiceSenderInfoReport(report, *voice_sender_info); 618 VerifyVoiceSenderInfoReport(report, *voice_sender_info);
619 } 619 }
620 if (voice_receiver_info) { 620 if (voice_receiver_info) {
621 VerifyVoiceReceiverInfoReport(report, *voice_receiver_info); 621 VerifyVoiceReceiverInfoReport(report, *voice_receiver_info);
622 } 622 }
623 623
624 // Verify we get the same result by passing a track to GetStats(). 624 // Verify we get the same result by passing a track to GetStats().
625 StatsReports track_reports; // returned values. 625 StatsReports track_reports; // returned values.
626 stats->GetStats(audio_track, &track_reports); 626 stats->GetStats(audio_track, &track_reports);
627 const StatsReport* track_report = FindNthReportByType( 627 const StatsReport* track_report = FindNthReportByType(
628 track_reports, StatsReport::kStatsReportTypeSsrc, 1); 628 track_reports, StatsReport::kStatsReportTypeSsrc, 1);
629 EXPECT_TRUE(track_report); 629 EXPECT_TRUE(track_report);
630 EXPECT_EQ(stats->GetTimeNow(), track_report->timestamp()); 630 EXPECT_EQ(stats->GetTimeNow(), track_report->timestamp());
631 track_id = ExtractSsrcStatsValue(track_reports, 631 track_id = ExtractSsrcStatsValue(track_reports,
632 StatsReport::kStatsValueNameTrackId); 632 StatsReport::kStatsValueNameTrackId);
633 EXPECT_EQ(audio_track->id(), track_id); 633 EXPECT_EQ(audio_track->id(), track_id);
634 ssrc_id = ExtractSsrcStatsValue(track_reports, 634 ssrc_id = ExtractSsrcStatsValue(track_reports,
635 StatsReport::kStatsValueNameSsrc); 635 StatsReport::kStatsValueNameSsrc);
636 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 636 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
637 if (voice_sender_info) 637 if (voice_sender_info)
638 VerifyVoiceSenderInfoReport(track_report, *voice_sender_info); 638 VerifyVoiceSenderInfoReport(track_report, *voice_sender_info);
639 if (voice_receiver_info) 639 if (voice_receiver_info)
640 VerifyVoiceReceiverInfoReport(track_report, *voice_receiver_info); 640 VerifyVoiceReceiverInfoReport(track_report, *voice_receiver_info);
641 } 641 }
642 642
643 void TestCertificateReports(const rtc::FakeSSLCertificate& local_cert, 643 void TestCertificateReports(const rtc::FakeSSLCertificate& local_cert,
644 const std::vector<std::string>& local_ders, 644 const std::vector<std::string>& local_ders,
645 const rtc::FakeSSLCertificate& remote_cert, 645 const rtc::FakeSSLCertificate& remote_cert,
646 const std::vector<std::string>& remote_ders) { 646 const std::vector<std::string>& remote_ders) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 768
769 StatsReport::Id reportId = StatsReport::NewTypedIntId( 769 StatsReport::Id reportId = StatsReport::NewTypedIntId(
770 StatsReport::kStatsReportTypeDataChannel, id); 770 StatsReport::kStatsReportTypeDataChannel, id);
771 771
772 EXPECT_TRUE(reportId->Equals(report->id())); 772 EXPECT_TRUE(reportId->Equals(report->id()));
773 773
774 EXPECT_EQ(stats.GetTimeNow(), report->timestamp()); 774 EXPECT_EQ(stats.GetTimeNow(), report->timestamp());
775 EXPECT_EQ(label, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, 775 EXPECT_EQ(label, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel,
776 reports, 776 reports,
777 StatsReport::kStatsValueNameLabel)); 777 StatsReport::kStatsValueNameLabel));
778 EXPECT_EQ(rtc::ToString<int64>(id), 778 EXPECT_EQ(rtc::ToString<int64_t>(id),
779 ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, 779 ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, reports,
780 reports,
781 StatsReport::kStatsValueNameDataChannelId)); 780 StatsReport::kStatsValueNameDataChannelId));
782 EXPECT_EQ(state, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, 781 EXPECT_EQ(state, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel,
783 reports, 782 reports,
784 StatsReport::kStatsValueNameState)); 783 StatsReport::kStatsValueNameState));
785 EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, 784 EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel,
786 reports, 785 reports,
787 StatsReport::kStatsValueNameProtocol)); 786 StatsReport::kStatsValueNameProtocol));
788 } 787 }
789 788
790 // This test verifies that 64-bit counters are passed successfully. 789 // This test verifies that 64-bit counters are passed successfully.
(...skipping 12 matching lines...) Expand all
803 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), 802 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
804 Return(true))); 803 Return(true)));
805 804
806 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 805 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
807 cricket::VideoChannel video_channel(rtc::Thread::Current(), 806 cricket::VideoChannel video_channel(rtc::Thread::Current(),
808 media_channel, NULL, kVideoChannelName, false); 807 media_channel, NULL, kVideoChannelName, false);
809 StatsReports reports; // returned values. 808 StatsReports reports; // returned values.
810 cricket::VideoSenderInfo video_sender_info; 809 cricket::VideoSenderInfo video_sender_info;
811 cricket::VideoMediaInfo stats_read; 810 cricket::VideoMediaInfo stats_read;
812 // The number of bytes must be larger than 0xFFFFFFFF for this test. 811 // The number of bytes must be larger than 0xFFFFFFFF for this test.
813 const int64 kBytesSent = 12345678901234LL; 812 const int64_t kBytesSent = 12345678901234LL;
814 const std::string kBytesSentString("12345678901234"); 813 const std::string kBytesSentString("12345678901234");
815 814
816 AddOutgoingVideoTrackStats(); 815 AddOutgoingVideoTrackStats();
817 stats.AddStream(stream_); 816 stats.AddStream(stream_);
818 817
819 // Construct a stats value to read. 818 // Construct a stats value to read.
820 video_sender_info.add_ssrc(1234); 819 video_sender_info.add_ssrc(1234);
821 video_sender_info.bytes_sent = kBytesSent; 820 video_sender_info.bytes_sent = kBytesSent;
822 stats_read.senders.push_back(video_sender_info); 821 stats_read.senders.push_back(video_sender_info);
823 822
(...skipping 27 matching lines...) Expand all
851 850
852 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 851 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
853 cricket::VideoChannel video_channel(rtc::Thread::Current(), 852 cricket::VideoChannel video_channel(rtc::Thread::Current(),
854 media_channel, NULL, kVideoChannelName, false); 853 media_channel, NULL, kVideoChannelName, false);
855 854
856 StatsReports reports; // returned values. 855 StatsReports reports; // returned values.
857 cricket::VideoSenderInfo video_sender_info; 856 cricket::VideoSenderInfo video_sender_info;
858 cricket::VideoMediaInfo stats_read; 857 cricket::VideoMediaInfo stats_read;
859 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and 858 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and
860 // BWE. 859 // BWE.
861 const int64 kBytesSent = 12345678901234LL; 860 const int64_t kBytesSent = 12345678901234LL;
862 const std::string kBytesSentString("12345678901234"); 861 const std::string kBytesSentString("12345678901234");
863 862
864 AddOutgoingVideoTrackStats(); 863 AddOutgoingVideoTrackStats();
865 stats.AddStream(stream_); 864 stats.AddStream(stream_);
866 865
867 // Construct a stats value to read. 866 // Construct a stats value to read.
868 video_sender_info.add_ssrc(1234); 867 video_sender_info.add_ssrc(1234);
869 video_sender_info.bytes_sent = kBytesSent; 868 video_sender_info.bytes_sent = kBytesSent;
870 stats_read.senders.push_back(video_sender_info); 869 stats_read.senders.push_back(video_sender_info);
871 cricket::BandwidthEstimationInfo bwe; 870 cricket::BandwidthEstimationInfo bwe;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 965
967 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 966 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
968 cricket::VideoChannel video_channel(rtc::Thread::Current(), 967 cricket::VideoChannel video_channel(rtc::Thread::Current(),
969 media_channel, NULL, kVideoChannelName, false); 968 media_channel, NULL, kVideoChannelName, false);
970 AddOutgoingVideoTrackStats(); 969 AddOutgoingVideoTrackStats();
971 stats.AddStream(stream_); 970 stats.AddStream(stream_);
972 971
973 // Constructs an ssrc stats update. 972 // Constructs an ssrc stats update.
974 cricket::VideoSenderInfo video_sender_info; 973 cricket::VideoSenderInfo video_sender_info;
975 cricket::VideoMediaInfo stats_read; 974 cricket::VideoMediaInfo stats_read;
976 const int64 kBytesSent = 12345678901234LL; 975 const int64_t kBytesSent = 12345678901234LL;
977 976
978 // Construct a stats value to read. 977 // Construct a stats value to read.
979 video_sender_info.add_ssrc(1234); 978 video_sender_info.add_ssrc(1234);
980 video_sender_info.bytes_sent = kBytesSent; 979 video_sender_info.bytes_sent = kBytesSent;
981 stats_read.senders.push_back(video_sender_info); 980 stats_read.senders.push_back(video_sender_info);
982 981
983 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); 982 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel));
984 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); 983 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull());
985 EXPECT_CALL(*media_channel, GetStats(_)) 984 EXPECT_CALL(*media_channel, GetStats(_))
986 .WillOnce(DoAll(SetArgPointee<0>(stats_read), 985 .WillOnce(DoAll(SetArgPointee<0>(stats_read),
(...skipping 15 matching lines...) Expand all
1002 // |reports| should contain at least one session report, one track report, 1001 // |reports| should contain at least one session report, one track report,
1003 // and one ssrc report. 1002 // and one ssrc report.
1004 EXPECT_LE((size_t)3, reports.size()); 1003 EXPECT_LE((size_t)3, reports.size());
1005 track_report = FindNthReportByType( 1004 track_report = FindNthReportByType(
1006 reports, StatsReport::kStatsReportTypeTrack, 1); 1005 reports, StatsReport::kStatsReportTypeTrack, 1);
1007 EXPECT_TRUE(track_report); 1006 EXPECT_TRUE(track_report);
1008 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp()); 1007 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp());
1009 1008
1010 std::string ssrc_id = ExtractSsrcStatsValue( 1009 std::string ssrc_id = ExtractSsrcStatsValue(
1011 reports, StatsReport::kStatsValueNameSsrc); 1010 reports, StatsReport::kStatsValueNameSsrc);
1012 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 1011 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
1013 1012
1014 std::string track_id = ExtractSsrcStatsValue( 1013 std::string track_id = ExtractSsrcStatsValue(
1015 reports, StatsReport::kStatsValueNameTrackId); 1014 reports, StatsReport::kStatsValueNameTrackId);
1016 EXPECT_EQ(kLocalTrackId, track_id); 1015 EXPECT_EQ(kLocalTrackId, track_id);
1017 } 1016 }
1018 1017
1019 // This test verifies that an SSRC object has the identifier of a Transport 1018 // This test verifies that an SSRC object has the identifier of a Transport
1020 // stats object, and that this transport stats object exists in stats. 1019 // stats object, and that this transport stats object exists in stats.
1021 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { 1020 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) {
1022 StatsCollectorForTest stats(&session_); 1021 StatsCollectorForTest stats(&session_);
1023 1022
1024 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1023 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1025 .WillRepeatedly(Return(false)); 1024 .WillRepeatedly(Return(false));
1026 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1025 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1027 .WillRepeatedly(Return(false)); 1026 .WillRepeatedly(Return(false));
1028 1027
1029 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 1028 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
1030 // The transport_name known by the video channel. 1029 // The transport_name known by the video channel.
1031 const std::string kVcName("vcname"); 1030 const std::string kVcName("vcname");
1032 cricket::VideoChannel video_channel(rtc::Thread::Current(), 1031 cricket::VideoChannel video_channel(rtc::Thread::Current(),
1033 media_channel, NULL, kVcName, false); 1032 media_channel, NULL, kVcName, false);
1034 AddOutgoingVideoTrackStats(); 1033 AddOutgoingVideoTrackStats();
1035 stats.AddStream(stream_); 1034 stats.AddStream(stream_);
1036 1035
1037 // Constructs an ssrc stats update. 1036 // Constructs an ssrc stats update.
1038 cricket::VideoSenderInfo video_sender_info; 1037 cricket::VideoSenderInfo video_sender_info;
1039 cricket::VideoMediaInfo stats_read; 1038 cricket::VideoMediaInfo stats_read;
1040 const int64 kBytesSent = 12345678901234LL; 1039 const int64_t kBytesSent = 12345678901234LL;
1041 1040
1042 // Construct a stats value to read. 1041 // Construct a stats value to read.
1043 video_sender_info.add_ssrc(1234); 1042 video_sender_info.add_ssrc(1234);
1044 video_sender_info.bytes_sent = kBytesSent; 1043 video_sender_info.bytes_sent = kBytesSent;
1045 stats_read.senders.push_back(video_sender_info); 1044 stats_read.senders.push_back(video_sender_info);
1046 1045
1047 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); 1046 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel));
1048 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); 1047 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull());
1049 EXPECT_CALL(*media_channel, GetStats(_)) 1048 EXPECT_CALL(*media_channel, GetStats(_))
1050 .WillRepeatedly(DoAll(SetArgPointee<0>(stats_read), 1049 .WillRepeatedly(DoAll(SetArgPointee<0>(stats_read),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1171
1173 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 1172 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
1174 cricket::VideoChannel video_channel(rtc::Thread::Current(), 1173 cricket::VideoChannel video_channel(rtc::Thread::Current(),
1175 media_channel, NULL, kVideoChannelName, false); 1174 media_channel, NULL, kVideoChannelName, false);
1176 AddIncomingVideoTrackStats(); 1175 AddIncomingVideoTrackStats();
1177 stats.AddStream(stream_); 1176 stats.AddStream(stream_);
1178 1177
1179 // Constructs an ssrc stats update. 1178 // Constructs an ssrc stats update.
1180 cricket::VideoReceiverInfo video_receiver_info; 1179 cricket::VideoReceiverInfo video_receiver_info;
1181 cricket::VideoMediaInfo stats_read; 1180 cricket::VideoMediaInfo stats_read;
1182 const int64 kNumOfPacketsConcealed = 54321; 1181 const int64_t kNumOfPacketsConcealed = 54321;
1183 1182
1184 // Construct a stats value to read. 1183 // Construct a stats value to read.
1185 video_receiver_info.add_ssrc(1234); 1184 video_receiver_info.add_ssrc(1234);
1186 video_receiver_info.packets_concealed = kNumOfPacketsConcealed; 1185 video_receiver_info.packets_concealed = kNumOfPacketsConcealed;
1187 stats_read.receivers.push_back(video_receiver_info); 1186 stats_read.receivers.push_back(video_receiver_info);
1188 1187
1189 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel)); 1188 EXPECT_CALL(session_, video_channel()).WillRepeatedly(Return(&video_channel));
1190 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); 1189 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull());
1191 EXPECT_CALL(*media_channel, GetStats(_)) 1190 EXPECT_CALL(*media_channel, GetStats(_))
1192 .WillOnce(DoAll(SetArgPointee<0>(stats_read), 1191 .WillOnce(DoAll(SetArgPointee<0>(stats_read),
1193 Return(true))); 1192 Return(true)));
1194 1193
1195 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 1194 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
1196 StatsReports reports; 1195 StatsReports reports;
1197 stats.GetStats(NULL, &reports); 1196 stats.GetStats(NULL, &reports);
1198 // |reports| should contain at least one session report, one track report, 1197 // |reports| should contain at least one session report, one track report,
1199 // and one ssrc report. 1198 // and one ssrc report.
1200 EXPECT_LE(static_cast<size_t>(3), reports.size()); 1199 EXPECT_LE(static_cast<size_t>(3), reports.size());
1201 const StatsReport* track_report = FindNthReportByType( 1200 const StatsReport* track_report = FindNthReportByType(
1202 reports, StatsReport::kStatsReportTypeTrack, 1); 1201 reports, StatsReport::kStatsReportTypeTrack, 1);
1203 EXPECT_TRUE(track_report); 1202 EXPECT_TRUE(track_report);
1204 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp()); 1203 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp());
1205 1204
1206 std::string ssrc_id = ExtractSsrcStatsValue( 1205 std::string ssrc_id = ExtractSsrcStatsValue(
1207 reports, StatsReport::kStatsValueNameSsrc); 1206 reports, StatsReport::kStatsValueNameSsrc);
1208 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 1207 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
1209 1208
1210 std::string track_id = ExtractSsrcStatsValue( 1209 std::string track_id = ExtractSsrcStatsValue(
1211 reports, StatsReport::kStatsValueNameTrackId); 1210 reports, StatsReport::kStatsValueNameTrackId);
1212 EXPECT_EQ(kRemoteTrackId, track_id); 1211 EXPECT_EQ(kRemoteTrackId, track_id);
1213 } 1212 }
1214 1213
1215 // This test verifies the Ice Candidate report should contain the correct 1214 // This test verifies the Ice Candidate report should contain the correct
1216 // information from local/remote candidates. 1215 // information from local/remote candidates.
1217 TEST_F(StatsCollectorTest, IceCandidateReport) { 1216 TEST_F(StatsCollectorTest, IceCandidateReport) {
1218 StatsCollectorForTest stats(&session_); 1217 StatsCollectorForTest stats(&session_);
1219 1218
1220 StatsReports reports; // returned values. 1219 StatsReports reports; // returned values.
1221 1220
1222 const int local_port = 2000; 1221 const int local_port = 2000;
1223 const char local_ip[] = "192.168.0.1"; 1222 const char local_ip[] = "192.168.0.1";
1224 const int remote_port = 2001; 1223 const int remote_port = 2001;
1225 const char remote_ip[] = "192.168.0.2"; 1224 const char remote_ip[] = "192.168.0.2";
1226 1225
1227 rtc::SocketAddress local_address(local_ip, local_port); 1226 rtc::SocketAddress local_address(local_ip, local_port);
1228 rtc::SocketAddress remote_address(remote_ip, remote_port); 1227 rtc::SocketAddress remote_address(remote_ip, remote_port);
1229 rtc::AdapterType network_type = rtc::ADAPTER_TYPE_ETHERNET; 1228 rtc::AdapterType network_type = rtc::ADAPTER_TYPE_ETHERNET;
1230 uint32 priority = 1000; 1229 uint32_t priority = 1000;
1231 1230
1232 cricket::Candidate c; 1231 cricket::Candidate c;
1233 ASSERT(c.id().length() > 0); 1232 ASSERT(c.id().length() > 0);
1234 c.set_type(cricket::LOCAL_PORT_TYPE); 1233 c.set_type(cricket::LOCAL_PORT_TYPE);
1235 c.set_protocol(cricket::UDP_PROTOCOL_NAME); 1234 c.set_protocol(cricket::UDP_PROTOCOL_NAME);
1236 c.set_address(local_address); 1235 c.set_address(local_address);
1237 c.set_priority(priority); 1236 c.set_priority(priority);
1238 c.set_network_type(network_type); 1237 c.set_network_type(network_type);
1239 std::string report_id = AddCandidateReport(&stats, c, true)->id()->ToString(); 1238 std::string report_id = AddCandidateReport(&stats, c, true)->id()->ToString();
1240 EXPECT_EQ("Cand-" + c.id(), report_id); 1239 EXPECT_EQ("Cand-" + c.id(), report_id);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 // The report will exist since we don't remove them in RemoveStream(). 1582 // The report will exist since we don't remove them in RemoveStream().
1584 const StatsReport* report = FindNthReportByType( 1583 const StatsReport* report = FindNthReportByType(
1585 reports, StatsReport::kStatsReportTypeSsrc, 1); 1584 reports, StatsReport::kStatsReportTypeSsrc, 1);
1586 EXPECT_FALSE(report == NULL); 1585 EXPECT_FALSE(report == NULL);
1587 EXPECT_EQ(stats.GetTimeNow(), report->timestamp()); 1586 EXPECT_EQ(stats.GetTimeNow(), report->timestamp());
1588 std::string track_id = ExtractSsrcStatsValue( 1587 std::string track_id = ExtractSsrcStatsValue(
1589 reports, StatsReport::kStatsValueNameTrackId); 1588 reports, StatsReport::kStatsValueNameTrackId);
1590 EXPECT_EQ(kLocalTrackId, track_id); 1589 EXPECT_EQ(kLocalTrackId, track_id);
1591 std::string ssrc_id = ExtractSsrcStatsValue( 1590 std::string ssrc_id = ExtractSsrcStatsValue(
1592 reports, StatsReport::kStatsValueNameSsrc); 1591 reports, StatsReport::kStatsValueNameSsrc);
1593 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 1592 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
1594 1593
1595 // Verifies the values in the track report, no value will be changed by the 1594 // Verifies the values in the track report, no value will be changed by the
1596 // AudioTrackInterface::GetSignalValue() and 1595 // AudioTrackInterface::GetSignalValue() and
1597 // AudioProcessorInterface::AudioProcessorStats::GetStats(); 1596 // AudioProcessorInterface::AudioProcessorStats::GetStats();
1598 VerifyVoiceSenderInfoReport(report, voice_sender_info); 1597 VerifyVoiceSenderInfoReport(report, voice_sender_info);
1599 } 1598 }
1600 1599
1601 // This test verifies that when ongoing and incoming audio tracks are using 1600 // This test verifies that when ongoing and incoming audio tracks are using
1602 // the same ssrc, they populate stats reports correctly. 1601 // the same ssrc, they populate stats reports correctly.
1603 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { 1602 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 cricket::VoiceSenderInfo new_voice_sender_info; 1731 cricket::VoiceSenderInfo new_voice_sender_info;
1733 InitVoiceSenderInfo(&new_voice_sender_info); 1732 InitVoiceSenderInfo(&new_voice_sender_info);
1734 cricket::VoiceMediaInfo new_stats_read; 1733 cricket::VoiceMediaInfo new_stats_read;
1735 reports.clear(); 1734 reports.clear();
1736 SetupAndVerifyAudioTrackStats( 1735 SetupAndVerifyAudioTrackStats(
1737 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, 1736 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName,
1738 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); 1737 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports);
1739 } 1738 }
1740 1739
1741 } // namespace webrtc 1740 } // namespace webrtc
OLDNEW
« no previous file with comments | « talk/app/webrtc/statscollector.cc ('k') | talk/app/webrtc/statstypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698