OLD | NEW |
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, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include <stdio.h> | 28 #include <stdio.h> |
29 | 29 |
| 30 #include <algorithm> |
| 31 |
30 #include "talk/app/webrtc/statscollector.h" | 32 #include "talk/app/webrtc/statscollector.h" |
31 | 33 |
32 #include "talk/app/webrtc/mediastream.h" | 34 #include "talk/app/webrtc/mediastream.h" |
33 #include "talk/app/webrtc/mediastreaminterface.h" | 35 #include "talk/app/webrtc/mediastreaminterface.h" |
34 #include "talk/app/webrtc/mediastreamsignaling.h" | 36 #include "talk/app/webrtc/mediastreamsignaling.h" |
35 #include "talk/app/webrtc/mediastreamtrack.h" | 37 #include "talk/app/webrtc/mediastreamtrack.h" |
36 #include "talk/app/webrtc/test/fakedatachannelprovider.h" | 38 #include "talk/app/webrtc/test/fakedatachannelprovider.h" |
37 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" | 39 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" |
38 #include "talk/app/webrtc/videotrack.h" | 40 #include "talk/app/webrtc/videotrack.h" |
39 #include "talk/media/base/fakemediaengine.h" | 41 #include "talk/media/base/fakemediaengine.h" |
40 #include "talk/media/devices/fakedevicemanager.h" | 42 #include "talk/media/devices/fakedevicemanager.h" |
41 #include "talk/session/media/channelmanager.h" | 43 #include "talk/session/media/channelmanager.h" |
42 #include "testing/gmock/include/gmock/gmock.h" | 44 #include "testing/gmock/include/gmock/gmock.h" |
43 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
44 #include "webrtc/base/base64.h" | 46 #include "webrtc/base/base64.h" |
45 #include "webrtc/base/fakesslidentity.h" | 47 #include "webrtc/base/fakesslidentity.h" |
46 #include "webrtc/base/gunit.h" | 48 #include "webrtc/base/gunit.h" |
47 #include "webrtc/base/network.h" | 49 #include "webrtc/base/network.h" |
48 #include "webrtc/p2p/base/fakesession.h" | 50 #include "webrtc/p2p/base/faketransportcontroller.h" |
49 | 51 |
50 using rtc::scoped_ptr; | 52 using rtc::scoped_ptr; |
51 using testing::_; | 53 using testing::_; |
52 using testing::DoAll; | 54 using testing::DoAll; |
53 using testing::Field; | 55 using testing::Field; |
54 using testing::Return; | 56 using testing::Return; |
55 using testing::ReturnNull; | 57 using testing::ReturnNull; |
56 using testing::SetArgPointee; | 58 using testing::SetArgPointee; |
57 using webrtc::PeerConnectionInterface; | 59 using webrtc::PeerConnectionInterface; |
58 using webrtc::StatsReport; | 60 using webrtc::StatsReport; |
(...skipping 23 matching lines...) Expand all Loading... |
82 rtc::Thread::Current(), NULL, NULL) { | 84 rtc::Thread::Current(), NULL, NULL) { |
83 } | 85 } |
84 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); | 86 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); |
85 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); | 87 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); |
86 MOCK_CONST_METHOD0(mediastream_signaling, const MediaStreamSignaling*()); | 88 MOCK_CONST_METHOD0(mediastream_signaling, const MediaStreamSignaling*()); |
87 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming | 89 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming |
88 // track. | 90 // track. |
89 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32, std::string*)); | 91 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32, std::string*)); |
90 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32, std::string*)); | 92 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32, std::string*)); |
91 MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*)); | 93 MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*)); |
92 MOCK_METHOD1(GetTransport, cricket::Transport*(const std::string&)); | 94 MOCK_METHOD2(GetIdentity, |
| 95 bool(const std::string& content_name, |
| 96 rtc::SSLIdentity** identity)); |
| 97 MOCK_METHOD2(GetRemoteCertificate, |
| 98 bool(const std::string& content_name, |
| 99 rtc::SSLCertificate** cert)); |
93 }; | 100 }; |
94 | 101 |
95 class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel { | 102 class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel { |
96 public: | 103 public: |
97 MockVideoMediaChannel() : cricket::FakeVideoMediaChannel(NULL) {} | 104 MockVideoMediaChannel() : cricket::FakeVideoMediaChannel(NULL) {} |
98 | 105 |
99 // MOCK_METHOD0(transport_channel, cricket::TransportChannel*()); | 106 // MOCK_METHOD0(transport_channel, cricket::TransportChannel*()); |
100 MOCK_METHOD1(GetStats, bool(cricket::VideoMediaInfo*)); | 107 MOCK_METHOD1(GetStats, bool(cricket::VideoMediaInfo*)); |
101 }; | 108 }; |
102 | 109 |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 channel_stats.ssl_cipher = "the-ssl-cipher"; | 655 channel_stats.ssl_cipher = "the-ssl-cipher"; |
649 | 656 |
650 cricket::TransportStats transport_stats; | 657 cricket::TransportStats transport_stats; |
651 transport_stats.content_name = "audio"; | 658 transport_stats.content_name = "audio"; |
652 transport_stats.channel_stats.push_back(channel_stats); | 659 transport_stats.channel_stats.push_back(channel_stats); |
653 | 660 |
654 cricket::SessionStats session_stats; | 661 cricket::SessionStats session_stats; |
655 session_stats.transport_stats[transport_stats.content_name] = | 662 session_stats.transport_stats[transport_stats.content_name] = |
656 transport_stats; | 663 transport_stats; |
657 | 664 |
658 // Fake certificates to report. | 665 // Fake identity to report |
659 rtc::FakeSSLIdentity local_identity(local_cert); | 666 rtc::FakeSSLIdentity local_identity(local_cert); |
660 rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert_copy( | |
661 remote_cert.GetReference()); | |
662 | |
663 // Fake transport object. | |
664 rtc::scoped_ptr<cricket::FakeTransport> transport( | |
665 new cricket::FakeTransport( | |
666 session_.signaling_thread(), | |
667 session_.worker_thread(), | |
668 transport_stats.content_name)); | |
669 transport->SetIdentity(&local_identity); | |
670 cricket::FakeTransportChannel* channel = | |
671 static_cast<cricket::FakeTransportChannel*>( | |
672 transport->CreateChannel(channel_stats.component)); | |
673 EXPECT_FALSE(channel == NULL); | |
674 channel->SetRemoteCertificate(remote_cert_copy.get()); | |
675 | 667 |
676 // Configure MockWebRtcSession | 668 // Configure MockWebRtcSession |
677 EXPECT_CALL(session_, GetTransport(transport_stats.content_name)) | 669 EXPECT_CALL(session_, GetIdentity(transport_stats.content_name, _)) |
678 .WillRepeatedly(Return(transport.get())); | 670 .WillOnce(DoAll(SetArgPointee<1>(local_identity.GetReference()), |
| 671 Return(true))); |
| 672 EXPECT_CALL(session_, GetRemoteCertificate(transport_stats.content_name, _)) |
| 673 .WillOnce( |
| 674 DoAll(SetArgPointee<1>(remote_cert.GetReference()), Return(true))); |
679 EXPECT_CALL(session_, GetTransportStats(_)) | 675 EXPECT_CALL(session_, GetTransportStats(_)) |
680 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 676 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
681 Return(true))); | 677 Return(true))); |
682 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 678 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
683 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 679 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
684 | 680 |
685 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 681 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
686 | 682 |
687 stats.GetStats(NULL, &reports); | 683 stats.GetStats(NULL, &reports); |
688 | 684 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 StatsReport::kStatsValueNameState)); | 778 StatsReport::kStatsValueNameState)); |
783 EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, | 779 EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, |
784 reports, | 780 reports, |
785 StatsReport::kStatsValueNameProtocol)); | 781 StatsReport::kStatsValueNameProtocol)); |
786 } | 782 } |
787 | 783 |
788 // This test verifies that 64-bit counters are passed successfully. | 784 // This test verifies that 64-bit counters are passed successfully. |
789 TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { | 785 TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { |
790 StatsCollectorForTest stats(&session_); | 786 StatsCollectorForTest stats(&session_); |
791 | 787 |
| 788 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
| 789 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 790 .WillRepeatedly(Return(false)); |
| 791 |
792 const char kVideoChannelName[] = "video"; | 792 const char kVideoChannelName[] = "video"; |
793 | 793 |
794 InitSessionStats(kVideoChannelName); | 794 InitSessionStats(kVideoChannelName); |
795 EXPECT_CALL(session_, GetTransportStats(_)) | 795 EXPECT_CALL(session_, GetTransportStats(_)) |
796 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 796 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
797 Return(true))); | 797 Return(true))); |
798 EXPECT_CALL(session_, GetTransport(_)) | |
799 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
800 | 798 |
801 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 799 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
802 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 800 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
803 media_channel, NULL, kVideoChannelName, false); | 801 media_channel, NULL, kVideoChannelName, false); |
804 StatsReports reports; // returned values. | 802 StatsReports reports; // returned values. |
805 cricket::VideoSenderInfo video_sender_info; | 803 cricket::VideoSenderInfo video_sender_info; |
806 cricket::VideoMediaInfo stats_read; | 804 cricket::VideoMediaInfo stats_read; |
807 // The number of bytes must be larger than 0xFFFFFFFF for this test. | 805 // The number of bytes must be larger than 0xFFFFFFFF for this test. |
808 const int64 kBytesSent = 12345678901234LL; | 806 const int64 kBytesSent = 12345678901234LL; |
809 const std::string kBytesSentString("12345678901234"); | 807 const std::string kBytesSentString("12345678901234"); |
(...skipping 15 matching lines...) Expand all Loading... |
825 stats.GetStats(NULL, &reports); | 823 stats.GetStats(NULL, &reports); |
826 std::string result = ExtractSsrcStatsValue(reports, | 824 std::string result = ExtractSsrcStatsValue(reports, |
827 StatsReport::kStatsValueNameBytesSent); | 825 StatsReport::kStatsValueNameBytesSent); |
828 EXPECT_EQ(kBytesSentString, result); | 826 EXPECT_EQ(kBytesSentString, result); |
829 } | 827 } |
830 | 828 |
831 // Test that BWE information is reported via stats. | 829 // Test that BWE information is reported via stats. |
832 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { | 830 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { |
833 StatsCollectorForTest stats(&session_); | 831 StatsCollectorForTest stats(&session_); |
834 | 832 |
| 833 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
| 834 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 835 .WillRepeatedly(Return(false)); |
| 836 |
835 const char kVideoChannelName[] = "video"; | 837 const char kVideoChannelName[] = "video"; |
836 | 838 |
837 InitSessionStats(kVideoChannelName); | 839 InitSessionStats(kVideoChannelName); |
838 EXPECT_CALL(session_, GetTransportStats(_)) | 840 EXPECT_CALL(session_, GetTransportStats(_)) |
839 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 841 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
840 Return(true))); | 842 Return(true))); |
841 EXPECT_CALL(session_, GetTransport(_)) | |
842 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
843 | 843 |
844 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 844 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
845 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 845 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
846 media_channel, NULL, kVideoChannelName, false); | 846 media_channel, NULL, kVideoChannelName, false); |
847 | 847 |
848 StatsReports reports; // returned values. | 848 StatsReports reports; // returned values. |
849 cricket::VideoSenderInfo video_sender_info; | 849 cricket::VideoSenderInfo video_sender_info; |
850 cricket::VideoMediaInfo stats_read; | 850 cricket::VideoMediaInfo stats_read; |
851 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and | 851 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and |
852 // BWE. | 852 // BWE. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 reports, | 938 reports, |
939 StatsReport::kStatsValueNameTrackId); | 939 StatsReport::kStatsValueNameTrackId); |
940 EXPECT_EQ(kLocalTrackId, trackValue); | 940 EXPECT_EQ(kLocalTrackId, trackValue); |
941 } | 941 } |
942 | 942 |
943 // This test verifies that the empty track report exists in the returned stats | 943 // This test verifies that the empty track report exists in the returned stats |
944 // when StatsCollector::UpdateStats is called with ssrc stats. | 944 // when StatsCollector::UpdateStats is called with ssrc stats. |
945 TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { | 945 TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { |
946 StatsCollectorForTest stats(&session_); | 946 StatsCollectorForTest stats(&session_); |
947 | 947 |
| 948 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
| 949 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 950 .WillRepeatedly(Return(false)); |
| 951 |
948 const char kVideoChannelName[] = "video"; | 952 const char kVideoChannelName[] = "video"; |
949 InitSessionStats(kVideoChannelName); | 953 InitSessionStats(kVideoChannelName); |
950 EXPECT_CALL(session_, GetTransportStats(_)) | 954 EXPECT_CALL(session_, GetTransportStats(_)) |
951 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 955 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
952 Return(true))); | 956 Return(true))); |
953 EXPECT_CALL(session_, GetTransport(_)) | |
954 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
955 | 957 |
956 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 958 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
957 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 959 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
958 media_channel, NULL, kVideoChannelName, false); | 960 media_channel, NULL, kVideoChannelName, false); |
959 AddOutgoingVideoTrackStats(); | 961 AddOutgoingVideoTrackStats(); |
960 stats.AddStream(stream_); | 962 stats.AddStream(stream_); |
961 | 963 |
962 // Constructs an ssrc stats update. | 964 // Constructs an ssrc stats update. |
963 cricket::VideoSenderInfo video_sender_info; | 965 cricket::VideoSenderInfo video_sender_info; |
964 cricket::VideoMediaInfo stats_read; | 966 cricket::VideoMediaInfo stats_read; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 std::string track_id = ExtractSsrcStatsValue( | 1005 std::string track_id = ExtractSsrcStatsValue( |
1004 reports, StatsReport::kStatsValueNameTrackId); | 1006 reports, StatsReport::kStatsValueNameTrackId); |
1005 EXPECT_EQ(kLocalTrackId, track_id); | 1007 EXPECT_EQ(kLocalTrackId, track_id); |
1006 } | 1008 } |
1007 | 1009 |
1008 // This test verifies that an SSRC object has the identifier of a Transport | 1010 // This test verifies that an SSRC object has the identifier of a Transport |
1009 // stats object, and that this transport stats object exists in stats. | 1011 // stats object, and that this transport stats object exists in stats. |
1010 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { | 1012 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { |
1011 StatsCollectorForTest stats(&session_); | 1013 StatsCollectorForTest stats(&session_); |
1012 | 1014 |
1013 // Ignore unused callback (logspam). | 1015 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
1014 EXPECT_CALL(session_, GetTransport(_)) | 1016 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
1015 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1017 .WillRepeatedly(Return(false)); |
| 1018 |
1016 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1019 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1017 // The content_name known by the video channel. | 1020 // The content_name known by the video channel. |
1018 const std::string kVcName("vcname"); | 1021 const std::string kVcName("vcname"); |
1019 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1022 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
1020 media_channel, NULL, kVcName, false); | 1023 media_channel, NULL, kVcName, false); |
1021 AddOutgoingVideoTrackStats(); | 1024 AddOutgoingVideoTrackStats(); |
1022 stats.AddStream(stream_); | 1025 stats.AddStream(stream_); |
1023 | 1026 |
1024 // Constructs an ssrc stats update. | 1027 // Constructs an ssrc stats update. |
1025 cricket::VideoSenderInfo video_sender_info; | 1028 cricket::VideoSenderInfo video_sender_info; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 const StatsReport* remote_report = FindNthReportByType(reports, | 1091 const StatsReport* remote_report = FindNthReportByType(reports, |
1089 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1092 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
1090 EXPECT_TRUE(remote_report == NULL); | 1093 EXPECT_TRUE(remote_report == NULL); |
1091 } | 1094 } |
1092 | 1095 |
1093 // This test verifies that a remote stats object will be created for | 1096 // This test verifies that a remote stats object will be created for |
1094 // an outgoing SSRC where stats are returned. | 1097 // an outgoing SSRC where stats are returned. |
1095 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { | 1098 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
1096 StatsCollectorForTest stats(&session_); | 1099 StatsCollectorForTest stats(&session_); |
1097 | 1100 |
1098 // Ignore unused callback (logspam). | 1101 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
1099 EXPECT_CALL(session_, GetTransport(_)) | 1102 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
1100 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1103 .WillRepeatedly(Return(false)); |
| 1104 |
1101 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1105 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1102 // The content_name known by the video channel. | 1106 // The content_name known by the video channel. |
1103 const std::string kVcName("vcname"); | 1107 const std::string kVcName("vcname"); |
1104 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1108 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
1105 media_channel, NULL, kVcName, false); | 1109 media_channel, NULL, kVcName, false); |
1106 AddOutgoingVideoTrackStats(); | 1110 AddOutgoingVideoTrackStats(); |
1107 stats.AddStream(stream_); | 1111 stats.AddStream(stream_); |
1108 | 1112 |
1109 // Instruct the session to return stats containing the transport channel. | 1113 // Instruct the session to return stats containing the transport channel. |
1110 InitSessionStats(kVcName); | 1114 InitSessionStats(kVcName); |
(...skipping 26 matching lines...) Expand all Loading... |
1137 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1141 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
1138 EXPECT_FALSE(remote_report == NULL); | 1142 EXPECT_FALSE(remote_report == NULL); |
1139 EXPECT_EQ(12345.678, remote_report->timestamp()); | 1143 EXPECT_EQ(12345.678, remote_report->timestamp()); |
1140 } | 1144 } |
1141 | 1145 |
1142 // This test verifies that the empty track report exists in the returned stats | 1146 // This test verifies that the empty track report exists in the returned stats |
1143 // when StatsCollector::UpdateStats is called with ssrc stats. | 1147 // when StatsCollector::UpdateStats is called with ssrc stats. |
1144 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { | 1148 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { |
1145 StatsCollectorForTest stats(&session_); | 1149 StatsCollectorForTest stats(&session_); |
1146 | 1150 |
| 1151 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
| 1152 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1153 .WillRepeatedly(Return(false)); |
| 1154 |
1147 const char kVideoChannelName[] = "video"; | 1155 const char kVideoChannelName[] = "video"; |
1148 InitSessionStats(kVideoChannelName); | 1156 InitSessionStats(kVideoChannelName); |
1149 EXPECT_CALL(session_, GetTransportStats(_)) | 1157 EXPECT_CALL(session_, GetTransportStats(_)) |
1150 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1158 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
1151 Return(true))); | 1159 Return(true))); |
1152 EXPECT_CALL(session_, GetTransport(_)) | |
1153 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
1154 | 1160 |
1155 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1161 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
1156 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1162 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
1157 media_channel, NULL, kVideoChannelName, false); | 1163 media_channel, NULL, kVideoChannelName, false); |
1158 AddIncomingVideoTrackStats(); | 1164 AddIncomingVideoTrackStats(); |
1159 stats.AddStream(stream_); | 1165 stats.AddStream(stream_); |
1160 | 1166 |
1161 // Constructs an ssrc stats update. | 1167 // Constructs an ssrc stats update. |
1162 cricket::VideoReceiverInfo video_receiver_info; | 1168 cricket::VideoReceiverInfo video_receiver_info; |
1163 cricket::VideoMediaInfo stats_read; | 1169 cricket::VideoMediaInfo stats_read; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 | 1328 |
1323 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), | 1329 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), |
1324 remote_cert, std::vector<std::string>(1, remote_der)); | 1330 remote_cert, std::vector<std::string>(1, remote_der)); |
1325 } | 1331 } |
1326 | 1332 |
1327 // This test verifies that the stats are generated correctly when no | 1333 // This test verifies that the stats are generated correctly when no |
1328 // transport is present. | 1334 // transport is present. |
1329 TEST_F(StatsCollectorTest, NoTransport) { | 1335 TEST_F(StatsCollectorTest, NoTransport) { |
1330 StatsCollectorForTest stats(&session_); | 1336 StatsCollectorForTest stats(&session_); |
1331 | 1337 |
| 1338 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
| 1339 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1340 .WillRepeatedly(Return(false)); |
| 1341 |
1332 StatsReports reports; // returned values. | 1342 StatsReports reports; // returned values. |
1333 | 1343 |
1334 // Fake stats to process. | 1344 // Fake stats to process. |
1335 cricket::TransportChannelStats channel_stats; | 1345 cricket::TransportChannelStats channel_stats; |
1336 channel_stats.component = 1; | 1346 channel_stats.component = 1; |
1337 | 1347 |
1338 cricket::TransportStats transport_stats; | 1348 cricket::TransportStats transport_stats; |
1339 transport_stats.content_name = "audio"; | 1349 transport_stats.content_name = "audio"; |
1340 transport_stats.channel_stats.push_back(channel_stats); | 1350 transport_stats.channel_stats.push_back(channel_stats); |
1341 | 1351 |
1342 cricket::SessionStats session_stats; | 1352 cricket::SessionStats session_stats; |
1343 session_stats.transport_stats[transport_stats.content_name] = | 1353 session_stats.transport_stats[transport_stats.content_name] = |
1344 transport_stats; | 1354 transport_stats; |
1345 | 1355 |
1346 // Configure MockWebRtcSession | 1356 // Configure MockWebRtcSession |
1347 EXPECT_CALL(session_, GetTransport(transport_stats.content_name)) | |
1348 .WillRepeatedly(ReturnNull()); | |
1349 EXPECT_CALL(session_, GetTransportStats(_)) | 1357 EXPECT_CALL(session_, GetTransportStats(_)) |
1350 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 1358 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
1351 Return(true))); | 1359 Return(true))); |
1352 | 1360 |
1353 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1361 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
1354 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1362 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
1355 | 1363 |
1356 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1364 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1357 stats.GetStats(NULL, &reports); | 1365 stats.GetStats(NULL, &reports); |
1358 | 1366 |
(...skipping 22 matching lines...) Expand all Loading... |
1381 reports, | 1389 reports, |
1382 StatsReport::kStatsValueNameSrtpCipher); | 1390 StatsReport::kStatsValueNameSrtpCipher); |
1383 ASSERT_EQ(kNotFound, srtp_cipher); | 1391 ASSERT_EQ(kNotFound, srtp_cipher); |
1384 } | 1392 } |
1385 | 1393 |
1386 // This test verifies that the stats are generated correctly when the transport | 1394 // This test verifies that the stats are generated correctly when the transport |
1387 // does not have any certificates. | 1395 // does not have any certificates. |
1388 TEST_F(StatsCollectorTest, NoCertificates) { | 1396 TEST_F(StatsCollectorTest, NoCertificates) { |
1389 StatsCollectorForTest stats(&session_); | 1397 StatsCollectorForTest stats(&session_); |
1390 | 1398 |
| 1399 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
| 1400 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1401 .WillRepeatedly(Return(false)); |
| 1402 |
1391 StatsReports reports; // returned values. | 1403 StatsReports reports; // returned values. |
1392 | 1404 |
1393 // Fake stats to process. | 1405 // Fake stats to process. |
1394 cricket::TransportChannelStats channel_stats; | 1406 cricket::TransportChannelStats channel_stats; |
1395 channel_stats.component = 1; | 1407 channel_stats.component = 1; |
1396 | 1408 |
1397 cricket::TransportStats transport_stats; | 1409 cricket::TransportStats transport_stats; |
1398 transport_stats.content_name = "audio"; | 1410 transport_stats.content_name = "audio"; |
1399 transport_stats.channel_stats.push_back(channel_stats); | 1411 transport_stats.channel_stats.push_back(channel_stats); |
1400 | 1412 |
1401 cricket::SessionStats session_stats; | 1413 cricket::SessionStats session_stats; |
1402 session_stats.transport_stats[transport_stats.content_name] = | 1414 session_stats.transport_stats[transport_stats.content_name] = |
1403 transport_stats; | 1415 transport_stats; |
1404 | 1416 |
1405 // Fake transport object. | 1417 // Fake transport object. |
1406 rtc::scoped_ptr<cricket::FakeTransport> transport( | 1418 rtc::scoped_ptr<cricket::FakeTransport> transport( |
1407 new cricket::FakeTransport( | 1419 new cricket::FakeTransport( |
1408 session_.signaling_thread(), | |
1409 session_.worker_thread(), | |
1410 transport_stats.content_name)); | 1420 transport_stats.content_name)); |
1411 | 1421 |
1412 // Configure MockWebRtcSession | 1422 // Configure MockWebRtcSession |
1413 EXPECT_CALL(session_, GetTransport(transport_stats.content_name)) | |
1414 .WillRepeatedly(Return(transport.get())); | |
1415 EXPECT_CALL(session_, GetTransportStats(_)) | 1423 EXPECT_CALL(session_, GetTransportStats(_)) |
1416 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 1424 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
1417 Return(true))); | 1425 Return(true))); |
1418 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1426 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
1419 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1427 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
1420 | 1428 |
1421 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1429 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
1422 stats.GetStats(NULL, &reports); | 1430 stats.GetStats(NULL, &reports); |
1423 | 1431 |
1424 // Check that the local certificate is absent. | 1432 // Check that the local certificate is absent. |
(...skipping 25 matching lines...) Expand all Loading... |
1450 | 1458 |
1451 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), | 1459 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), |
1452 remote_cert, std::vector<std::string>()); | 1460 remote_cert, std::vector<std::string>()); |
1453 } | 1461 } |
1454 | 1462 |
1455 // This test verifies that a local stats object can get statistics via | 1463 // This test verifies that a local stats object can get statistics via |
1456 // AudioTrackInterface::GetStats() method. | 1464 // AudioTrackInterface::GetStats() method. |
1457 TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { | 1465 TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { |
1458 StatsCollectorForTest stats(&session_); | 1466 StatsCollectorForTest stats(&session_); |
1459 | 1467 |
1460 // Ignore unused callback (logspam). | 1468 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
1461 EXPECT_CALL(session_, GetTransport(_)) | 1469 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
1462 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1470 .WillRepeatedly(Return(false)); |
1463 | 1471 |
1464 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1472 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1465 // The content_name known by the voice channel. | 1473 // The content_name known by the voice channel. |
1466 const std::string kVcName("vcname"); | 1474 const std::string kVcName("vcname"); |
1467 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1475 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
1468 media_engine_, media_channel, NULL, kVcName, false); | 1476 media_engine_, media_channel, NULL, kVcName, false); |
1469 AddOutgoingAudioTrackStats(); | 1477 AddOutgoingAudioTrackStats(); |
1470 stats.AddStream(stream_); | 1478 stats.AddStream(stream_); |
1471 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1479 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
1472 | 1480 |
(...skipping 11 matching lines...) Expand all Loading... |
1484 const StatsReport* remote_report = FindNthReportByType(reports, | 1492 const StatsReport* remote_report = FindNthReportByType(reports, |
1485 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1493 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
1486 EXPECT_TRUE(remote_report == NULL); | 1494 EXPECT_TRUE(remote_report == NULL); |
1487 } | 1495 } |
1488 | 1496 |
1489 // This test verifies that audio receive streams populate stats reports | 1497 // This test verifies that audio receive streams populate stats reports |
1490 // correctly. | 1498 // correctly. |
1491 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { | 1499 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { |
1492 StatsCollectorForTest stats(&session_); | 1500 StatsCollectorForTest stats(&session_); |
1493 | 1501 |
1494 // Ignore unused callback (logspam). | 1502 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
1495 EXPECT_CALL(session_, GetTransport(_)) | 1503 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
1496 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1504 .WillRepeatedly(Return(false)); |
| 1505 |
1497 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1506 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1498 // The content_name known by the voice channel. | 1507 // The content_name known by the voice channel. |
1499 const std::string kVcName("vcname"); | 1508 const std::string kVcName("vcname"); |
1500 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1509 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
1501 media_engine_, media_channel, NULL, kVcName, false); | 1510 media_engine_, media_channel, NULL, kVcName, false); |
1502 AddIncomingAudioTrackStats(); | 1511 AddIncomingAudioTrackStats(); |
1503 stats.AddStream(stream_); | 1512 stats.AddStream(stream_); |
1504 | 1513 |
1505 cricket::VoiceReceiverInfo voice_receiver_info; | 1514 cricket::VoiceReceiverInfo voice_receiver_info; |
1506 InitVoiceReceiverInfo(&voice_receiver_info); | 1515 InitVoiceReceiverInfo(&voice_receiver_info); |
1507 voice_receiver_info.codec_name = "fake_codec"; | 1516 voice_receiver_info.codec_name = "fake_codec"; |
1508 | 1517 |
1509 cricket::VoiceMediaInfo stats_read; | 1518 cricket::VoiceMediaInfo stats_read; |
1510 StatsReports reports; // returned values. | 1519 StatsReports reports; // returned values. |
1511 SetupAndVerifyAudioTrackStats( | 1520 SetupAndVerifyAudioTrackStats( |
1512 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1521 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
1513 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); | 1522 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); |
1514 } | 1523 } |
1515 | 1524 |
1516 // This test verifies that a local stats object won't update its statistics | 1525 // This test verifies that a local stats object won't update its statistics |
1517 // after a RemoveLocalAudioTrack() call. | 1526 // after a RemoveLocalAudioTrack() call. |
1518 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { | 1527 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { |
1519 StatsCollectorForTest stats(&session_); | 1528 StatsCollectorForTest stats(&session_); |
1520 | 1529 |
1521 // Ignore unused callback (logspam). | 1530 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
1522 EXPECT_CALL(session_, GetTransport(_)) | 1531 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
1523 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1532 .WillRepeatedly(Return(false)); |
| 1533 |
1524 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1534 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1525 // The content_name known by the voice channel. | 1535 // The content_name known by the voice channel. |
1526 const std::string kVcName("vcname"); | 1536 const std::string kVcName("vcname"); |
1527 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1537 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
1528 media_engine_, media_channel, NULL, kVcName, false); | 1538 media_engine_, media_channel, NULL, kVcName, false); |
1529 AddOutgoingAudioTrackStats(); | 1539 AddOutgoingAudioTrackStats(); |
1530 stats.AddStream(stream_); | 1540 stats.AddStream(stream_); |
1531 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1541 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
1532 | 1542 |
1533 // Instruct the session to return stats containing the transport channel. | 1543 // Instruct the session to return stats containing the transport channel. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 // AudioTrackInterface::GetSignalValue() and | 1580 // AudioTrackInterface::GetSignalValue() and |
1571 // AudioProcessorInterface::AudioProcessorStats::GetStats(); | 1581 // AudioProcessorInterface::AudioProcessorStats::GetStats(); |
1572 VerifyVoiceSenderInfoReport(report, voice_sender_info); | 1582 VerifyVoiceSenderInfoReport(report, voice_sender_info); |
1573 } | 1583 } |
1574 | 1584 |
1575 // This test verifies that when ongoing and incoming audio tracks are using | 1585 // This test verifies that when ongoing and incoming audio tracks are using |
1576 // the same ssrc, they populate stats reports correctly. | 1586 // the same ssrc, they populate stats reports correctly. |
1577 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { | 1587 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { |
1578 StatsCollectorForTest stats(&session_); | 1588 StatsCollectorForTest stats(&session_); |
1579 | 1589 |
1580 // Ignore unused callback (logspam). | 1590 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
1581 EXPECT_CALL(session_, GetTransport(_)) | 1591 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
1582 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1592 .WillRepeatedly(Return(false)); |
| 1593 |
1583 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1594 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1584 // The content_name known by the voice channel. | 1595 // The content_name known by the voice channel. |
1585 const std::string kVcName("vcname"); | 1596 const std::string kVcName("vcname"); |
1586 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1597 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
1587 media_engine_, media_channel, NULL, kVcName, false); | 1598 media_engine_, media_channel, NULL, kVcName, false); |
1588 | 1599 |
1589 // Create a local stream with a local audio track and adds it to the stats. | 1600 // Create a local stream with a local audio track and adds it to the stats. |
1590 AddOutgoingAudioTrackStats(); | 1601 AddOutgoingAudioTrackStats(); |
1591 stats.AddStream(stream_); | 1602 stats.AddStream(stream_); |
1592 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1603 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info); | 1666 VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info); |
1656 } | 1667 } |
1657 | 1668 |
1658 // This test verifies that when two outgoing audio tracks are using the same | 1669 // This test verifies that when two outgoing audio tracks are using the same |
1659 // ssrc at different times, they populate stats reports correctly. | 1670 // ssrc at different times, they populate stats reports correctly. |
1660 // TODO(xians): Figure out if it is possible to encapsulate the setup and | 1671 // TODO(xians): Figure out if it is possible to encapsulate the setup and |
1661 // avoid duplication of code in test cases. | 1672 // avoid duplication of code in test cases. |
1662 TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { | 1673 TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { |
1663 StatsCollectorForTest stats(&session_); | 1674 StatsCollectorForTest stats(&session_); |
1664 | 1675 |
1665 // Ignore unused callback (logspam). | 1676 EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false)); |
1666 EXPECT_CALL(session_, GetTransport(_)) | 1677 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
1667 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1678 .WillRepeatedly(Return(false)); |
| 1679 |
1668 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1680 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
1669 // The content_name known by the voice channel. | 1681 // The content_name known by the voice channel. |
1670 const std::string kVcName("vcname"); | 1682 const std::string kVcName("vcname"); |
1671 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1683 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
1672 media_engine_, media_channel, NULL, kVcName, false); | 1684 media_engine_, media_channel, NULL, kVcName, false); |
1673 | 1685 |
1674 // Create a local stream with a local audio track and adds it to the stats. | 1686 // Create a local stream with a local audio track and adds it to the stats. |
1675 AddOutgoingAudioTrackStats(); | 1687 AddOutgoingAudioTrackStats(); |
1676 stats.AddStream(stream_); | 1688 stats.AddStream(stream_); |
1677 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1689 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
(...skipping 24 matching lines...) Expand all Loading... |
1702 cricket::VoiceSenderInfo new_voice_sender_info; | 1714 cricket::VoiceSenderInfo new_voice_sender_info; |
1703 InitVoiceSenderInfo(&new_voice_sender_info); | 1715 InitVoiceSenderInfo(&new_voice_sender_info); |
1704 cricket::VoiceMediaInfo new_stats_read; | 1716 cricket::VoiceMediaInfo new_stats_read; |
1705 reports.clear(); | 1717 reports.clear(); |
1706 SetupAndVerifyAudioTrackStats( | 1718 SetupAndVerifyAudioTrackStats( |
1707 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1719 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, |
1708 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1720 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); |
1709 } | 1721 } |
1710 | 1722 |
1711 } // namespace webrtc | 1723 } // namespace webrtc |
OLD | NEW |