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