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