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