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

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

Issue 1363573002: Wire up transport sequence number / send time callbacks to webrtc via libjingle. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Connect to SignalSentPacket when enabling bundle. 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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_t 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 webrtc::CallFactory* call_factory)
87 rtc::Thread::Current(), NULL, NULL) { 87 : WebRtcSession(channel_manager,
88 } 88 rtc::Thread::Current(),
89 rtc::Thread::Current(),
90 NULL,
91 NULL,
92 call_factory) {}
89 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); 93 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*());
90 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); 94 MOCK_METHOD0(video_channel, cricket::VideoChannel*());
91 MOCK_CONST_METHOD0(mediastream_signaling, const MediaStreamSignaling*()); 95 MOCK_CONST_METHOD0(mediastream_signaling, const MediaStreamSignaling*());
92 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming 96 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming
93 // track. 97 // track.
94 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*)); 98 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*));
95 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*)); 99 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*));
96 MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*)); 100 MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*));
97 MOCK_METHOD2(GetLocalCertificate, 101 MOCK_METHOD2(GetLocalCertificate,
98 bool(const std::string& transport_name, 102 bool(const std::string& transport_name,
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 return time_now_; 484 return time_now_;
481 } 485 }
482 486
483 private: 487 private:
484 double time_now_; 488 double time_now_;
485 }; 489 };
486 490
487 class StatsCollectorTest : public testing::Test { 491 class StatsCollectorTest : public testing::Test {
488 protected: 492 protected:
489 StatsCollectorTest() 493 StatsCollectorTest()
490 : media_engine_(new cricket::FakeMediaEngine()), 494 : media_engine_(new cricket::FakeMediaEngine()),
491 channel_manager_( 495 channel_manager_(
492 new cricket::ChannelManager(media_engine_, rtc::Thread::Current())), 496 new cricket::ChannelManager(media_engine_, rtc::Thread::Current())),
493 session_(channel_manager_.get()), 497 session_(channel_manager_.get(), &call_factory_),
494 signaling_(channel_manager_.get()) { 498 signaling_(channel_manager_.get()) {
495 // By default, we ignore session GetStats calls. 499 // By default, we ignore session GetStats calls.
496 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); 500 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false));
497 EXPECT_CALL(session_, mediastream_signaling()).WillRepeatedly( 501 EXPECT_CALL(session_, mediastream_signaling()).WillRepeatedly(
498 Return(&signaling_)); 502 Return(&signaling_));
499 } 503 }
500 504
501 ~StatsCollectorTest() {} 505 ~StatsCollectorTest() {}
502 506
503 // This creates a standard setup with a transport called "trspname" 507 // This creates a standard setup with a transport called "trspname"
504 // having one transport channel 508 // having one transport channel
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 dtls_cipher); 730 dtls_cipher);
727 std::string srtp_cipher = ExtractStatsValue( 731 std::string srtp_cipher = ExtractStatsValue(
728 StatsReport::kStatsReportTypeComponent, 732 StatsReport::kStatsReportTypeComponent,
729 reports, 733 reports,
730 StatsReport::kStatsValueNameSrtpCipher); 734 StatsReport::kStatsValueNameSrtpCipher);
731 EXPECT_EQ("the-srtp-cipher", srtp_cipher); 735 EXPECT_EQ("the-srtp-cipher", srtp_cipher);
732 } 736 }
733 737
734 cricket::FakeMediaEngine* media_engine_; 738 cricket::FakeMediaEngine* media_engine_;
735 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; 739 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_;
740 webrtc::CallFactory call_factory_;
736 MockWebRtcSession session_; 741 MockWebRtcSession session_;
737 FakeMediaStreamSignaling signaling_; 742 FakeMediaStreamSignaling signaling_;
738 FakeDataChannelProvider data_channel_provider_; 743 FakeDataChannelProvider data_channel_provider_;
739 cricket::SessionStats session_stats_; 744 cricket::SessionStats session_stats_;
740 rtc::scoped_refptr<webrtc::MediaStream> stream_; 745 rtc::scoped_refptr<webrtc::MediaStream> stream_;
741 rtc::scoped_refptr<webrtc::VideoTrack> track_; 746 rtc::scoped_refptr<webrtc::VideoTrack> track_;
742 rtc::scoped_refptr<FakeAudioTrack> audio_track_; 747 rtc::scoped_refptr<FakeAudioTrack> audio_track_;
743 }; 748 };
744 749
745 // Verify that ExtractDataInfo populates reports. 750 // Verify that ExtractDataInfo populates reports.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 .WillRepeatedly(Return(false)); 801 .WillRepeatedly(Return(false));
797 802
798 const char kVideoChannelName[] = "video"; 803 const char kVideoChannelName[] = "video";
799 804
800 InitSessionStats(kVideoChannelName); 805 InitSessionStats(kVideoChannelName);
801 EXPECT_CALL(session_, GetTransportStats(_)) 806 EXPECT_CALL(session_, GetTransportStats(_))
802 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), 807 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
803 Return(true))); 808 Return(true)));
804 809
805 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 810 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
806 cricket::VideoChannel video_channel(rtc::Thread::Current(), 811 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
807 media_channel, NULL, kVideoChannelName, false); 812 nullptr, kVideoChannelName, false);
808 StatsReports reports; // returned values. 813 StatsReports reports; // returned values.
809 cricket::VideoSenderInfo video_sender_info; 814 cricket::VideoSenderInfo video_sender_info;
810 cricket::VideoMediaInfo stats_read; 815 cricket::VideoMediaInfo stats_read;
811 // The number of bytes must be larger than 0xFFFFFFFF for this test. 816 // The number of bytes must be larger than 0xFFFFFFFF for this test.
812 const int64_t kBytesSent = 12345678901234LL; 817 const int64_t kBytesSent = 12345678901234LL;
813 const std::string kBytesSentString("12345678901234"); 818 const std::string kBytesSentString("12345678901234");
814 819
815 AddOutgoingVideoTrackStats(); 820 AddOutgoingVideoTrackStats();
816 stats.AddStream(stream_); 821 stats.AddStream(stream_);
817 822
(...skipping 24 matching lines...) Expand all
842 .WillRepeatedly(Return(false)); 847 .WillRepeatedly(Return(false));
843 848
844 const char kVideoChannelName[] = "video"; 849 const char kVideoChannelName[] = "video";
845 850
846 InitSessionStats(kVideoChannelName); 851 InitSessionStats(kVideoChannelName);
847 EXPECT_CALL(session_, GetTransportStats(_)) 852 EXPECT_CALL(session_, GetTransportStats(_))
848 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), 853 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
849 Return(true))); 854 Return(true)));
850 855
851 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 856 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
852 cricket::VideoChannel video_channel(rtc::Thread::Current(), 857 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
853 media_channel, NULL, kVideoChannelName, false); 858 nullptr, kVideoChannelName, false);
854 859
855 StatsReports reports; // returned values. 860 StatsReports reports; // returned values.
856 cricket::VideoSenderInfo video_sender_info; 861 cricket::VideoSenderInfo video_sender_info;
857 cricket::VideoMediaInfo stats_read; 862 cricket::VideoMediaInfo stats_read;
858 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and 863 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and
859 // BWE. 864 // BWE.
860 const int64_t kBytesSent = 12345678901234LL; 865 const int64_t kBytesSent = 12345678901234LL;
861 const std::string kBytesSentString("12345678901234"); 866 const std::string kBytesSentString("12345678901234");
862 867
863 AddOutgoingVideoTrackStats(); 868 AddOutgoingVideoTrackStats();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 reports, StatsReport::kStatsReportTypeSession, 2); 926 reports, StatsReport::kStatsReportTypeSession, 2);
922 EXPECT_EQ(NULL, session_report); 927 EXPECT_EQ(NULL, session_report);
923 } 928 }
924 929
925 // This test verifies that the empty track report exists in the returned stats 930 // This test verifies that the empty track report exists in the returned stats
926 // without calling StatsCollector::UpdateStats. 931 // without calling StatsCollector::UpdateStats.
927 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { 932 TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) {
928 StatsCollectorForTest stats(&session_); 933 StatsCollectorForTest stats(&session_);
929 934
930 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 935 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
931 cricket::VideoChannel video_channel(rtc::Thread::Current(), 936 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
932 media_channel, NULL, "video", false); 937 nullptr, "video", false);
933 AddOutgoingVideoTrackStats(); 938 AddOutgoingVideoTrackStats();
934 stats.AddStream(stream_); 939 stats.AddStream(stream_);
935 940
936 // Verfies the existence of the track report. 941 // Verfies the existence of the track report.
937 StatsReports reports; 942 StatsReports reports;
938 stats.GetStats(NULL, &reports); 943 stats.GetStats(NULL, &reports);
939 EXPECT_EQ((size_t)1, reports.size()); 944 EXPECT_EQ((size_t)1, reports.size());
940 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); 945 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type());
941 EXPECT_EQ(0, reports[0]->timestamp()); 946 EXPECT_EQ(0, reports[0]->timestamp());
942 947
(...skipping 14 matching lines...) Expand all
957 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 962 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
958 .WillRepeatedly(Return(false)); 963 .WillRepeatedly(Return(false));
959 964
960 const char kVideoChannelName[] = "video"; 965 const char kVideoChannelName[] = "video";
961 InitSessionStats(kVideoChannelName); 966 InitSessionStats(kVideoChannelName);
962 EXPECT_CALL(session_, GetTransportStats(_)) 967 EXPECT_CALL(session_, GetTransportStats(_))
963 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), 968 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
964 Return(true))); 969 Return(true)));
965 970
966 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 971 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
967 cricket::VideoChannel video_channel(rtc::Thread::Current(), 972 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
968 media_channel, NULL, kVideoChannelName, false); 973 nullptr, kVideoChannelName, false);
969 AddOutgoingVideoTrackStats(); 974 AddOutgoingVideoTrackStats();
970 stats.AddStream(stream_); 975 stats.AddStream(stream_);
971 976
972 // Constructs an ssrc stats update. 977 // Constructs an ssrc stats update.
973 cricket::VideoSenderInfo video_sender_info; 978 cricket::VideoSenderInfo video_sender_info;
974 cricket::VideoMediaInfo stats_read; 979 cricket::VideoMediaInfo stats_read;
975 const int64_t kBytesSent = 12345678901234LL; 980 const int64_t kBytesSent = 12345678901234LL;
976 981
977 // Construct a stats value to read. 982 // Construct a stats value to read.
978 video_sender_info.add_ssrc(1234); 983 video_sender_info.add_ssrc(1234);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 StatsCollectorForTest stats(&session_); 1026 StatsCollectorForTest stats(&session_);
1022 1027
1023 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1028 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1024 .WillRepeatedly(Return(false)); 1029 .WillRepeatedly(Return(false));
1025 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1030 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1026 .WillRepeatedly(Return(false)); 1031 .WillRepeatedly(Return(false));
1027 1032
1028 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 1033 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
1029 // The transport_name known by the video channel. 1034 // The transport_name known by the video channel.
1030 const std::string kVcName("vcname"); 1035 const std::string kVcName("vcname");
1031 cricket::VideoChannel video_channel(rtc::Thread::Current(), 1036 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
1032 media_channel, NULL, kVcName, false); 1037 nullptr, kVcName, false);
1033 AddOutgoingVideoTrackStats(); 1038 AddOutgoingVideoTrackStats();
1034 stats.AddStream(stream_); 1039 stats.AddStream(stream_);
1035 1040
1036 // Constructs an ssrc stats update. 1041 // Constructs an ssrc stats update.
1037 cricket::VideoSenderInfo video_sender_info; 1042 cricket::VideoSenderInfo video_sender_info;
1038 cricket::VideoMediaInfo stats_read; 1043 cricket::VideoMediaInfo stats_read;
1039 const int64_t kBytesSent = 12345678901234LL; 1044 const int64_t kBytesSent = 12345678901234LL;
1040 1045
1041 // Construct a stats value to read. 1046 // Construct a stats value to read.
1042 video_sender_info.add_ssrc(1234); 1047 video_sender_info.add_ssrc(1234);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 } 1084 }
1080 1085
1081 // This test verifies that a remote stats object will not be created for 1086 // This test verifies that a remote stats object will not be created for
1082 // an outgoing SSRC where remote stats are not returned. 1087 // an outgoing SSRC where remote stats are not returned.
1083 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { 1088 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) {
1084 StatsCollectorForTest stats(&session_); 1089 StatsCollectorForTest stats(&session_);
1085 1090
1086 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 1091 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
1087 // The transport_name known by the video channel. 1092 // The transport_name known by the video channel.
1088 const std::string kVcName("vcname"); 1093 const std::string kVcName("vcname");
1089 cricket::VideoChannel video_channel(rtc::Thread::Current(), 1094 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
1090 media_channel, NULL, kVcName, false); 1095 nullptr, kVcName, false);
1091 AddOutgoingVideoTrackStats(); 1096 AddOutgoingVideoTrackStats();
1092 stats.AddStream(stream_); 1097 stats.AddStream(stream_);
1093 1098
1094 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); 1099 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
1095 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); 1100 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull());
1096 1101
1097 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 1102 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
1098 StatsReports reports; 1103 StatsReports reports;
1099 stats.GetStats(NULL, &reports); 1104 stats.GetStats(NULL, &reports);
1100 const StatsReport* remote_report = FindNthReportByType(reports, 1105 const StatsReport* remote_report = FindNthReportByType(reports,
1101 StatsReport::kStatsReportTypeRemoteSsrc, 1); 1106 StatsReport::kStatsReportTypeRemoteSsrc, 1);
1102 EXPECT_TRUE(remote_report == NULL); 1107 EXPECT_TRUE(remote_report == NULL);
1103 } 1108 }
1104 1109
1105 // This test verifies that a remote stats object will be created for 1110 // This test verifies that a remote stats object will be created for
1106 // an outgoing SSRC where stats are returned. 1111 // an outgoing SSRC where stats are returned.
1107 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { 1112 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) {
1108 StatsCollectorForTest stats(&session_); 1113 StatsCollectorForTest stats(&session_);
1109 1114
1110 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1115 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1111 .WillRepeatedly(Return(false)); 1116 .WillRepeatedly(Return(false));
1112 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1117 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1113 .WillRepeatedly(Return(false)); 1118 .WillRepeatedly(Return(false));
1114 1119
1115 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 1120 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
1116 // The transport_name known by the video channel. 1121 // The transport_name known by the video channel.
1117 const std::string kVcName("vcname"); 1122 const std::string kVcName("vcname");
1118 cricket::VideoChannel video_channel(rtc::Thread::Current(), 1123 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
1119 media_channel, NULL, kVcName, false); 1124 nullptr, kVcName, false);
1120 AddOutgoingVideoTrackStats(); 1125 AddOutgoingVideoTrackStats();
1121 stats.AddStream(stream_); 1126 stats.AddStream(stream_);
1122 1127
1123 // Instruct the session to return stats containing the transport channel. 1128 // Instruct the session to return stats containing the transport channel.
1124 InitSessionStats(kVcName); 1129 InitSessionStats(kVcName);
1125 EXPECT_CALL(session_, GetTransportStats(_)) 1130 EXPECT_CALL(session_, GetTransportStats(_))
1126 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), 1131 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
1127 Return(true))); 1132 Return(true)));
1128 1133
1129 // Constructs an ssrc stats update. 1134 // Constructs an ssrc stats update.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1168 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1164 .WillRepeatedly(Return(false)); 1169 .WillRepeatedly(Return(false));
1165 1170
1166 const char kVideoChannelName[] = "video"; 1171 const char kVideoChannelName[] = "video";
1167 InitSessionStats(kVideoChannelName); 1172 InitSessionStats(kVideoChannelName);
1168 EXPECT_CALL(session_, GetTransportStats(_)) 1173 EXPECT_CALL(session_, GetTransportStats(_))
1169 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), 1174 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
1170 Return(true))); 1175 Return(true)));
1171 1176
1172 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); 1177 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
1173 cricket::VideoChannel video_channel(rtc::Thread::Current(), 1178 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
1174 media_channel, NULL, kVideoChannelName, false); 1179 nullptr, kVideoChannelName, false);
1175 AddIncomingVideoTrackStats(); 1180 AddIncomingVideoTrackStats();
1176 stats.AddStream(stream_); 1181 stats.AddStream(stream_);
1177 1182
1178 // Constructs an ssrc stats update. 1183 // Constructs an ssrc stats update.
1179 cricket::VideoReceiverInfo video_receiver_info; 1184 cricket::VideoReceiverInfo video_receiver_info;
1180 cricket::VideoMediaInfo stats_read; 1185 cricket::VideoMediaInfo stats_read;
1181 const int64_t kNumOfPacketsConcealed = 54321; 1186 const int64_t kNumOfPacketsConcealed = 54321;
1182 1187
1183 // Construct a stats value to read. 1188 // Construct a stats value to read.
1184 video_receiver_info.add_ssrc(1234); 1189 video_receiver_info.add_ssrc(1234);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 StatsCollectorForTest stats(&session_); 1483 StatsCollectorForTest stats(&session_);
1479 1484
1480 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1485 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1481 .WillRepeatedly(Return(false)); 1486 .WillRepeatedly(Return(false));
1482 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1487 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1483 .WillRepeatedly(Return(false)); 1488 .WillRepeatedly(Return(false));
1484 1489
1485 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); 1490 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
1486 // The transport_name known by the voice channel. 1491 // The transport_name known by the voice channel.
1487 const std::string kVcName("vcname"); 1492 const std::string kVcName("vcname");
1488 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), 1493 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
1489 media_engine_, media_channel, NULL, kVcName, false); 1494 media_channel, nullptr, kVcName, false);
1490 AddOutgoingAudioTrackStats(); 1495 AddOutgoingAudioTrackStats();
1491 stats.AddStream(stream_); 1496 stats.AddStream(stream_);
1492 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); 1497 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack);
1493 1498
1494 cricket::VoiceSenderInfo voice_sender_info; 1499 cricket::VoiceSenderInfo voice_sender_info;
1495 InitVoiceSenderInfo(&voice_sender_info); 1500 InitVoiceSenderInfo(&voice_sender_info);
1496 1501
1497 cricket::VoiceMediaInfo stats_read; 1502 cricket::VoiceMediaInfo stats_read;
1498 StatsReports reports; // returned values. 1503 StatsReports reports; // returned values.
1499 SetupAndVerifyAudioTrackStats( 1504 SetupAndVerifyAudioTrackStats(
(...skipping 13 matching lines...) Expand all
1513 StatsCollectorForTest stats(&session_); 1518 StatsCollectorForTest stats(&session_);
1514 1519
1515 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1520 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1516 .WillRepeatedly(Return(false)); 1521 .WillRepeatedly(Return(false));
1517 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1522 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1518 .WillRepeatedly(Return(false)); 1523 .WillRepeatedly(Return(false));
1519 1524
1520 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); 1525 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
1521 // The transport_name known by the voice channel. 1526 // The transport_name known by the voice channel.
1522 const std::string kVcName("vcname"); 1527 const std::string kVcName("vcname");
1523 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), 1528 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
1524 media_engine_, media_channel, NULL, kVcName, false); 1529 media_channel, nullptr, kVcName, false);
1525 AddIncomingAudioTrackStats(); 1530 AddIncomingAudioTrackStats();
1526 stats.AddStream(stream_); 1531 stats.AddStream(stream_);
1527 1532
1528 cricket::VoiceReceiverInfo voice_receiver_info; 1533 cricket::VoiceReceiverInfo voice_receiver_info;
1529 InitVoiceReceiverInfo(&voice_receiver_info); 1534 InitVoiceReceiverInfo(&voice_receiver_info);
1530 voice_receiver_info.codec_name = "fake_codec"; 1535 voice_receiver_info.codec_name = "fake_codec";
1531 1536
1532 cricket::VoiceMediaInfo stats_read; 1537 cricket::VoiceMediaInfo stats_read;
1533 StatsReports reports; // returned values. 1538 StatsReports reports; // returned values.
1534 SetupAndVerifyAudioTrackStats( 1539 SetupAndVerifyAudioTrackStats(
1535 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, 1540 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName,
1536 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); 1541 media_channel, NULL, &voice_receiver_info, &stats_read, &reports);
1537 } 1542 }
1538 1543
1539 // This test verifies that a local stats object won't update its statistics 1544 // This test verifies that a local stats object won't update its statistics
1540 // after a RemoveLocalAudioTrack() call. 1545 // after a RemoveLocalAudioTrack() call.
1541 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { 1546 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) {
1542 StatsCollectorForTest stats(&session_); 1547 StatsCollectorForTest stats(&session_);
1543 1548
1544 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1549 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1545 .WillRepeatedly(Return(false)); 1550 .WillRepeatedly(Return(false));
1546 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1551 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1547 .WillRepeatedly(Return(false)); 1552 .WillRepeatedly(Return(false));
1548 1553
1549 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); 1554 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
1550 // The transport_name known by the voice channel. 1555 // The transport_name known by the voice channel.
1551 const std::string kVcName("vcname"); 1556 const std::string kVcName("vcname");
1552 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), 1557 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
1553 media_engine_, media_channel, NULL, kVcName, false); 1558 media_channel, nullptr, kVcName, false);
1554 AddOutgoingAudioTrackStats(); 1559 AddOutgoingAudioTrackStats();
1555 stats.AddStream(stream_); 1560 stats.AddStream(stream_);
1556 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); 1561 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack);
1557 1562
1558 // Instruct the session to return stats containing the transport channel. 1563 // Instruct the session to return stats containing the transport channel.
1559 InitSessionStats(kVcName); 1564 InitSessionStats(kVcName);
1560 EXPECT_CALL(session_, GetTransportStats(_)) 1565 EXPECT_CALL(session_, GetTransportStats(_))
1561 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), 1566 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
1562 Return(true))); 1567 Return(true)));
1563 1568
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 StatsCollectorForTest stats(&session_); 1608 StatsCollectorForTest stats(&session_);
1604 1609
1605 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1610 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1606 .WillRepeatedly(Return(false)); 1611 .WillRepeatedly(Return(false));
1607 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1612 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1608 .WillRepeatedly(Return(false)); 1613 .WillRepeatedly(Return(false));
1609 1614
1610 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); 1615 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
1611 // The transport_name known by the voice channel. 1616 // The transport_name known by the voice channel.
1612 const std::string kVcName("vcname"); 1617 const std::string kVcName("vcname");
1613 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), 1618 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
1614 media_engine_, media_channel, NULL, kVcName, false); 1619 media_channel, nullptr, kVcName, false);
1615 1620
1616 // Create a local stream with a local audio track and adds it to the stats. 1621 // Create a local stream with a local audio track and adds it to the stats.
1617 AddOutgoingAudioTrackStats(); 1622 AddOutgoingAudioTrackStats();
1618 stats.AddStream(stream_); 1623 stats.AddStream(stream_);
1619 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); 1624 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack);
1620 1625
1621 // Create a remote stream with a remote audio track and adds it to the stats. 1626 // Create a remote stream with a remote audio track and adds it to the stats.
1622 rtc::scoped_refptr<webrtc::MediaStream> remote_stream( 1627 rtc::scoped_refptr<webrtc::MediaStream> remote_stream(
1623 webrtc::MediaStream::Create("remotestreamlabel")); 1628 webrtc::MediaStream::Create("remotestreamlabel"));
1624 rtc::scoped_refptr<FakeAudioTrack> remote_track( 1629 rtc::scoped_refptr<FakeAudioTrack> remote_track(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 StatsCollectorForTest stats(&session_); 1695 StatsCollectorForTest stats(&session_);
1691 1696
1692 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1697 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1693 .WillRepeatedly(Return(false)); 1698 .WillRepeatedly(Return(false));
1694 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1699 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
1695 .WillRepeatedly(Return(false)); 1700 .WillRepeatedly(Return(false));
1696 1701
1697 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); 1702 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
1698 // The transport_name known by the voice channel. 1703 // The transport_name known by the voice channel.
1699 const std::string kVcName("vcname"); 1704 const std::string kVcName("vcname");
1700 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), 1705 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
1701 media_engine_, media_channel, NULL, kVcName, false); 1706 media_channel, nullptr, kVcName, false);
1702 1707
1703 // Create a local stream with a local audio track and adds it to the stats. 1708 // Create a local stream with a local audio track and adds it to the stats.
1704 AddOutgoingAudioTrackStats(); 1709 AddOutgoingAudioTrackStats();
1705 stats.AddStream(stream_); 1710 stats.AddStream(stream_);
1706 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); 1711 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack);
1707 1712
1708 cricket::VoiceSenderInfo voice_sender_info; 1713 cricket::VoiceSenderInfo voice_sender_info;
1709 voice_sender_info.add_ssrc(kSsrcOfTrack); 1714 voice_sender_info.add_ssrc(kSsrcOfTrack);
1710 1715
1711 cricket::VoiceMediaInfo stats_read; 1716 cricket::VoiceMediaInfo stats_read;
(...skipping 19 matching lines...) Expand all
1731 cricket::VoiceSenderInfo new_voice_sender_info; 1736 cricket::VoiceSenderInfo new_voice_sender_info;
1732 InitVoiceSenderInfo(&new_voice_sender_info); 1737 InitVoiceSenderInfo(&new_voice_sender_info);
1733 cricket::VoiceMediaInfo new_stats_read; 1738 cricket::VoiceMediaInfo new_stats_read;
1734 reports.clear(); 1739 reports.clear();
1735 SetupAndVerifyAudioTrackStats( 1740 SetupAndVerifyAudioTrackStats(
1736 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, 1741 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName,
1737 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); 1742 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports);
1738 } 1743 }
1739 1744
1740 } // namespace webrtc 1745 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698