| 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(GetCertificate, |
| 95 bool(const std::string& content_name, |
| 96 rtc::scoped_refptr<rtc::RTCCertificate>* certificate)); |
| 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 certificate to report |
| 659 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate( | 666 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate( |
| 660 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::FakeSSLIdentity>( | 667 rtc::RTCCertificate::Create( |
| 661 new rtc::FakeSSLIdentity(local_cert)).Pass())); | 668 rtc::scoped_ptr<rtc::FakeSSLIdentity>( |
| 662 rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert_copy( | 669 new rtc::FakeSSLIdentity(local_cert)).Pass())); |
| 663 remote_cert.GetReference()); | |
| 664 | |
| 665 // Fake transport object. | |
| 666 rtc::scoped_ptr<cricket::FakeTransport> transport( | |
| 667 new cricket::FakeTransport( | |
| 668 session_.signaling_thread(), | |
| 669 session_.worker_thread(), | |
| 670 transport_stats.content_name)); | |
| 671 transport->SetCertificate(local_certificate); | |
| 672 cricket::FakeTransportChannel* channel = | |
| 673 static_cast<cricket::FakeTransportChannel*>( | |
| 674 transport->CreateChannel(channel_stats.component)); | |
| 675 EXPECT_FALSE(channel == NULL); | |
| 676 channel->SetRemoteCertificate(remote_cert_copy.get()); | |
| 677 | 670 |
| 678 // Configure MockWebRtcSession | 671 // Configure MockWebRtcSession |
| 679 EXPECT_CALL(session_, GetTransport(transport_stats.content_name)) | 672 EXPECT_CALL(session_, GetCertificate(transport_stats.content_name, _)) |
| 680 .WillRepeatedly(Return(transport.get())); | 673 .WillOnce(DoAll(SetArgPointee<1>(local_certificate), Return(true))); |
| 674 EXPECT_CALL(session_, GetRemoteCertificate(transport_stats.content_name, _)) |
| 675 .WillOnce( |
| 676 DoAll(SetArgPointee<1>(remote_cert.GetReference()), Return(true))); |
| 681 EXPECT_CALL(session_, GetTransportStats(_)) | 677 EXPECT_CALL(session_, GetTransportStats(_)) |
| 682 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 678 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
| 683 Return(true))); | 679 Return(true))); |
| 684 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 680 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 685 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 681 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 686 | 682 |
| 687 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 683 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 688 | 684 |
| 689 stats.GetStats(NULL, &reports); | 685 stats.GetStats(NULL, &reports); |
| 690 | 686 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 StatsReport::kStatsValueNameState)); | 780 StatsReport::kStatsValueNameState)); |
| 785 EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, | 781 EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, |
| 786 reports, | 782 reports, |
| 787 StatsReport::kStatsValueNameProtocol)); | 783 StatsReport::kStatsValueNameProtocol)); |
| 788 } | 784 } |
| 789 | 785 |
| 790 // This test verifies that 64-bit counters are passed successfully. | 786 // This test verifies that 64-bit counters are passed successfully. |
| 791 TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { | 787 TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { |
| 792 StatsCollectorForTest stats(&session_); | 788 StatsCollectorForTest stats(&session_); |
| 793 | 789 |
| 790 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 791 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 792 .WillRepeatedly(Return(false)); |
| 793 |
| 794 const char kVideoChannelName[] = "video"; | 794 const char kVideoChannelName[] = "video"; |
| 795 | 795 |
| 796 InitSessionStats(kVideoChannelName); | 796 InitSessionStats(kVideoChannelName); |
| 797 EXPECT_CALL(session_, GetTransportStats(_)) | 797 EXPECT_CALL(session_, GetTransportStats(_)) |
| 798 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 798 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 799 Return(true))); | 799 Return(true))); |
| 800 EXPECT_CALL(session_, GetTransport(_)) | |
| 801 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
| 802 | 800 |
| 803 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 801 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 804 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 802 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 805 media_channel, NULL, kVideoChannelName, false); | 803 media_channel, NULL, kVideoChannelName, false); |
| 806 StatsReports reports; // returned values. | 804 StatsReports reports; // returned values. |
| 807 cricket::VideoSenderInfo video_sender_info; | 805 cricket::VideoSenderInfo video_sender_info; |
| 808 cricket::VideoMediaInfo stats_read; | 806 cricket::VideoMediaInfo stats_read; |
| 809 // The number of bytes must be larger than 0xFFFFFFFF for this test. | 807 // The number of bytes must be larger than 0xFFFFFFFF for this test. |
| 810 const int64 kBytesSent = 12345678901234LL; | 808 const int64 kBytesSent = 12345678901234LL; |
| 811 const std::string kBytesSentString("12345678901234"); | 809 const std::string kBytesSentString("12345678901234"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 827 stats.GetStats(NULL, &reports); | 825 stats.GetStats(NULL, &reports); |
| 828 std::string result = ExtractSsrcStatsValue(reports, | 826 std::string result = ExtractSsrcStatsValue(reports, |
| 829 StatsReport::kStatsValueNameBytesSent); | 827 StatsReport::kStatsValueNameBytesSent); |
| 830 EXPECT_EQ(kBytesSentString, result); | 828 EXPECT_EQ(kBytesSentString, result); |
| 831 } | 829 } |
| 832 | 830 |
| 833 // Test that BWE information is reported via stats. | 831 // Test that BWE information is reported via stats. |
| 834 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { | 832 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { |
| 835 StatsCollectorForTest stats(&session_); | 833 StatsCollectorForTest stats(&session_); |
| 836 | 834 |
| 835 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 836 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 837 .WillRepeatedly(Return(false)); |
| 838 |
| 837 const char kVideoChannelName[] = "video"; | 839 const char kVideoChannelName[] = "video"; |
| 838 | 840 |
| 839 InitSessionStats(kVideoChannelName); | 841 InitSessionStats(kVideoChannelName); |
| 840 EXPECT_CALL(session_, GetTransportStats(_)) | 842 EXPECT_CALL(session_, GetTransportStats(_)) |
| 841 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 843 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 842 Return(true))); | 844 Return(true))); |
| 843 EXPECT_CALL(session_, GetTransport(_)) | |
| 844 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
| 845 | 845 |
| 846 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 846 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 847 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 847 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 848 media_channel, NULL, kVideoChannelName, false); | 848 media_channel, NULL, kVideoChannelName, false); |
| 849 | 849 |
| 850 StatsReports reports; // returned values. | 850 StatsReports reports; // returned values. |
| 851 cricket::VideoSenderInfo video_sender_info; | 851 cricket::VideoSenderInfo video_sender_info; |
| 852 cricket::VideoMediaInfo stats_read; | 852 cricket::VideoMediaInfo stats_read; |
| 853 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and | 853 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and |
| 854 // BWE. | 854 // BWE. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 reports, | 940 reports, |
| 941 StatsReport::kStatsValueNameTrackId); | 941 StatsReport::kStatsValueNameTrackId); |
| 942 EXPECT_EQ(kLocalTrackId, trackValue); | 942 EXPECT_EQ(kLocalTrackId, trackValue); |
| 943 } | 943 } |
| 944 | 944 |
| 945 // This test verifies that the empty track report exists in the returned stats | 945 // This test verifies that the empty track report exists in the returned stats |
| 946 // when StatsCollector::UpdateStats is called with ssrc stats. | 946 // when StatsCollector::UpdateStats is called with ssrc stats. |
| 947 TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { | 947 TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { |
| 948 StatsCollectorForTest stats(&session_); | 948 StatsCollectorForTest stats(&session_); |
| 949 | 949 |
| 950 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 951 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 952 .WillRepeatedly(Return(false)); |
| 953 |
| 950 const char kVideoChannelName[] = "video"; | 954 const char kVideoChannelName[] = "video"; |
| 951 InitSessionStats(kVideoChannelName); | 955 InitSessionStats(kVideoChannelName); |
| 952 EXPECT_CALL(session_, GetTransportStats(_)) | 956 EXPECT_CALL(session_, GetTransportStats(_)) |
| 953 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 957 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 954 Return(true))); | 958 Return(true))); |
| 955 EXPECT_CALL(session_, GetTransport(_)) | |
| 956 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
| 957 | 959 |
| 958 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 960 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 959 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 961 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 960 media_channel, NULL, kVideoChannelName, false); | 962 media_channel, NULL, kVideoChannelName, false); |
| 961 AddOutgoingVideoTrackStats(); | 963 AddOutgoingVideoTrackStats(); |
| 962 stats.AddStream(stream_); | 964 stats.AddStream(stream_); |
| 963 | 965 |
| 964 // Constructs an ssrc stats update. | 966 // Constructs an ssrc stats update. |
| 965 cricket::VideoSenderInfo video_sender_info; | 967 cricket::VideoSenderInfo video_sender_info; |
| 966 cricket::VideoMediaInfo stats_read; | 968 cricket::VideoMediaInfo stats_read; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 std::string track_id = ExtractSsrcStatsValue( | 1007 std::string track_id = ExtractSsrcStatsValue( |
| 1006 reports, StatsReport::kStatsValueNameTrackId); | 1008 reports, StatsReport::kStatsValueNameTrackId); |
| 1007 EXPECT_EQ(kLocalTrackId, track_id); | 1009 EXPECT_EQ(kLocalTrackId, track_id); |
| 1008 } | 1010 } |
| 1009 | 1011 |
| 1010 // This test verifies that an SSRC object has the identifier of a Transport | 1012 // This test verifies that an SSRC object has the identifier of a Transport |
| 1011 // stats object, and that this transport stats object exists in stats. | 1013 // stats object, and that this transport stats object exists in stats. |
| 1012 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { | 1014 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { |
| 1013 StatsCollectorForTest stats(&session_); | 1015 StatsCollectorForTest stats(&session_); |
| 1014 | 1016 |
| 1015 // Ignore unused callback (logspam). | 1017 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1016 EXPECT_CALL(session_, GetTransport(_)) | 1018 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1017 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1019 .WillRepeatedly(Return(false)); |
| 1020 |
| 1018 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1021 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1019 // The content_name known by the video channel. | 1022 // The content_name known by the video channel. |
| 1020 const std::string kVcName("vcname"); | 1023 const std::string kVcName("vcname"); |
| 1021 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1024 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 1022 media_channel, NULL, kVcName, false); | 1025 media_channel, NULL, kVcName, false); |
| 1023 AddOutgoingVideoTrackStats(); | 1026 AddOutgoingVideoTrackStats(); |
| 1024 stats.AddStream(stream_); | 1027 stats.AddStream(stream_); |
| 1025 | 1028 |
| 1026 // Constructs an ssrc stats update. | 1029 // Constructs an ssrc stats update. |
| 1027 cricket::VideoSenderInfo video_sender_info; | 1030 cricket::VideoSenderInfo video_sender_info; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 const StatsReport* remote_report = FindNthReportByType(reports, | 1093 const StatsReport* remote_report = FindNthReportByType(reports, |
| 1091 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1094 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
| 1092 EXPECT_TRUE(remote_report == NULL); | 1095 EXPECT_TRUE(remote_report == NULL); |
| 1093 } | 1096 } |
| 1094 | 1097 |
| 1095 // This test verifies that a remote stats object will be created for | 1098 // This test verifies that a remote stats object will be created for |
| 1096 // an outgoing SSRC where stats are returned. | 1099 // an outgoing SSRC where stats are returned. |
| 1097 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { | 1100 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
| 1098 StatsCollectorForTest stats(&session_); | 1101 StatsCollectorForTest stats(&session_); |
| 1099 | 1102 |
| 1100 // Ignore unused callback (logspam). | 1103 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1101 EXPECT_CALL(session_, GetTransport(_)) | 1104 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1102 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1105 .WillRepeatedly(Return(false)); |
| 1106 |
| 1103 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1107 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1104 // The content_name known by the video channel. | 1108 // The content_name known by the video channel. |
| 1105 const std::string kVcName("vcname"); | 1109 const std::string kVcName("vcname"); |
| 1106 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1110 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 1107 media_channel, NULL, kVcName, false); | 1111 media_channel, NULL, kVcName, false); |
| 1108 AddOutgoingVideoTrackStats(); | 1112 AddOutgoingVideoTrackStats(); |
| 1109 stats.AddStream(stream_); | 1113 stats.AddStream(stream_); |
| 1110 | 1114 |
| 1111 // Instruct the session to return stats containing the transport channel. | 1115 // Instruct the session to return stats containing the transport channel. |
| 1112 InitSessionStats(kVcName); | 1116 InitSessionStats(kVcName); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1139 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1143 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
| 1140 EXPECT_FALSE(remote_report == NULL); | 1144 EXPECT_FALSE(remote_report == NULL); |
| 1141 EXPECT_EQ(12345.678, remote_report->timestamp()); | 1145 EXPECT_EQ(12345.678, remote_report->timestamp()); |
| 1142 } | 1146 } |
| 1143 | 1147 |
| 1144 // This test verifies that the empty track report exists in the returned stats | 1148 // This test verifies that the empty track report exists in the returned stats |
| 1145 // when StatsCollector::UpdateStats is called with ssrc stats. | 1149 // when StatsCollector::UpdateStats is called with ssrc stats. |
| 1146 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { | 1150 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { |
| 1147 StatsCollectorForTest stats(&session_); | 1151 StatsCollectorForTest stats(&session_); |
| 1148 | 1152 |
| 1153 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1154 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1155 .WillRepeatedly(Return(false)); |
| 1156 |
| 1149 const char kVideoChannelName[] = "video"; | 1157 const char kVideoChannelName[] = "video"; |
| 1150 InitSessionStats(kVideoChannelName); | 1158 InitSessionStats(kVideoChannelName); |
| 1151 EXPECT_CALL(session_, GetTransportStats(_)) | 1159 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1152 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1160 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 1153 Return(true))); | 1161 Return(true))); |
| 1154 EXPECT_CALL(session_, GetTransport(_)) | |
| 1155 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
| 1156 | 1162 |
| 1157 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1163 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1158 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1164 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 1159 media_channel, NULL, kVideoChannelName, false); | 1165 media_channel, NULL, kVideoChannelName, false); |
| 1160 AddIncomingVideoTrackStats(); | 1166 AddIncomingVideoTrackStats(); |
| 1161 stats.AddStream(stream_); | 1167 stats.AddStream(stream_); |
| 1162 | 1168 |
| 1163 // Constructs an ssrc stats update. | 1169 // Constructs an ssrc stats update. |
| 1164 cricket::VideoReceiverInfo video_receiver_info; | 1170 cricket::VideoReceiverInfo video_receiver_info; |
| 1165 cricket::VideoMediaInfo stats_read; | 1171 cricket::VideoMediaInfo stats_read; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 | 1330 |
| 1325 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), | 1331 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), |
| 1326 remote_cert, std::vector<std::string>(1, remote_der)); | 1332 remote_cert, std::vector<std::string>(1, remote_der)); |
| 1327 } | 1333 } |
| 1328 | 1334 |
| 1329 // This test verifies that the stats are generated correctly when no | 1335 // This test verifies that the stats are generated correctly when no |
| 1330 // transport is present. | 1336 // transport is present. |
| 1331 TEST_F(StatsCollectorTest, NoTransport) { | 1337 TEST_F(StatsCollectorTest, NoTransport) { |
| 1332 StatsCollectorForTest stats(&session_); | 1338 StatsCollectorForTest stats(&session_); |
| 1333 | 1339 |
| 1340 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1341 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1342 .WillRepeatedly(Return(false)); |
| 1343 |
| 1334 StatsReports reports; // returned values. | 1344 StatsReports reports; // returned values. |
| 1335 | 1345 |
| 1336 // Fake stats to process. | 1346 // Fake stats to process. |
| 1337 cricket::TransportChannelStats channel_stats; | 1347 cricket::TransportChannelStats channel_stats; |
| 1338 channel_stats.component = 1; | 1348 channel_stats.component = 1; |
| 1339 | 1349 |
| 1340 cricket::TransportStats transport_stats; | 1350 cricket::TransportStats transport_stats; |
| 1341 transport_stats.content_name = "audio"; | 1351 transport_stats.content_name = "audio"; |
| 1342 transport_stats.channel_stats.push_back(channel_stats); | 1352 transport_stats.channel_stats.push_back(channel_stats); |
| 1343 | 1353 |
| 1344 cricket::SessionStats session_stats; | 1354 cricket::SessionStats session_stats; |
| 1345 session_stats.transport_stats[transport_stats.content_name] = | 1355 session_stats.transport_stats[transport_stats.content_name] = |
| 1346 transport_stats; | 1356 transport_stats; |
| 1347 | 1357 |
| 1348 // Configure MockWebRtcSession | 1358 // Configure MockWebRtcSession |
| 1349 EXPECT_CALL(session_, GetTransport(transport_stats.content_name)) | |
| 1350 .WillRepeatedly(ReturnNull()); | |
| 1351 EXPECT_CALL(session_, GetTransportStats(_)) | 1359 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1352 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 1360 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
| 1353 Return(true))); | 1361 Return(true))); |
| 1354 | 1362 |
| 1355 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1363 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 1356 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1364 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 1357 | 1365 |
| 1358 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1366 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 1359 stats.GetStats(NULL, &reports); | 1367 stats.GetStats(NULL, &reports); |
| 1360 | 1368 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1383 reports, | 1391 reports, |
| 1384 StatsReport::kStatsValueNameSrtpCipher); | 1392 StatsReport::kStatsValueNameSrtpCipher); |
| 1385 ASSERT_EQ(kNotFound, srtp_cipher); | 1393 ASSERT_EQ(kNotFound, srtp_cipher); |
| 1386 } | 1394 } |
| 1387 | 1395 |
| 1388 // This test verifies that the stats are generated correctly when the transport | 1396 // This test verifies that the stats are generated correctly when the transport |
| 1389 // does not have any certificates. | 1397 // does not have any certificates. |
| 1390 TEST_F(StatsCollectorTest, NoCertificates) { | 1398 TEST_F(StatsCollectorTest, NoCertificates) { |
| 1391 StatsCollectorForTest stats(&session_); | 1399 StatsCollectorForTest stats(&session_); |
| 1392 | 1400 |
| 1401 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1402 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1403 .WillRepeatedly(Return(false)); |
| 1404 |
| 1393 StatsReports reports; // returned values. | 1405 StatsReports reports; // returned values. |
| 1394 | 1406 |
| 1395 // Fake stats to process. | 1407 // Fake stats to process. |
| 1396 cricket::TransportChannelStats channel_stats; | 1408 cricket::TransportChannelStats channel_stats; |
| 1397 channel_stats.component = 1; | 1409 channel_stats.component = 1; |
| 1398 | 1410 |
| 1399 cricket::TransportStats transport_stats; | 1411 cricket::TransportStats transport_stats; |
| 1400 transport_stats.content_name = "audio"; | 1412 transport_stats.content_name = "audio"; |
| 1401 transport_stats.channel_stats.push_back(channel_stats); | 1413 transport_stats.channel_stats.push_back(channel_stats); |
| 1402 | 1414 |
| 1403 cricket::SessionStats session_stats; | 1415 cricket::SessionStats session_stats; |
| 1404 session_stats.transport_stats[transport_stats.content_name] = | 1416 session_stats.transport_stats[transport_stats.content_name] = |
| 1405 transport_stats; | 1417 transport_stats; |
| 1406 | 1418 |
| 1407 // Fake transport object. | 1419 // Fake transport object. |
| 1408 rtc::scoped_ptr<cricket::FakeTransport> transport( | 1420 rtc::scoped_ptr<cricket::FakeTransport> transport( |
| 1409 new cricket::FakeTransport( | 1421 new cricket::FakeTransport( |
| 1410 session_.signaling_thread(), | |
| 1411 session_.worker_thread(), | |
| 1412 transport_stats.content_name)); | 1422 transport_stats.content_name)); |
| 1413 | 1423 |
| 1414 // Configure MockWebRtcSession | 1424 // Configure MockWebRtcSession |
| 1415 EXPECT_CALL(session_, GetTransport(transport_stats.content_name)) | |
| 1416 .WillRepeatedly(Return(transport.get())); | |
| 1417 EXPECT_CALL(session_, GetTransportStats(_)) | 1425 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1418 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 1426 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
| 1419 Return(true))); | 1427 Return(true))); |
| 1420 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1428 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 1421 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1429 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 1422 | 1430 |
| 1423 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1431 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 1424 stats.GetStats(NULL, &reports); | 1432 stats.GetStats(NULL, &reports); |
| 1425 | 1433 |
| 1426 // Check that the local certificate is absent. | 1434 // Check that the local certificate is absent. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1452 | 1460 |
| 1453 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), | 1461 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), |
| 1454 remote_cert, std::vector<std::string>()); | 1462 remote_cert, std::vector<std::string>()); |
| 1455 } | 1463 } |
| 1456 | 1464 |
| 1457 // This test verifies that a local stats object can get statistics via | 1465 // This test verifies that a local stats object can get statistics via |
| 1458 // AudioTrackInterface::GetStats() method. | 1466 // AudioTrackInterface::GetStats() method. |
| 1459 TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { | 1467 TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { |
| 1460 StatsCollectorForTest stats(&session_); | 1468 StatsCollectorForTest stats(&session_); |
| 1461 | 1469 |
| 1462 // Ignore unused callback (logspam). | 1470 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1463 EXPECT_CALL(session_, GetTransport(_)) | 1471 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1464 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1472 .WillRepeatedly(Return(false)); |
| 1465 | 1473 |
| 1466 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1474 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1467 // The content_name known by the voice channel. | 1475 // The content_name known by the voice channel. |
| 1468 const std::string kVcName("vcname"); | 1476 const std::string kVcName("vcname"); |
| 1469 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1477 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1470 media_engine_, media_channel, NULL, kVcName, false); | 1478 media_engine_, media_channel, NULL, kVcName, false); |
| 1471 AddOutgoingAudioTrackStats(); | 1479 AddOutgoingAudioTrackStats(); |
| 1472 stats.AddStream(stream_); | 1480 stats.AddStream(stream_); |
| 1473 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1481 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
| 1474 | 1482 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1486 const StatsReport* remote_report = FindNthReportByType(reports, | 1494 const StatsReport* remote_report = FindNthReportByType(reports, |
| 1487 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1495 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
| 1488 EXPECT_TRUE(remote_report == NULL); | 1496 EXPECT_TRUE(remote_report == NULL); |
| 1489 } | 1497 } |
| 1490 | 1498 |
| 1491 // This test verifies that audio receive streams populate stats reports | 1499 // This test verifies that audio receive streams populate stats reports |
| 1492 // correctly. | 1500 // correctly. |
| 1493 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { | 1501 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { |
| 1494 StatsCollectorForTest stats(&session_); | 1502 StatsCollectorForTest stats(&session_); |
| 1495 | 1503 |
| 1496 // Ignore unused callback (logspam). | 1504 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1497 EXPECT_CALL(session_, GetTransport(_)) | 1505 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1498 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1506 .WillRepeatedly(Return(false)); |
| 1507 |
| 1499 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1508 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1500 // The content_name known by the voice channel. | 1509 // The content_name known by the voice channel. |
| 1501 const std::string kVcName("vcname"); | 1510 const std::string kVcName("vcname"); |
| 1502 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1511 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1503 media_engine_, media_channel, NULL, kVcName, false); | 1512 media_engine_, media_channel, NULL, kVcName, false); |
| 1504 AddIncomingAudioTrackStats(); | 1513 AddIncomingAudioTrackStats(); |
| 1505 stats.AddStream(stream_); | 1514 stats.AddStream(stream_); |
| 1506 | 1515 |
| 1507 cricket::VoiceReceiverInfo voice_receiver_info; | 1516 cricket::VoiceReceiverInfo voice_receiver_info; |
| 1508 InitVoiceReceiverInfo(&voice_receiver_info); | 1517 InitVoiceReceiverInfo(&voice_receiver_info); |
| 1509 voice_receiver_info.codec_name = "fake_codec"; | 1518 voice_receiver_info.codec_name = "fake_codec"; |
| 1510 | 1519 |
| 1511 cricket::VoiceMediaInfo stats_read; | 1520 cricket::VoiceMediaInfo stats_read; |
| 1512 StatsReports reports; // returned values. | 1521 StatsReports reports; // returned values. |
| 1513 SetupAndVerifyAudioTrackStats( | 1522 SetupAndVerifyAudioTrackStats( |
| 1514 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1523 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1515 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); | 1524 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); |
| 1516 } | 1525 } |
| 1517 | 1526 |
| 1518 // This test verifies that a local stats object won't update its statistics | 1527 // This test verifies that a local stats object won't update its statistics |
| 1519 // after a RemoveLocalAudioTrack() call. | 1528 // after a RemoveLocalAudioTrack() call. |
| 1520 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { | 1529 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { |
| 1521 StatsCollectorForTest stats(&session_); | 1530 StatsCollectorForTest stats(&session_); |
| 1522 | 1531 |
| 1523 // Ignore unused callback (logspam). | 1532 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1524 EXPECT_CALL(session_, GetTransport(_)) | 1533 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1525 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1534 .WillRepeatedly(Return(false)); |
| 1535 |
| 1526 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1536 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1527 // The content_name known by the voice channel. | 1537 // The content_name known by the voice channel. |
| 1528 const std::string kVcName("vcname"); | 1538 const std::string kVcName("vcname"); |
| 1529 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1539 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1530 media_engine_, media_channel, NULL, kVcName, false); | 1540 media_engine_, media_channel, NULL, kVcName, false); |
| 1531 AddOutgoingAudioTrackStats(); | 1541 AddOutgoingAudioTrackStats(); |
| 1532 stats.AddStream(stream_); | 1542 stats.AddStream(stream_); |
| 1533 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1543 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
| 1534 | 1544 |
| 1535 // Instruct the session to return stats containing the transport channel. | 1545 // Instruct the session to return stats containing the transport channel. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 // AudioTrackInterface::GetSignalValue() and | 1582 // AudioTrackInterface::GetSignalValue() and |
| 1573 // AudioProcessorInterface::AudioProcessorStats::GetStats(); | 1583 // AudioProcessorInterface::AudioProcessorStats::GetStats(); |
| 1574 VerifyVoiceSenderInfoReport(report, voice_sender_info); | 1584 VerifyVoiceSenderInfoReport(report, voice_sender_info); |
| 1575 } | 1585 } |
| 1576 | 1586 |
| 1577 // This test verifies that when ongoing and incoming audio tracks are using | 1587 // This test verifies that when ongoing and incoming audio tracks are using |
| 1578 // the same ssrc, they populate stats reports correctly. | 1588 // the same ssrc, they populate stats reports correctly. |
| 1579 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { | 1589 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { |
| 1580 StatsCollectorForTest stats(&session_); | 1590 StatsCollectorForTest stats(&session_); |
| 1581 | 1591 |
| 1582 // Ignore unused callback (logspam). | 1592 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1583 EXPECT_CALL(session_, GetTransport(_)) | 1593 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1584 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1594 .WillRepeatedly(Return(false)); |
| 1595 |
| 1585 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1596 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1586 // The content_name known by the voice channel. | 1597 // The content_name known by the voice channel. |
| 1587 const std::string kVcName("vcname"); | 1598 const std::string kVcName("vcname"); |
| 1588 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1599 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1589 media_engine_, media_channel, NULL, kVcName, false); | 1600 media_engine_, media_channel, NULL, kVcName, false); |
| 1590 | 1601 |
| 1591 // Create a local stream with a local audio track and adds it to the stats. | 1602 // Create a local stream with a local audio track and adds it to the stats. |
| 1592 AddOutgoingAudioTrackStats(); | 1603 AddOutgoingAudioTrackStats(); |
| 1593 stats.AddStream(stream_); | 1604 stats.AddStream(stream_); |
| 1594 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1605 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info); | 1668 VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info); |
| 1658 } | 1669 } |
| 1659 | 1670 |
| 1660 // This test verifies that when two outgoing audio tracks are using the same | 1671 // This test verifies that when two outgoing audio tracks are using the same |
| 1661 // ssrc at different times, they populate stats reports correctly. | 1672 // ssrc at different times, they populate stats reports correctly. |
| 1662 // TODO(xians): Figure out if it is possible to encapsulate the setup and | 1673 // TODO(xians): Figure out if it is possible to encapsulate the setup and |
| 1663 // avoid duplication of code in test cases. | 1674 // avoid duplication of code in test cases. |
| 1664 TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { | 1675 TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { |
| 1665 StatsCollectorForTest stats(&session_); | 1676 StatsCollectorForTest stats(&session_); |
| 1666 | 1677 |
| 1667 // Ignore unused callback (logspam). | 1678 EXPECT_CALL(session_, GetCertificate(_, _)).WillRepeatedly(Return(false)); |
| 1668 EXPECT_CALL(session_, GetTransport(_)) | 1679 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1669 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1680 .WillRepeatedly(Return(false)); |
| 1681 |
| 1670 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1682 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1671 // The content_name known by the voice channel. | 1683 // The content_name known by the voice channel. |
| 1672 const std::string kVcName("vcname"); | 1684 const std::string kVcName("vcname"); |
| 1673 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1685 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1674 media_engine_, media_channel, NULL, kVcName, false); | 1686 media_engine_, media_channel, NULL, kVcName, false); |
| 1675 | 1687 |
| 1676 // Create a local stream with a local audio track and adds it to the stats. | 1688 // Create a local stream with a local audio track and adds it to the stats. |
| 1677 AddOutgoingAudioTrackStats(); | 1689 AddOutgoingAudioTrackStats(); |
| 1678 stats.AddStream(stream_); | 1690 stats.AddStream(stream_); |
| 1679 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1691 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1704 cricket::VoiceSenderInfo new_voice_sender_info; | 1716 cricket::VoiceSenderInfo new_voice_sender_info; |
| 1705 InitVoiceSenderInfo(&new_voice_sender_info); | 1717 InitVoiceSenderInfo(&new_voice_sender_info); |
| 1706 cricket::VoiceMediaInfo new_stats_read; | 1718 cricket::VoiceMediaInfo new_stats_read; |
| 1707 reports.clear(); | 1719 reports.clear(); |
| 1708 SetupAndVerifyAudioTrackStats( | 1720 SetupAndVerifyAudioTrackStats( |
| 1709 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1721 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1710 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1722 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); |
| 1711 } | 1723 } |
| 1712 | 1724 |
| 1713 } // namespace webrtc | 1725 } // namespace webrtc |
| OLD | NEW |