| 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(GetLocalCertificate, |
| 95 bool(const std::string& transport_name, |
| 96 rtc::scoped_refptr<rtc::RTCCertificate>* certificate)); |
| 97 MOCK_METHOD2(GetRemoteCertificate, |
| 98 bool(const std::string& transport_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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 ~StatsCollectorTest() {} | 501 ~StatsCollectorTest() {} |
| 495 | 502 |
| 496 // This creates a standard setup with a transport called "trspname" | 503 // This creates a standard setup with a transport called "trspname" |
| 497 // having one transport channel | 504 // having one transport channel |
| 498 // and the specified virtual connection name. | 505 // and the specified virtual connection name. |
| 499 void InitSessionStats(const std::string& vc_name) { | 506 void InitSessionStats(const std::string& vc_name) { |
| 500 const std::string kTransportName("trspname"); | 507 const std::string kTransportName("trspname"); |
| 501 cricket::TransportStats transport_stats; | 508 cricket::TransportStats transport_stats; |
| 502 cricket::TransportChannelStats channel_stats; | 509 cricket::TransportChannelStats channel_stats; |
| 503 channel_stats.component = 1; | 510 channel_stats.component = 1; |
| 504 transport_stats.content_name = kTransportName; | 511 transport_stats.transport_name = kTransportName; |
| 505 transport_stats.channel_stats.push_back(channel_stats); | 512 transport_stats.channel_stats.push_back(channel_stats); |
| 506 | 513 |
| 507 session_stats_.transport_stats[kTransportName] = transport_stats; | 514 session_stats_.transport_stats[kTransportName] = transport_stats; |
| 508 session_stats_.proxy_to_transport[vc_name] = kTransportName; | 515 session_stats_.proxy_to_transport[vc_name] = kTransportName; |
| 509 } | 516 } |
| 510 | 517 |
| 511 // Adds a outgoing video track with a given SSRC into the stats. | 518 // Adds a outgoing video track with a given SSRC into the stats. |
| 512 void AddOutgoingVideoTrackStats() { | 519 void AddOutgoingVideoTrackStats() { |
| 513 stream_ = webrtc::MediaStream::Create("streamlabel"); | 520 stream_ = webrtc::MediaStream::Create("streamlabel"); |
| 514 track_= webrtc::VideoTrack::Create(kLocalTrackId, NULL); | 521 track_= webrtc::VideoTrack::Create(kLocalTrackId, NULL); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 648 |
| 642 StatsReports reports; // returned values. | 649 StatsReports reports; // returned values. |
| 643 | 650 |
| 644 // Fake stats to process. | 651 // Fake stats to process. |
| 645 cricket::TransportChannelStats channel_stats; | 652 cricket::TransportChannelStats channel_stats; |
| 646 channel_stats.component = 1; | 653 channel_stats.component = 1; |
| 647 channel_stats.srtp_cipher = "the-srtp-cipher"; | 654 channel_stats.srtp_cipher = "the-srtp-cipher"; |
| 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.transport_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.transport_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_, |
| 680 .WillRepeatedly(Return(transport.get())); | 673 GetLocalCertificate(transport_stats.transport_name, _)) |
| 674 .WillOnce(DoAll(SetArgPointee<1>(local_certificate), Return(true))); |
| 675 EXPECT_CALL(session_, |
| 676 GetRemoteCertificate(transport_stats.transport_name, _)) |
| 677 .WillOnce( |
| 678 DoAll(SetArgPointee<1>(remote_cert.GetReference()), Return(true))); |
| 681 EXPECT_CALL(session_, GetTransportStats(_)) | 679 EXPECT_CALL(session_, GetTransportStats(_)) |
| 682 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 680 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
| 683 Return(true))); | 681 Return(true))); |
| 684 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 682 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 685 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 683 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 686 | 684 |
| 687 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 685 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 688 | 686 |
| 689 stats.GetStats(NULL, &reports); | 687 stats.GetStats(NULL, &reports); |
| 690 | 688 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 StatsReport::kStatsValueNameState)); | 782 StatsReport::kStatsValueNameState)); |
| 785 EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, | 783 EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, |
| 786 reports, | 784 reports, |
| 787 StatsReport::kStatsValueNameProtocol)); | 785 StatsReport::kStatsValueNameProtocol)); |
| 788 } | 786 } |
| 789 | 787 |
| 790 // This test verifies that 64-bit counters are passed successfully. | 788 // This test verifies that 64-bit counters are passed successfully. |
| 791 TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { | 789 TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { |
| 792 StatsCollectorForTest stats(&session_); | 790 StatsCollectorForTest stats(&session_); |
| 793 | 791 |
| 792 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 793 .WillRepeatedly(Return(false)); |
| 794 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 795 .WillRepeatedly(Return(false)); |
| 796 |
| 794 const char kVideoChannelName[] = "video"; | 797 const char kVideoChannelName[] = "video"; |
| 795 | 798 |
| 796 InitSessionStats(kVideoChannelName); | 799 InitSessionStats(kVideoChannelName); |
| 797 EXPECT_CALL(session_, GetTransportStats(_)) | 800 EXPECT_CALL(session_, GetTransportStats(_)) |
| 798 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 801 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 799 Return(true))); | 802 Return(true))); |
| 800 EXPECT_CALL(session_, GetTransport(_)) | |
| 801 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
| 802 | 803 |
| 803 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 804 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 804 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 805 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 805 media_channel, NULL, kVideoChannelName, false); | 806 media_channel, NULL, kVideoChannelName, false); |
| 806 StatsReports reports; // returned values. | 807 StatsReports reports; // returned values. |
| 807 cricket::VideoSenderInfo video_sender_info; | 808 cricket::VideoSenderInfo video_sender_info; |
| 808 cricket::VideoMediaInfo stats_read; | 809 cricket::VideoMediaInfo stats_read; |
| 809 // The number of bytes must be larger than 0xFFFFFFFF for this test. | 810 // The number of bytes must be larger than 0xFFFFFFFF for this test. |
| 810 const int64 kBytesSent = 12345678901234LL; | 811 const int64 kBytesSent = 12345678901234LL; |
| 811 const std::string kBytesSentString("12345678901234"); | 812 const std::string kBytesSentString("12345678901234"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 827 stats.GetStats(NULL, &reports); | 828 stats.GetStats(NULL, &reports); |
| 828 std::string result = ExtractSsrcStatsValue(reports, | 829 std::string result = ExtractSsrcStatsValue(reports, |
| 829 StatsReport::kStatsValueNameBytesSent); | 830 StatsReport::kStatsValueNameBytesSent); |
| 830 EXPECT_EQ(kBytesSentString, result); | 831 EXPECT_EQ(kBytesSentString, result); |
| 831 } | 832 } |
| 832 | 833 |
| 833 // Test that BWE information is reported via stats. | 834 // Test that BWE information is reported via stats. |
| 834 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { | 835 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { |
| 835 StatsCollectorForTest stats(&session_); | 836 StatsCollectorForTest stats(&session_); |
| 836 | 837 |
| 838 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 839 .WillRepeatedly(Return(false)); |
| 840 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 841 .WillRepeatedly(Return(false)); |
| 842 |
| 837 const char kVideoChannelName[] = "video"; | 843 const char kVideoChannelName[] = "video"; |
| 838 | 844 |
| 839 InitSessionStats(kVideoChannelName); | 845 InitSessionStats(kVideoChannelName); |
| 840 EXPECT_CALL(session_, GetTransportStats(_)) | 846 EXPECT_CALL(session_, GetTransportStats(_)) |
| 841 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 847 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 842 Return(true))); | 848 Return(true))); |
| 843 EXPECT_CALL(session_, GetTransport(_)) | |
| 844 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
| 845 | 849 |
| 846 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 850 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 847 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 851 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 848 media_channel, NULL, kVideoChannelName, false); | 852 media_channel, NULL, kVideoChannelName, false); |
| 849 | 853 |
| 850 StatsReports reports; // returned values. | 854 StatsReports reports; // returned values. |
| 851 cricket::VideoSenderInfo video_sender_info; | 855 cricket::VideoSenderInfo video_sender_info; |
| 852 cricket::VideoMediaInfo stats_read; | 856 cricket::VideoMediaInfo stats_read; |
| 853 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and | 857 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and |
| 854 // BWE. | 858 // BWE. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 reports, | 944 reports, |
| 941 StatsReport::kStatsValueNameTrackId); | 945 StatsReport::kStatsValueNameTrackId); |
| 942 EXPECT_EQ(kLocalTrackId, trackValue); | 946 EXPECT_EQ(kLocalTrackId, trackValue); |
| 943 } | 947 } |
| 944 | 948 |
| 945 // This test verifies that the empty track report exists in the returned stats | 949 // This test verifies that the empty track report exists in the returned stats |
| 946 // when StatsCollector::UpdateStats is called with ssrc stats. | 950 // when StatsCollector::UpdateStats is called with ssrc stats. |
| 947 TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { | 951 TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { |
| 948 StatsCollectorForTest stats(&session_); | 952 StatsCollectorForTest stats(&session_); |
| 949 | 953 |
| 954 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 955 .WillRepeatedly(Return(false)); |
| 956 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 957 .WillRepeatedly(Return(false)); |
| 958 |
| 950 const char kVideoChannelName[] = "video"; | 959 const char kVideoChannelName[] = "video"; |
| 951 InitSessionStats(kVideoChannelName); | 960 InitSessionStats(kVideoChannelName); |
| 952 EXPECT_CALL(session_, GetTransportStats(_)) | 961 EXPECT_CALL(session_, GetTransportStats(_)) |
| 953 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 962 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 954 Return(true))); | 963 Return(true))); |
| 955 EXPECT_CALL(session_, GetTransport(_)) | |
| 956 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
| 957 | 964 |
| 958 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 965 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 959 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 966 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 960 media_channel, NULL, kVideoChannelName, false); | 967 media_channel, NULL, kVideoChannelName, false); |
| 961 AddOutgoingVideoTrackStats(); | 968 AddOutgoingVideoTrackStats(); |
| 962 stats.AddStream(stream_); | 969 stats.AddStream(stream_); |
| 963 | 970 |
| 964 // Constructs an ssrc stats update. | 971 // Constructs an ssrc stats update. |
| 965 cricket::VideoSenderInfo video_sender_info; | 972 cricket::VideoSenderInfo video_sender_info; |
| 966 cricket::VideoMediaInfo stats_read; | 973 cricket::VideoMediaInfo stats_read; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 std::string track_id = ExtractSsrcStatsValue( | 1012 std::string track_id = ExtractSsrcStatsValue( |
| 1006 reports, StatsReport::kStatsValueNameTrackId); | 1013 reports, StatsReport::kStatsValueNameTrackId); |
| 1007 EXPECT_EQ(kLocalTrackId, track_id); | 1014 EXPECT_EQ(kLocalTrackId, track_id); |
| 1008 } | 1015 } |
| 1009 | 1016 |
| 1010 // This test verifies that an SSRC object has the identifier of a Transport | 1017 // 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. | 1018 // stats object, and that this transport stats object exists in stats. |
| 1012 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { | 1019 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { |
| 1013 StatsCollectorForTest stats(&session_); | 1020 StatsCollectorForTest stats(&session_); |
| 1014 | 1021 |
| 1015 // Ignore unused callback (logspam). | 1022 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1016 EXPECT_CALL(session_, GetTransport(_)) | 1023 .WillRepeatedly(Return(false)); |
| 1017 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1024 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1025 .WillRepeatedly(Return(false)); |
| 1026 |
| 1018 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1027 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1019 // The content_name known by the video channel. | 1028 // The transport_name known by the video channel. |
| 1020 const std::string kVcName("vcname"); | 1029 const std::string kVcName("vcname"); |
| 1021 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1030 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 1022 media_channel, NULL, kVcName, false); | 1031 media_channel, NULL, kVcName, false); |
| 1023 AddOutgoingVideoTrackStats(); | 1032 AddOutgoingVideoTrackStats(); |
| 1024 stats.AddStream(stream_); | 1033 stats.AddStream(stream_); |
| 1025 | 1034 |
| 1026 // Constructs an ssrc stats update. | 1035 // Constructs an ssrc stats update. |
| 1027 cricket::VideoSenderInfo video_sender_info; | 1036 cricket::VideoSenderInfo video_sender_info; |
| 1028 cricket::VideoMediaInfo stats_read; | 1037 cricket::VideoMediaInfo stats_read; |
| 1029 const int64 kBytesSent = 12345678901234LL; | 1038 const int64 kBytesSent = 12345678901234LL; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 const StatsReport* transport_report = FindReportById(reports, id); | 1076 const StatsReport* transport_report = FindReportById(reports, id); |
| 1068 ASSERT_FALSE(transport_report == NULL); | 1077 ASSERT_FALSE(transport_report == NULL); |
| 1069 } | 1078 } |
| 1070 | 1079 |
| 1071 // This test verifies that a remote stats object will not be created for | 1080 // This test verifies that a remote stats object will not be created for |
| 1072 // an outgoing SSRC where remote stats are not returned. | 1081 // an outgoing SSRC where remote stats are not returned. |
| 1073 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { | 1082 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { |
| 1074 StatsCollectorForTest stats(&session_); | 1083 StatsCollectorForTest stats(&session_); |
| 1075 | 1084 |
| 1076 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1085 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1077 // The content_name known by the video channel. | 1086 // The transport_name known by the video channel. |
| 1078 const std::string kVcName("vcname"); | 1087 const std::string kVcName("vcname"); |
| 1079 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1088 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 1080 media_channel, NULL, kVcName, false); | 1089 media_channel, NULL, kVcName, false); |
| 1081 AddOutgoingVideoTrackStats(); | 1090 AddOutgoingVideoTrackStats(); |
| 1082 stats.AddStream(stream_); | 1091 stats.AddStream(stream_); |
| 1083 | 1092 |
| 1084 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1093 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 1085 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1094 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 1086 | 1095 |
| 1087 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1096 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 1088 StatsReports reports; | 1097 StatsReports reports; |
| 1089 stats.GetStats(NULL, &reports); | 1098 stats.GetStats(NULL, &reports); |
| 1090 const StatsReport* remote_report = FindNthReportByType(reports, | 1099 const StatsReport* remote_report = FindNthReportByType(reports, |
| 1091 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1100 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
| 1092 EXPECT_TRUE(remote_report == NULL); | 1101 EXPECT_TRUE(remote_report == NULL); |
| 1093 } | 1102 } |
| 1094 | 1103 |
| 1095 // This test verifies that a remote stats object will be created for | 1104 // This test verifies that a remote stats object will be created for |
| 1096 // an outgoing SSRC where stats are returned. | 1105 // an outgoing SSRC where stats are returned. |
| 1097 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { | 1106 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
| 1098 StatsCollectorForTest stats(&session_); | 1107 StatsCollectorForTest stats(&session_); |
| 1099 | 1108 |
| 1100 // Ignore unused callback (logspam). | 1109 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1101 EXPECT_CALL(session_, GetTransport(_)) | 1110 .WillRepeatedly(Return(false)); |
| 1102 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1111 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1112 .WillRepeatedly(Return(false)); |
| 1113 |
| 1103 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1114 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1104 // The content_name known by the video channel. | 1115 // The transport_name known by the video channel. |
| 1105 const std::string kVcName("vcname"); | 1116 const std::string kVcName("vcname"); |
| 1106 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1117 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 1107 media_channel, NULL, kVcName, false); | 1118 media_channel, NULL, kVcName, false); |
| 1108 AddOutgoingVideoTrackStats(); | 1119 AddOutgoingVideoTrackStats(); |
| 1109 stats.AddStream(stream_); | 1120 stats.AddStream(stream_); |
| 1110 | 1121 |
| 1111 // Instruct the session to return stats containing the transport channel. | 1122 // Instruct the session to return stats containing the transport channel. |
| 1112 InitSessionStats(kVcName); | 1123 InitSessionStats(kVcName); |
| 1113 EXPECT_CALL(session_, GetTransportStats(_)) | 1124 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1114 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1125 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1139 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1150 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
| 1140 EXPECT_FALSE(remote_report == NULL); | 1151 EXPECT_FALSE(remote_report == NULL); |
| 1141 EXPECT_EQ(12345.678, remote_report->timestamp()); | 1152 EXPECT_EQ(12345.678, remote_report->timestamp()); |
| 1142 } | 1153 } |
| 1143 | 1154 |
| 1144 // This test verifies that the empty track report exists in the returned stats | 1155 // This test verifies that the empty track report exists in the returned stats |
| 1145 // when StatsCollector::UpdateStats is called with ssrc stats. | 1156 // when StatsCollector::UpdateStats is called with ssrc stats. |
| 1146 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { | 1157 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { |
| 1147 StatsCollectorForTest stats(&session_); | 1158 StatsCollectorForTest stats(&session_); |
| 1148 | 1159 |
| 1160 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1161 .WillRepeatedly(Return(false)); |
| 1162 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1163 .WillRepeatedly(Return(false)); |
| 1164 |
| 1149 const char kVideoChannelName[] = "video"; | 1165 const char kVideoChannelName[] = "video"; |
| 1150 InitSessionStats(kVideoChannelName); | 1166 InitSessionStats(kVideoChannelName); |
| 1151 EXPECT_CALL(session_, GetTransportStats(_)) | 1167 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1152 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1168 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 1153 Return(true))); | 1169 Return(true))); |
| 1154 EXPECT_CALL(session_, GetTransport(_)) | |
| 1155 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | |
| 1156 | 1170 |
| 1157 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1171 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1158 cricket::VideoChannel video_channel(rtc::Thread::Current(), | 1172 cricket::VideoChannel video_channel(rtc::Thread::Current(), |
| 1159 media_channel, NULL, kVideoChannelName, false); | 1173 media_channel, NULL, kVideoChannelName, false); |
| 1160 AddIncomingVideoTrackStats(); | 1174 AddIncomingVideoTrackStats(); |
| 1161 stats.AddStream(stream_); | 1175 stats.AddStream(stream_); |
| 1162 | 1176 |
| 1163 // Constructs an ssrc stats update. | 1177 // Constructs an ssrc stats update. |
| 1164 cricket::VideoReceiverInfo video_receiver_info; | 1178 cricket::VideoReceiverInfo video_receiver_info; |
| 1165 cricket::VideoMediaInfo stats_read; | 1179 cricket::VideoMediaInfo stats_read; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 | 1338 |
| 1325 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), | 1339 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), |
| 1326 remote_cert, std::vector<std::string>(1, remote_der)); | 1340 remote_cert, std::vector<std::string>(1, remote_der)); |
| 1327 } | 1341 } |
| 1328 | 1342 |
| 1329 // This test verifies that the stats are generated correctly when no | 1343 // This test verifies that the stats are generated correctly when no |
| 1330 // transport is present. | 1344 // transport is present. |
| 1331 TEST_F(StatsCollectorTest, NoTransport) { | 1345 TEST_F(StatsCollectorTest, NoTransport) { |
| 1332 StatsCollectorForTest stats(&session_); | 1346 StatsCollectorForTest stats(&session_); |
| 1333 | 1347 |
| 1348 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1349 .WillRepeatedly(Return(false)); |
| 1350 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1351 .WillRepeatedly(Return(false)); |
| 1352 |
| 1334 StatsReports reports; // returned values. | 1353 StatsReports reports; // returned values. |
| 1335 | 1354 |
| 1336 // Fake stats to process. | 1355 // Fake stats to process. |
| 1337 cricket::TransportChannelStats channel_stats; | 1356 cricket::TransportChannelStats channel_stats; |
| 1338 channel_stats.component = 1; | 1357 channel_stats.component = 1; |
| 1339 | 1358 |
| 1340 cricket::TransportStats transport_stats; | 1359 cricket::TransportStats transport_stats; |
| 1341 transport_stats.content_name = "audio"; | 1360 transport_stats.transport_name = "audio"; |
| 1342 transport_stats.channel_stats.push_back(channel_stats); | 1361 transport_stats.channel_stats.push_back(channel_stats); |
| 1343 | 1362 |
| 1344 cricket::SessionStats session_stats; | 1363 cricket::SessionStats session_stats; |
| 1345 session_stats.transport_stats[transport_stats.content_name] = | 1364 session_stats.transport_stats[transport_stats.transport_name] = |
| 1346 transport_stats; | 1365 transport_stats; |
| 1347 | 1366 |
| 1348 // Configure MockWebRtcSession | 1367 // Configure MockWebRtcSession |
| 1349 EXPECT_CALL(session_, GetTransport(transport_stats.content_name)) | |
| 1350 .WillRepeatedly(ReturnNull()); | |
| 1351 EXPECT_CALL(session_, GetTransportStats(_)) | 1368 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1352 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 1369 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
| 1353 Return(true))); | 1370 Return(true))); |
| 1354 | 1371 |
| 1355 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1372 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 1356 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1373 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 1357 | 1374 |
| 1358 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1375 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 1359 stats.GetStats(NULL, &reports); | 1376 stats.GetStats(NULL, &reports); |
| 1360 | 1377 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1383 reports, | 1400 reports, |
| 1384 StatsReport::kStatsValueNameSrtpCipher); | 1401 StatsReport::kStatsValueNameSrtpCipher); |
| 1385 ASSERT_EQ(kNotFound, srtp_cipher); | 1402 ASSERT_EQ(kNotFound, srtp_cipher); |
| 1386 } | 1403 } |
| 1387 | 1404 |
| 1388 // This test verifies that the stats are generated correctly when the transport | 1405 // This test verifies that the stats are generated correctly when the transport |
| 1389 // does not have any certificates. | 1406 // does not have any certificates. |
| 1390 TEST_F(StatsCollectorTest, NoCertificates) { | 1407 TEST_F(StatsCollectorTest, NoCertificates) { |
| 1391 StatsCollectorForTest stats(&session_); | 1408 StatsCollectorForTest stats(&session_); |
| 1392 | 1409 |
| 1410 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1411 .WillRepeatedly(Return(false)); |
| 1412 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1413 .WillRepeatedly(Return(false)); |
| 1414 |
| 1393 StatsReports reports; // returned values. | 1415 StatsReports reports; // returned values. |
| 1394 | 1416 |
| 1395 // Fake stats to process. | 1417 // Fake stats to process. |
| 1396 cricket::TransportChannelStats channel_stats; | 1418 cricket::TransportChannelStats channel_stats; |
| 1397 channel_stats.component = 1; | 1419 channel_stats.component = 1; |
| 1398 | 1420 |
| 1399 cricket::TransportStats transport_stats; | 1421 cricket::TransportStats transport_stats; |
| 1400 transport_stats.content_name = "audio"; | 1422 transport_stats.transport_name = "audio"; |
| 1401 transport_stats.channel_stats.push_back(channel_stats); | 1423 transport_stats.channel_stats.push_back(channel_stats); |
| 1402 | 1424 |
| 1403 cricket::SessionStats session_stats; | 1425 cricket::SessionStats session_stats; |
| 1404 session_stats.transport_stats[transport_stats.content_name] = | 1426 session_stats.transport_stats[transport_stats.transport_name] = |
| 1405 transport_stats; | 1427 transport_stats; |
| 1406 | 1428 |
| 1407 // Fake transport object. | 1429 // Fake transport object. |
| 1408 rtc::scoped_ptr<cricket::FakeTransport> transport( | 1430 rtc::scoped_ptr<cricket::FakeTransport> transport( |
| 1409 new cricket::FakeTransport( | 1431 new cricket::FakeTransport(transport_stats.transport_name)); |
| 1410 session_.signaling_thread(), | |
| 1411 session_.worker_thread(), | |
| 1412 transport_stats.content_name)); | |
| 1413 | 1432 |
| 1414 // Configure MockWebRtcSession | 1433 // Configure MockWebRtcSession |
| 1415 EXPECT_CALL(session_, GetTransport(transport_stats.content_name)) | |
| 1416 .WillRepeatedly(Return(transport.get())); | |
| 1417 EXPECT_CALL(session_, GetTransportStats(_)) | 1434 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1418 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 1435 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
| 1419 Return(true))); | 1436 Return(true))); |
| 1420 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 1437 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 1421 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 1438 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 1422 | 1439 |
| 1423 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 1440 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 1424 stats.GetStats(NULL, &reports); | 1441 stats.GetStats(NULL, &reports); |
| 1425 | 1442 |
| 1426 // Check that the local certificate is absent. | 1443 // Check that the local certificate is absent. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1452 | 1469 |
| 1453 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), | 1470 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), |
| 1454 remote_cert, std::vector<std::string>()); | 1471 remote_cert, std::vector<std::string>()); |
| 1455 } | 1472 } |
| 1456 | 1473 |
| 1457 // This test verifies that a local stats object can get statistics via | 1474 // This test verifies that a local stats object can get statistics via |
| 1458 // AudioTrackInterface::GetStats() method. | 1475 // AudioTrackInterface::GetStats() method. |
| 1459 TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { | 1476 TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { |
| 1460 StatsCollectorForTest stats(&session_); | 1477 StatsCollectorForTest stats(&session_); |
| 1461 | 1478 |
| 1462 // Ignore unused callback (logspam). | 1479 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1463 EXPECT_CALL(session_, GetTransport(_)) | 1480 .WillRepeatedly(Return(false)); |
| 1464 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1481 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1482 .WillRepeatedly(Return(false)); |
| 1465 | 1483 |
| 1466 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1484 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1467 // The content_name known by the voice channel. | 1485 // The transport_name known by the voice channel. |
| 1468 const std::string kVcName("vcname"); | 1486 const std::string kVcName("vcname"); |
| 1469 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1487 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1470 media_engine_, media_channel, NULL, kVcName, false); | 1488 media_engine_, media_channel, NULL, kVcName, false); |
| 1471 AddOutgoingAudioTrackStats(); | 1489 AddOutgoingAudioTrackStats(); |
| 1472 stats.AddStream(stream_); | 1490 stats.AddStream(stream_); |
| 1473 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1491 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
| 1474 | 1492 |
| 1475 cricket::VoiceSenderInfo voice_sender_info; | 1493 cricket::VoiceSenderInfo voice_sender_info; |
| 1476 InitVoiceSenderInfo(&voice_sender_info); | 1494 InitVoiceSenderInfo(&voice_sender_info); |
| 1477 | 1495 |
| 1478 cricket::VoiceMediaInfo stats_read; | 1496 cricket::VoiceMediaInfo stats_read; |
| 1479 StatsReports reports; // returned values. | 1497 StatsReports reports; // returned values. |
| 1480 SetupAndVerifyAudioTrackStats( | 1498 SetupAndVerifyAudioTrackStats( |
| 1481 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1499 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1482 media_channel, &voice_sender_info, NULL, &stats_read, &reports); | 1500 media_channel, &voice_sender_info, NULL, &stats_read, &reports); |
| 1483 | 1501 |
| 1484 // Verify that there is no remote report for the local audio track because | 1502 // Verify that there is no remote report for the local audio track because |
| 1485 // we did not set it up. | 1503 // we did not set it up. |
| 1486 const StatsReport* remote_report = FindNthReportByType(reports, | 1504 const StatsReport* remote_report = FindNthReportByType(reports, |
| 1487 StatsReport::kStatsReportTypeRemoteSsrc, 1); | 1505 StatsReport::kStatsReportTypeRemoteSsrc, 1); |
| 1488 EXPECT_TRUE(remote_report == NULL); | 1506 EXPECT_TRUE(remote_report == NULL); |
| 1489 } | 1507 } |
| 1490 | 1508 |
| 1491 // This test verifies that audio receive streams populate stats reports | 1509 // This test verifies that audio receive streams populate stats reports |
| 1492 // correctly. | 1510 // correctly. |
| 1493 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { | 1511 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { |
| 1494 StatsCollectorForTest stats(&session_); | 1512 StatsCollectorForTest stats(&session_); |
| 1495 | 1513 |
| 1496 // Ignore unused callback (logspam). | 1514 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1497 EXPECT_CALL(session_, GetTransport(_)) | 1515 .WillRepeatedly(Return(false)); |
| 1498 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1516 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1517 .WillRepeatedly(Return(false)); |
| 1518 |
| 1499 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1519 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1500 // The content_name known by the voice channel. | 1520 // The transport_name known by the voice channel. |
| 1501 const std::string kVcName("vcname"); | 1521 const std::string kVcName("vcname"); |
| 1502 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1522 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1503 media_engine_, media_channel, NULL, kVcName, false); | 1523 media_engine_, media_channel, NULL, kVcName, false); |
| 1504 AddIncomingAudioTrackStats(); | 1524 AddIncomingAudioTrackStats(); |
| 1505 stats.AddStream(stream_); | 1525 stats.AddStream(stream_); |
| 1506 | 1526 |
| 1507 cricket::VoiceReceiverInfo voice_receiver_info; | 1527 cricket::VoiceReceiverInfo voice_receiver_info; |
| 1508 InitVoiceReceiverInfo(&voice_receiver_info); | 1528 InitVoiceReceiverInfo(&voice_receiver_info); |
| 1509 voice_receiver_info.codec_name = "fake_codec"; | 1529 voice_receiver_info.codec_name = "fake_codec"; |
| 1510 | 1530 |
| 1511 cricket::VoiceMediaInfo stats_read; | 1531 cricket::VoiceMediaInfo stats_read; |
| 1512 StatsReports reports; // returned values. | 1532 StatsReports reports; // returned values. |
| 1513 SetupAndVerifyAudioTrackStats( | 1533 SetupAndVerifyAudioTrackStats( |
| 1514 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1534 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1515 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); | 1535 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); |
| 1516 } | 1536 } |
| 1517 | 1537 |
| 1518 // This test verifies that a local stats object won't update its statistics | 1538 // This test verifies that a local stats object won't update its statistics |
| 1519 // after a RemoveLocalAudioTrack() call. | 1539 // after a RemoveLocalAudioTrack() call. |
| 1520 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { | 1540 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { |
| 1521 StatsCollectorForTest stats(&session_); | 1541 StatsCollectorForTest stats(&session_); |
| 1522 | 1542 |
| 1523 // Ignore unused callback (logspam). | 1543 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1524 EXPECT_CALL(session_, GetTransport(_)) | 1544 .WillRepeatedly(Return(false)); |
| 1525 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1545 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1546 .WillRepeatedly(Return(false)); |
| 1547 |
| 1526 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1548 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1527 // The content_name known by the voice channel. | 1549 // The transport_name known by the voice channel. |
| 1528 const std::string kVcName("vcname"); | 1550 const std::string kVcName("vcname"); |
| 1529 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1551 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1530 media_engine_, media_channel, NULL, kVcName, false); | 1552 media_engine_, media_channel, NULL, kVcName, false); |
| 1531 AddOutgoingAudioTrackStats(); | 1553 AddOutgoingAudioTrackStats(); |
| 1532 stats.AddStream(stream_); | 1554 stats.AddStream(stream_); |
| 1533 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1555 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
| 1534 | 1556 |
| 1535 // Instruct the session to return stats containing the transport channel. | 1557 // Instruct the session to return stats containing the transport channel. |
| 1536 InitSessionStats(kVcName); | 1558 InitSessionStats(kVcName); |
| 1537 EXPECT_CALL(session_, GetTransportStats(_)) | 1559 EXPECT_CALL(session_, GetTransportStats(_)) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 // AudioTrackInterface::GetSignalValue() and | 1594 // AudioTrackInterface::GetSignalValue() and |
| 1573 // AudioProcessorInterface::AudioProcessorStats::GetStats(); | 1595 // AudioProcessorInterface::AudioProcessorStats::GetStats(); |
| 1574 VerifyVoiceSenderInfoReport(report, voice_sender_info); | 1596 VerifyVoiceSenderInfoReport(report, voice_sender_info); |
| 1575 } | 1597 } |
| 1576 | 1598 |
| 1577 // This test verifies that when ongoing and incoming audio tracks are using | 1599 // This test verifies that when ongoing and incoming audio tracks are using |
| 1578 // the same ssrc, they populate stats reports correctly. | 1600 // the same ssrc, they populate stats reports correctly. |
| 1579 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { | 1601 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { |
| 1580 StatsCollectorForTest stats(&session_); | 1602 StatsCollectorForTest stats(&session_); |
| 1581 | 1603 |
| 1582 // Ignore unused callback (logspam). | 1604 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1583 EXPECT_CALL(session_, GetTransport(_)) | 1605 .WillRepeatedly(Return(false)); |
| 1584 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1606 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1607 .WillRepeatedly(Return(false)); |
| 1608 |
| 1585 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1609 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1586 // The content_name known by the voice channel. | 1610 // The transport_name known by the voice channel. |
| 1587 const std::string kVcName("vcname"); | 1611 const std::string kVcName("vcname"); |
| 1588 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1612 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1589 media_engine_, media_channel, NULL, kVcName, false); | 1613 media_engine_, media_channel, NULL, kVcName, false); |
| 1590 | 1614 |
| 1591 // Create a local stream with a local audio track and adds it to the stats. | 1615 // Create a local stream with a local audio track and adds it to the stats. |
| 1592 AddOutgoingAudioTrackStats(); | 1616 AddOutgoingAudioTrackStats(); |
| 1593 stats.AddStream(stream_); | 1617 stats.AddStream(stream_); |
| 1594 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1618 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
| 1595 | 1619 |
| 1596 // Create a remote stream with a remote audio track and adds it to the stats. | 1620 // Create a remote stream with a remote audio track and adds it to the stats. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info); | 1681 VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info); |
| 1658 } | 1682 } |
| 1659 | 1683 |
| 1660 // This test verifies that when two outgoing audio tracks are using the same | 1684 // This test verifies that when two outgoing audio tracks are using the same |
| 1661 // ssrc at different times, they populate stats reports correctly. | 1685 // ssrc at different times, they populate stats reports correctly. |
| 1662 // TODO(xians): Figure out if it is possible to encapsulate the setup and | 1686 // TODO(xians): Figure out if it is possible to encapsulate the setup and |
| 1663 // avoid duplication of code in test cases. | 1687 // avoid duplication of code in test cases. |
| 1664 TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { | 1688 TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { |
| 1665 StatsCollectorForTest stats(&session_); | 1689 StatsCollectorForTest stats(&session_); |
| 1666 | 1690 |
| 1667 // Ignore unused callback (logspam). | 1691 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1668 EXPECT_CALL(session_, GetTransport(_)) | 1692 .WillRepeatedly(Return(false)); |
| 1669 .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL))); | 1693 EXPECT_CALL(session_, GetRemoteCertificate(_, _)) |
| 1694 .WillRepeatedly(Return(false)); |
| 1695 |
| 1670 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1696 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1671 // The content_name known by the voice channel. | 1697 // The transport_name known by the voice channel. |
| 1672 const std::string kVcName("vcname"); | 1698 const std::string kVcName("vcname"); |
| 1673 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), | 1699 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), |
| 1674 media_engine_, media_channel, NULL, kVcName, false); | 1700 media_engine_, media_channel, NULL, kVcName, false); |
| 1675 | 1701 |
| 1676 // Create a local stream with a local audio track and adds it to the stats. | 1702 // Create a local stream with a local audio track and adds it to the stats. |
| 1677 AddOutgoingAudioTrackStats(); | 1703 AddOutgoingAudioTrackStats(); |
| 1678 stats.AddStream(stream_); | 1704 stats.AddStream(stream_); |
| 1679 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1705 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
| 1680 | 1706 |
| 1681 cricket::VoiceSenderInfo voice_sender_info; | 1707 cricket::VoiceSenderInfo voice_sender_info; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1704 cricket::VoiceSenderInfo new_voice_sender_info; | 1730 cricket::VoiceSenderInfo new_voice_sender_info; |
| 1705 InitVoiceSenderInfo(&new_voice_sender_info); | 1731 InitVoiceSenderInfo(&new_voice_sender_info); |
| 1706 cricket::VoiceMediaInfo new_stats_read; | 1732 cricket::VoiceMediaInfo new_stats_read; |
| 1707 reports.clear(); | 1733 reports.clear(); |
| 1708 SetupAndVerifyAudioTrackStats( | 1734 SetupAndVerifyAudioTrackStats( |
| 1709 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1735 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1710 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1736 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); |
| 1711 } | 1737 } |
| 1712 | 1738 |
| 1713 } // namespace webrtc | 1739 } // namespace webrtc |
| OLD | NEW |