OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/api/statscollector.h" | 16 #include "webrtc/api/statscollector.h" |
17 | 17 |
18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "webrtc/api/mediastream.h" | 20 #include "webrtc/api/mediastream.h" |
21 #include "webrtc/api/mediastreaminterface.h" | 21 #include "webrtc/api/mediastreaminterface.h" |
22 #include "webrtc/api/mediastreamtrack.h" | 22 #include "webrtc/api/mediastreamtrack.h" |
23 #include "webrtc/api/peerconnection.h" | 23 #include "webrtc/api/peerconnection.h" |
24 #include "webrtc/api/peerconnectionfactory.h" | 24 #include "webrtc/api/peerconnectionfactory.h" |
25 #include "webrtc/api/test/fakedatachannelprovider.h" | 25 #include "webrtc/api/test/fakedatachannelprovider.h" |
26 #include "webrtc/api/test/fakevideotracksource.h" | 26 #include "webrtc/api/test/fakevideotracksource.h" |
| 27 #include "webrtc/api/test/mock_peerconnection.h" |
| 28 #include "webrtc/api/test/mock_webrtcsession.h" |
27 #include "webrtc/api/videotrack.h" | 29 #include "webrtc/api/videotrack.h" |
28 #include "webrtc/base/base64.h" | 30 #include "webrtc/base/base64.h" |
29 #include "webrtc/base/fakesslidentity.h" | 31 #include "webrtc/base/fakesslidentity.h" |
30 #include "webrtc/base/gunit.h" | 32 #include "webrtc/base/gunit.h" |
31 #include "webrtc/base/network.h" | 33 #include "webrtc/base/network.h" |
32 #include "webrtc/media/base/fakemediaengine.h" | 34 #include "webrtc/media/base/fakemediaengine.h" |
| 35 #include "webrtc/media/base/test/mock_mediachannel.h" |
33 #include "webrtc/p2p/base/faketransportcontroller.h" | 36 #include "webrtc/p2p/base/faketransportcontroller.h" |
34 #include "webrtc/pc/channelmanager.h" | 37 #include "webrtc/pc/channelmanager.h" |
35 | 38 |
36 using testing::_; | 39 using testing::_; |
37 using testing::DoAll; | 40 using testing::DoAll; |
38 using testing::Field; | 41 using testing::Field; |
39 using testing::Return; | 42 using testing::Return; |
40 using testing::ReturnNull; | 43 using testing::ReturnNull; |
41 using testing::ReturnRef; | 44 using testing::ReturnRef; |
42 using testing::SetArgPointee; | 45 using testing::SetArgPointee; |
(...skipping 15 matching lines...) Expand all Loading... |
58 } // namespace internal | 61 } // namespace internal |
59 | 62 |
60 // Error return values | 63 // Error return values |
61 const char kNotFound[] = "NOT FOUND"; | 64 const char kNotFound[] = "NOT FOUND"; |
62 | 65 |
63 // Constant names for track identification. | 66 // Constant names for track identification. |
64 const char kLocalTrackId[] = "local_track_id"; | 67 const char kLocalTrackId[] = "local_track_id"; |
65 const char kRemoteTrackId[] = "remote_track_id"; | 68 const char kRemoteTrackId[] = "remote_track_id"; |
66 const uint32_t kSsrcOfTrack = 1234; | 69 const uint32_t kSsrcOfTrack = 1234; |
67 | 70 |
68 class MockWebRtcSession : public webrtc::WebRtcSession { | |
69 public: | |
70 // TODO(nisse): Valid overrides commented out, because the gmock | |
71 // methods don't use any override declarations, and we want to avoid | |
72 // warnings from -Winconsistent-missing-override. See | |
73 // http://crbug.com/428099. | |
74 explicit MockWebRtcSession(webrtc::MediaControllerInterface* media_controller) | |
75 : WebRtcSession( | |
76 media_controller, | |
77 rtc::Thread::Current(), | |
78 rtc::Thread::Current(), | |
79 rtc::Thread::Current(), | |
80 nullptr, | |
81 std::unique_ptr<cricket::TransportController>( | |
82 new cricket::TransportController(rtc::Thread::Current(), | |
83 rtc::Thread::Current(), | |
84 nullptr))) {} | |
85 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); | |
86 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); | |
87 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming | |
88 // track. | |
89 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*)); | |
90 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*)); | |
91 MOCK_METHOD1(GetTransportStats, bool(SessionStats*)); | |
92 MOCK_METHOD2(GetLocalCertificate, | |
93 bool(const std::string& transport_name, | |
94 rtc::scoped_refptr<rtc::RTCCertificate>* certificate)); | |
95 | |
96 // Workaround for gmock's inability to cope with move-only return values. | |
97 std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate( | |
98 const std::string& transport_name) /* override */ { | |
99 return std::unique_ptr<rtc::SSLCertificate>( | |
100 GetRemoteSSLCertificate_ReturnsRawPointer(transport_name)); | |
101 } | |
102 MOCK_METHOD1(GetRemoteSSLCertificate_ReturnsRawPointer, | |
103 rtc::SSLCertificate*(const std::string& transport_name)); | |
104 }; | |
105 | |
106 // The factory isn't really used; it just satisfies the base PeerConnection. | |
107 class FakePeerConnectionFactory | |
108 : public rtc::RefCountedObject<PeerConnectionFactory> {}; | |
109 | |
110 class MockPeerConnection | |
111 : public rtc::RefCountedObject<webrtc::PeerConnection> { | |
112 public: | |
113 MockPeerConnection() | |
114 : rtc::RefCountedObject<webrtc::PeerConnection>( | |
115 new FakePeerConnectionFactory()) {} | |
116 MOCK_METHOD0(session, WebRtcSession*()); | |
117 MOCK_CONST_METHOD0(sctp_data_channels, | |
118 const std::vector<rtc::scoped_refptr<DataChannel>>&()); | |
119 }; | |
120 | |
121 class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel { | |
122 public: | |
123 MockVideoMediaChannel() : | |
124 cricket::FakeVideoMediaChannel(NULL, cricket::VideoOptions()) {} | |
125 MOCK_METHOD1(GetStats, bool(cricket::VideoMediaInfo*)); | |
126 }; | |
127 | |
128 class MockVoiceMediaChannel : public cricket::FakeVoiceMediaChannel { | |
129 public: | |
130 MockVoiceMediaChannel() : | |
131 cricket::FakeVoiceMediaChannel(NULL, cricket::AudioOptions()) {} | |
132 MOCK_METHOD1(GetStats, bool(cricket::VoiceMediaInfo*)); | |
133 }; | |
134 | |
135 class FakeAudioProcessor : public webrtc::AudioProcessorInterface { | 71 class FakeAudioProcessor : public webrtc::AudioProcessorInterface { |
136 public: | 72 public: |
137 FakeAudioProcessor() {} | 73 FakeAudioProcessor() {} |
138 ~FakeAudioProcessor() {} | 74 ~FakeAudioProcessor() {} |
139 | 75 |
140 private: | 76 private: |
141 void GetStats(AudioProcessorInterface::AudioProcessorStats* stats) override { | 77 void GetStats(AudioProcessorInterface::AudioProcessorStats* stats) override { |
142 stats->typing_noise_detected = true; | 78 stats->typing_noise_detected = true; |
143 stats->echo_return_loss = 2; | 79 stats->echo_return_loss = 2; |
144 stats->echo_return_loss_enhancement = 3; | 80 stats->echo_return_loss_enhancement = 3; |
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 cricket::VoiceSenderInfo new_voice_sender_info; | 1879 cricket::VoiceSenderInfo new_voice_sender_info; |
1944 InitVoiceSenderInfo(&new_voice_sender_info); | 1880 InitVoiceSenderInfo(&new_voice_sender_info); |
1945 cricket::VoiceMediaInfo new_stats_read; | 1881 cricket::VoiceMediaInfo new_stats_read; |
1946 reports.clear(); | 1882 reports.clear(); |
1947 SetupAndVerifyAudioTrackStats( | 1883 SetupAndVerifyAudioTrackStats( |
1948 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1884 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, |
1949 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1885 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); |
1950 } | 1886 } |
1951 | 1887 |
1952 } // namespace webrtc | 1888 } // namespace webrtc |
OLD | NEW |