henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2012, Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 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 |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 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 |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 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, |
| 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 |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include <string> |
| 29 | |
| 30 | #include "talk/app/webrtc/fakeportallocatorfactory.h" |
| 31 | #include "talk/app/webrtc/jsepsessiondescription.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | #include "talk/app/webrtc/mediastreaminterface.h" |
| 33 | #include "talk/app/webrtc/peerconnectioninterface.h" |
| 34 | #include "talk/app/webrtc/test/fakeconstraints.h" |
jiayl@webrtc.org | a576faf | 2014-01-29 17:45:53 +0000 | [diff] [blame^] | 35 | #include "talk/app/webrtc/test/fakedtlsidentityservice.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 36 | #include "talk/app/webrtc/test/mockpeerconnectionobservers.h" |
| 37 | #include "talk/app/webrtc/test/testsdpstrings.h" |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 38 | #include "talk/app/webrtc/videosource.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 39 | #include "talk/base/gunit.h" |
| 40 | #include "talk/base/scoped_ptr.h" |
sergeyu@chromium.org | a23f0ca | 2013-11-13 22:48:52 +0000 | [diff] [blame] | 41 | #include "talk/base/ssladapter.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 42 | #include "talk/base/sslstreamadapter.h" |
| 43 | #include "talk/base/stringutils.h" |
| 44 | #include "talk/base/thread.h" |
| 45 | #include "talk/media/base/fakevideocapturer.h" |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 46 | #include "talk/media/sctp/sctpdataengine.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 47 | #include "talk/session/media/mediasession.h" |
| 48 | |
| 49 | static const char kStreamLabel1[] = "local_stream_1"; |
| 50 | static const char kStreamLabel2[] = "local_stream_2"; |
| 51 | static const char kStreamLabel3[] = "local_stream_3"; |
| 52 | static const int kDefaultStunPort = 3478; |
| 53 | static const char kStunAddressOnly[] = "stun:address"; |
| 54 | static const char kStunInvalidPort[] = "stun:address:-1"; |
| 55 | static const char kStunAddressPortAndMore1[] = "stun:address:port:more"; |
| 56 | static const char kStunAddressPortAndMore2[] = "stun:address:port more"; |
| 57 | static const char kTurnIceServerUri[] = "turn:user@turn.example.org"; |
| 58 | static const char kTurnUsername[] = "user"; |
| 59 | static const char kTurnPassword[] = "password"; |
| 60 | static const char kTurnHostname[] = "turn.example.org"; |
| 61 | static const uint32 kTimeout = 5000U; |
| 62 | |
| 63 | #define MAYBE_SKIP_TEST(feature) \ |
| 64 | if (!(feature())) { \ |
| 65 | LOG(LS_INFO) << "Feature disabled... skipping"; \ |
| 66 | return; \ |
| 67 | } |
| 68 | |
| 69 | using talk_base::scoped_ptr; |
| 70 | using talk_base::scoped_refptr; |
| 71 | using webrtc::AudioSourceInterface; |
| 72 | using webrtc::AudioTrackInterface; |
| 73 | using webrtc::DataBuffer; |
| 74 | using webrtc::DataChannelInterface; |
| 75 | using webrtc::FakeConstraints; |
| 76 | using webrtc::FakePortAllocatorFactory; |
| 77 | using webrtc::IceCandidateInterface; |
| 78 | using webrtc::MediaStreamInterface; |
| 79 | using webrtc::MediaStreamTrackInterface; |
| 80 | using webrtc::MockCreateSessionDescriptionObserver; |
| 81 | using webrtc::MockDataChannelObserver; |
| 82 | using webrtc::MockSetSessionDescriptionObserver; |
| 83 | using webrtc::MockStatsObserver; |
| 84 | using webrtc::PeerConnectionInterface; |
| 85 | using webrtc::PeerConnectionObserver; |
| 86 | using webrtc::PortAllocatorFactoryInterface; |
| 87 | using webrtc::SdpParseError; |
| 88 | using webrtc::SessionDescriptionInterface; |
| 89 | using webrtc::VideoSourceInterface; |
| 90 | using webrtc::VideoTrackInterface; |
| 91 | |
| 92 | namespace { |
| 93 | |
| 94 | // Gets the first ssrc of given content type from the ContentInfo. |
| 95 | bool GetFirstSsrc(const cricket::ContentInfo* content_info, int* ssrc) { |
| 96 | if (!content_info || !ssrc) { |
| 97 | return false; |
| 98 | } |
| 99 | const cricket::MediaContentDescription* media_desc = |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 100 | static_cast<const cricket::MediaContentDescription*>( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 101 | content_info->description); |
| 102 | if (!media_desc || media_desc->streams().empty()) { |
| 103 | return false; |
| 104 | } |
| 105 | *ssrc = media_desc->streams().begin()->first_ssrc(); |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | void SetSsrcToZero(std::string* sdp) { |
| 110 | const char kSdpSsrcAtribute[] = "a=ssrc:"; |
| 111 | const char kSdpSsrcAtributeZero[] = "a=ssrc:0"; |
| 112 | size_t ssrc_pos = 0; |
| 113 | while ((ssrc_pos = sdp->find(kSdpSsrcAtribute, ssrc_pos)) != |
| 114 | std::string::npos) { |
| 115 | size_t end_ssrc = sdp->find(" ", ssrc_pos); |
| 116 | sdp->replace(ssrc_pos, end_ssrc - ssrc_pos, kSdpSsrcAtributeZero); |
| 117 | ssrc_pos = end_ssrc; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | class MockPeerConnectionObserver : public PeerConnectionObserver { |
| 122 | public: |
| 123 | MockPeerConnectionObserver() |
| 124 | : renegotiation_needed_(false), |
| 125 | ice_complete_(false) { |
| 126 | } |
| 127 | ~MockPeerConnectionObserver() { |
| 128 | } |
| 129 | void SetPeerConnectionInterface(PeerConnectionInterface* pc) { |
| 130 | pc_ = pc; |
| 131 | if (pc) { |
| 132 | state_ = pc_->signaling_state(); |
| 133 | } |
| 134 | } |
| 135 | virtual void OnError() {} |
| 136 | virtual void OnSignalingChange( |
| 137 | PeerConnectionInterface::SignalingState new_state) { |
| 138 | EXPECT_EQ(pc_->signaling_state(), new_state); |
| 139 | state_ = new_state; |
| 140 | } |
| 141 | // TODO(bemasc): Remove this once callers transition to OnIceGatheringChange. |
| 142 | virtual void OnStateChange(StateType state_changed) { |
| 143 | if (pc_.get() == NULL) |
| 144 | return; |
| 145 | switch (state_changed) { |
| 146 | case kSignalingState: |
| 147 | // OnSignalingChange and OnStateChange(kSignalingState) should always |
| 148 | // be called approximately simultaneously. To ease testing, we require |
| 149 | // that they always be called in that order. This check verifies |
| 150 | // that OnSignalingChange has just been called. |
| 151 | EXPECT_EQ(pc_->signaling_state(), state_); |
| 152 | break; |
| 153 | case kIceState: |
| 154 | ADD_FAILURE(); |
| 155 | break; |
| 156 | default: |
| 157 | ADD_FAILURE(); |
| 158 | break; |
| 159 | } |
| 160 | } |
| 161 | virtual void OnAddStream(MediaStreamInterface* stream) { |
| 162 | last_added_stream_ = stream; |
| 163 | } |
| 164 | virtual void OnRemoveStream(MediaStreamInterface* stream) { |
| 165 | last_removed_stream_ = stream; |
| 166 | } |
| 167 | virtual void OnRenegotiationNeeded() { |
| 168 | renegotiation_needed_ = true; |
| 169 | } |
| 170 | virtual void OnDataChannel(DataChannelInterface* data_channel) { |
| 171 | last_datachannel_ = data_channel; |
| 172 | } |
| 173 | |
| 174 | virtual void OnIceConnectionChange( |
| 175 | PeerConnectionInterface::IceConnectionState new_state) { |
| 176 | EXPECT_EQ(pc_->ice_connection_state(), new_state); |
| 177 | } |
| 178 | virtual void OnIceGatheringChange( |
| 179 | PeerConnectionInterface::IceGatheringState new_state) { |
| 180 | EXPECT_EQ(pc_->ice_gathering_state(), new_state); |
| 181 | } |
| 182 | virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) { |
mallinath@webrtc.org | 0dac537 | 2014-01-28 06:58:42 +0000 | [diff] [blame] | 183 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 184 | EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, |
| 185 | pc_->ice_gathering_state()); |
| 186 | |
| 187 | std::string sdp; |
| 188 | EXPECT_TRUE(candidate->ToString(&sdp)); |
| 189 | EXPECT_LT(0u, sdp.size()); |
| 190 | last_candidate_.reset(webrtc::CreateIceCandidate(candidate->sdp_mid(), |
| 191 | candidate->sdp_mline_index(), sdp, NULL)); |
| 192 | EXPECT_TRUE(last_candidate_.get() != NULL); |
| 193 | } |
| 194 | // TODO(bemasc): Remove this once callers transition to OnSignalingChange. |
| 195 | virtual void OnIceComplete() { |
| 196 | ice_complete_ = true; |
| 197 | // OnIceGatheringChange(IceGatheringCompleted) and OnIceComplete() should |
| 198 | // be called approximately simultaneously. For ease of testing, this |
| 199 | // check additionally requires that they be called in the above order. |
| 200 | EXPECT_EQ(PeerConnectionInterface::kIceGatheringComplete, |
| 201 | pc_->ice_gathering_state()); |
| 202 | } |
| 203 | |
| 204 | // Returns the label of the last added stream. |
| 205 | // Empty string if no stream have been added. |
| 206 | std::string GetLastAddedStreamLabel() { |
| 207 | if (last_added_stream_.get()) |
| 208 | return last_added_stream_->label(); |
| 209 | return ""; |
| 210 | } |
| 211 | std::string GetLastRemovedStreamLabel() { |
| 212 | if (last_removed_stream_.get()) |
| 213 | return last_removed_stream_->label(); |
| 214 | return ""; |
| 215 | } |
| 216 | |
| 217 | scoped_refptr<PeerConnectionInterface> pc_; |
| 218 | PeerConnectionInterface::SignalingState state_; |
| 219 | scoped_ptr<IceCandidateInterface> last_candidate_; |
| 220 | scoped_refptr<DataChannelInterface> last_datachannel_; |
| 221 | bool renegotiation_needed_; |
| 222 | bool ice_complete_; |
| 223 | |
| 224 | private: |
| 225 | scoped_refptr<MediaStreamInterface> last_added_stream_; |
| 226 | scoped_refptr<MediaStreamInterface> last_removed_stream_; |
| 227 | }; |
| 228 | |
| 229 | } // namespace |
| 230 | class PeerConnectionInterfaceTest : public testing::Test { |
| 231 | protected: |
| 232 | virtual void SetUp() { |
sergeyu@chromium.org | a23f0ca | 2013-11-13 22:48:52 +0000 | [diff] [blame] | 233 | talk_base::InitializeSSL(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 234 | pc_factory_ = webrtc::CreatePeerConnectionFactory( |
| 235 | talk_base::Thread::Current(), talk_base::Thread::Current(), NULL, NULL, |
| 236 | NULL); |
| 237 | ASSERT_TRUE(pc_factory_.get() != NULL); |
| 238 | } |
| 239 | |
sergeyu@chromium.org | a23f0ca | 2013-11-13 22:48:52 +0000 | [diff] [blame] | 240 | virtual void TearDown() { |
| 241 | talk_base::CleanupSSL(); |
| 242 | } |
| 243 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 244 | void CreatePeerConnection() { |
| 245 | CreatePeerConnection("", "", NULL); |
| 246 | } |
| 247 | |
| 248 | void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) { |
| 249 | CreatePeerConnection("", "", constraints); |
| 250 | } |
| 251 | |
| 252 | void CreatePeerConnection(const std::string& uri, |
| 253 | const std::string& password, |
| 254 | webrtc::MediaConstraintsInterface* constraints) { |
| 255 | PeerConnectionInterface::IceServer server; |
| 256 | PeerConnectionInterface::IceServers servers; |
| 257 | server.uri = uri; |
| 258 | server.password = password; |
| 259 | servers.push_back(server); |
| 260 | |
| 261 | port_allocator_factory_ = FakePortAllocatorFactory::Create(); |
jiayl@webrtc.org | a576faf | 2014-01-29 17:45:53 +0000 | [diff] [blame^] | 262 | |
| 263 | // TODO(jiayl): we should always pass a FakeIdentityService so that DTLS |
| 264 | // is enabled by default like in Chrome (issue 2838). |
| 265 | FakeIdentityService* dtls_service = NULL; |
| 266 | bool dtls; |
| 267 | if (FindConstraint(constraints, |
| 268 | webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 269 | &dtls, |
| 270 | NULL) && dtls) { |
| 271 | dtls_service = new FakeIdentityService(); |
| 272 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 273 | pc_ = pc_factory_->CreatePeerConnection(servers, constraints, |
| 274 | port_allocator_factory_.get(), |
jiayl@webrtc.org | a576faf | 2014-01-29 17:45:53 +0000 | [diff] [blame^] | 275 | dtls_service, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 276 | &observer_); |
| 277 | ASSERT_TRUE(pc_.get() != NULL); |
| 278 | observer_.SetPeerConnectionInterface(pc_.get()); |
| 279 | EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
| 280 | } |
| 281 | |
| 282 | void CreatePeerConnectionWithDifferentConfigurations() { |
| 283 | CreatePeerConnection(kStunAddressOnly, "", NULL); |
| 284 | EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size()); |
| 285 | EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); |
| 286 | EXPECT_EQ("address", |
| 287 | port_allocator_factory_->stun_configs()[0].server.hostname()); |
| 288 | EXPECT_EQ(kDefaultStunPort, |
| 289 | port_allocator_factory_->stun_configs()[0].server.port()); |
| 290 | |
| 291 | CreatePeerConnection(kStunInvalidPort, "", NULL); |
| 292 | EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size()); |
| 293 | EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); |
| 294 | |
| 295 | CreatePeerConnection(kStunAddressPortAndMore1, "", NULL); |
| 296 | EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size()); |
| 297 | EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); |
| 298 | |
| 299 | CreatePeerConnection(kStunAddressPortAndMore2, "", NULL); |
| 300 | EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size()); |
| 301 | EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); |
| 302 | |
| 303 | CreatePeerConnection(kTurnIceServerUri, kTurnPassword, NULL); |
| 304 | EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size()); |
| 305 | EXPECT_EQ(1u, port_allocator_factory_->turn_configs().size()); |
| 306 | EXPECT_EQ(kTurnUsername, |
| 307 | port_allocator_factory_->turn_configs()[0].username); |
| 308 | EXPECT_EQ(kTurnPassword, |
| 309 | port_allocator_factory_->turn_configs()[0].password); |
| 310 | EXPECT_EQ(kTurnHostname, |
| 311 | port_allocator_factory_->turn_configs()[0].server.hostname()); |
| 312 | EXPECT_EQ(kTurnHostname, |
| 313 | port_allocator_factory_->stun_configs()[0].server.hostname()); |
| 314 | } |
| 315 | |
| 316 | void ReleasePeerConnection() { |
| 317 | pc_ = NULL; |
| 318 | observer_.SetPeerConnectionInterface(NULL); |
| 319 | } |
| 320 | |
| 321 | void AddStream(const std::string& label) { |
| 322 | // Create a local stream. |
| 323 | scoped_refptr<MediaStreamInterface> stream( |
| 324 | pc_factory_->CreateLocalMediaStream(label)); |
| 325 | scoped_refptr<VideoSourceInterface> video_source( |
| 326 | pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer(), NULL)); |
| 327 | scoped_refptr<VideoTrackInterface> video_track( |
| 328 | pc_factory_->CreateVideoTrack(label + "v0", video_source)); |
| 329 | stream->AddTrack(video_track.get()); |
| 330 | EXPECT_TRUE(pc_->AddStream(stream, NULL)); |
| 331 | EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
| 332 | observer_.renegotiation_needed_ = false; |
| 333 | } |
| 334 | |
| 335 | void AddVoiceStream(const std::string& label) { |
| 336 | // Create a local stream. |
| 337 | scoped_refptr<MediaStreamInterface> stream( |
| 338 | pc_factory_->CreateLocalMediaStream(label)); |
| 339 | scoped_refptr<AudioTrackInterface> audio_track( |
| 340 | pc_factory_->CreateAudioTrack(label + "a0", NULL)); |
| 341 | stream->AddTrack(audio_track.get()); |
| 342 | EXPECT_TRUE(pc_->AddStream(stream, NULL)); |
| 343 | EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
| 344 | observer_.renegotiation_needed_ = false; |
| 345 | } |
| 346 | |
| 347 | void AddAudioVideoStream(const std::string& stream_label, |
| 348 | const std::string& audio_track_label, |
| 349 | const std::string& video_track_label) { |
| 350 | // Create a local stream. |
| 351 | scoped_refptr<MediaStreamInterface> stream( |
| 352 | pc_factory_->CreateLocalMediaStream(stream_label)); |
| 353 | scoped_refptr<AudioTrackInterface> audio_track( |
| 354 | pc_factory_->CreateAudioTrack( |
| 355 | audio_track_label, static_cast<AudioSourceInterface*>(NULL))); |
| 356 | stream->AddTrack(audio_track.get()); |
| 357 | scoped_refptr<VideoTrackInterface> video_track( |
| 358 | pc_factory_->CreateVideoTrack(video_track_label, NULL)); |
| 359 | stream->AddTrack(video_track.get()); |
| 360 | EXPECT_TRUE(pc_->AddStream(stream, NULL)); |
| 361 | EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
| 362 | observer_.renegotiation_needed_ = false; |
| 363 | } |
| 364 | |
| 365 | bool DoCreateOfferAnswer(SessionDescriptionInterface** desc, bool offer) { |
| 366 | talk_base::scoped_refptr<MockCreateSessionDescriptionObserver> |
| 367 | observer(new talk_base::RefCountedObject< |
| 368 | MockCreateSessionDescriptionObserver>()); |
| 369 | if (offer) { |
| 370 | pc_->CreateOffer(observer, NULL); |
| 371 | } else { |
| 372 | pc_->CreateAnswer(observer, NULL); |
| 373 | } |
| 374 | EXPECT_EQ_WAIT(true, observer->called(), kTimeout); |
| 375 | *desc = observer->release_desc(); |
| 376 | return observer->result(); |
| 377 | } |
| 378 | |
| 379 | bool DoCreateOffer(SessionDescriptionInterface** desc) { |
| 380 | return DoCreateOfferAnswer(desc, true); |
| 381 | } |
| 382 | |
| 383 | bool DoCreateAnswer(SessionDescriptionInterface** desc) { |
| 384 | return DoCreateOfferAnswer(desc, false); |
| 385 | } |
| 386 | |
| 387 | bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) { |
| 388 | talk_base::scoped_refptr<MockSetSessionDescriptionObserver> |
| 389 | observer(new talk_base::RefCountedObject< |
| 390 | MockSetSessionDescriptionObserver>()); |
| 391 | if (local) { |
| 392 | pc_->SetLocalDescription(observer, desc); |
| 393 | } else { |
| 394 | pc_->SetRemoteDescription(observer, desc); |
| 395 | } |
| 396 | EXPECT_EQ_WAIT(true, observer->called(), kTimeout); |
| 397 | return observer->result(); |
| 398 | } |
| 399 | |
| 400 | bool DoSetLocalDescription(SessionDescriptionInterface* desc) { |
| 401 | return DoSetSessionDescription(desc, true); |
| 402 | } |
| 403 | |
| 404 | bool DoSetRemoteDescription(SessionDescriptionInterface* desc) { |
| 405 | return DoSetSessionDescription(desc, false); |
| 406 | } |
| 407 | |
| 408 | // Calls PeerConnection::GetStats and check the return value. |
| 409 | // It does not verify the values in the StatReports since a RTCP packet might |
| 410 | // be required. |
| 411 | bool DoGetStats(MediaStreamTrackInterface* track) { |
| 412 | talk_base::scoped_refptr<MockStatsObserver> observer( |
| 413 | new talk_base::RefCountedObject<MockStatsObserver>()); |
| 414 | if (!pc_->GetStats(observer, track)) |
| 415 | return false; |
| 416 | EXPECT_TRUE_WAIT(observer->called(), kTimeout); |
| 417 | return observer->called(); |
| 418 | } |
| 419 | |
| 420 | void InitiateCall() { |
| 421 | CreatePeerConnection(); |
| 422 | // Create a local stream with audio&video tracks. |
| 423 | AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
| 424 | CreateOfferReceiveAnswer(); |
| 425 | } |
| 426 | |
| 427 | // Verify that RTP Header extensions has been negotiated for audio and video. |
| 428 | void VerifyRemoteRtpHeaderExtensions() { |
| 429 | const cricket::MediaContentDescription* desc = |
| 430 | cricket::GetFirstAudioContentDescription( |
| 431 | pc_->remote_description()->description()); |
| 432 | ASSERT_TRUE(desc != NULL); |
| 433 | EXPECT_GT(desc->rtp_header_extensions().size(), 0u); |
| 434 | |
| 435 | desc = cricket::GetFirstVideoContentDescription( |
| 436 | pc_->remote_description()->description()); |
| 437 | ASSERT_TRUE(desc != NULL); |
| 438 | EXPECT_GT(desc->rtp_header_extensions().size(), 0u); |
| 439 | } |
| 440 | |
| 441 | void CreateOfferAsRemoteDescription() { |
| 442 | talk_base::scoped_ptr<SessionDescriptionInterface> offer; |
| 443 | EXPECT_TRUE(DoCreateOffer(offer.use())); |
| 444 | std::string sdp; |
| 445 | EXPECT_TRUE(offer->ToString(&sdp)); |
| 446 | SessionDescriptionInterface* remote_offer = |
| 447 | webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 448 | sdp, NULL); |
| 449 | EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); |
| 450 | EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); |
| 451 | } |
| 452 | |
| 453 | void CreateAnswerAsLocalDescription() { |
| 454 | scoped_ptr<SessionDescriptionInterface> answer; |
| 455 | EXPECT_TRUE(DoCreateAnswer(answer.use())); |
| 456 | |
| 457 | // TODO(perkj): Currently SetLocalDescription fails if any parameters in an |
| 458 | // audio codec change, even if the parameter has nothing to do with |
| 459 | // receiving. Not all parameters are serialized to SDP. |
| 460 | // Since CreatePrAnswerAsLocalDescription serialize/deserialize |
| 461 | // the SessionDescription, it is necessary to do that here to in order to |
| 462 | // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. |
| 463 | // https://code.google.com/p/webrtc/issues/detail?id=1356 |
| 464 | std::string sdp; |
| 465 | EXPECT_TRUE(answer->ToString(&sdp)); |
| 466 | SessionDescriptionInterface* new_answer = |
| 467 | webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, |
| 468 | sdp, NULL); |
| 469 | EXPECT_TRUE(DoSetLocalDescription(new_answer)); |
| 470 | EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
| 471 | } |
| 472 | |
| 473 | void CreatePrAnswerAsLocalDescription() { |
| 474 | scoped_ptr<SessionDescriptionInterface> answer; |
| 475 | EXPECT_TRUE(DoCreateAnswer(answer.use())); |
| 476 | |
| 477 | std::string sdp; |
| 478 | EXPECT_TRUE(answer->ToString(&sdp)); |
| 479 | SessionDescriptionInterface* pr_answer = |
| 480 | webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer, |
| 481 | sdp, NULL); |
| 482 | EXPECT_TRUE(DoSetLocalDescription(pr_answer)); |
| 483 | EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_); |
| 484 | } |
| 485 | |
| 486 | void CreateOfferReceiveAnswer() { |
| 487 | CreateOfferAsLocalDescription(); |
| 488 | std::string sdp; |
| 489 | EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
| 490 | CreateAnswerAsRemoteDescription(sdp); |
| 491 | } |
| 492 | |
| 493 | void CreateOfferAsLocalDescription() { |
| 494 | talk_base::scoped_ptr<SessionDescriptionInterface> offer; |
| 495 | ASSERT_TRUE(DoCreateOffer(offer.use())); |
| 496 | // TODO(perkj): Currently SetLocalDescription fails if any parameters in an |
| 497 | // audio codec change, even if the parameter has nothing to do with |
| 498 | // receiving. Not all parameters are serialized to SDP. |
| 499 | // Since CreatePrAnswerAsLocalDescription serialize/deserialize |
| 500 | // the SessionDescription, it is necessary to do that here to in order to |
| 501 | // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. |
| 502 | // https://code.google.com/p/webrtc/issues/detail?id=1356 |
| 503 | std::string sdp; |
| 504 | EXPECT_TRUE(offer->ToString(&sdp)); |
| 505 | SessionDescriptionInterface* new_offer = |
| 506 | webrtc::CreateSessionDescription( |
| 507 | SessionDescriptionInterface::kOffer, |
| 508 | sdp, NULL); |
| 509 | |
| 510 | EXPECT_TRUE(DoSetLocalDescription(new_offer)); |
| 511 | EXPECT_EQ(PeerConnectionInterface::kHaveLocalOffer, observer_.state_); |
mallinath@webrtc.org | 68cbd01 | 2014-01-22 00:16:46 +0000 | [diff] [blame] | 512 | // Wait for the ice_complete message, so that SDP will have candidates. |
| 513 | EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | void CreateAnswerAsRemoteDescription(const std::string& offer) { |
| 517 | webrtc::JsepSessionDescription* answer = new webrtc::JsepSessionDescription( |
| 518 | SessionDescriptionInterface::kAnswer); |
| 519 | EXPECT_TRUE(answer->Initialize(offer, NULL)); |
| 520 | EXPECT_TRUE(DoSetRemoteDescription(answer)); |
| 521 | EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
| 522 | } |
| 523 | |
| 524 | void CreatePrAnswerAndAnswerAsRemoteDescription(const std::string& offer) { |
| 525 | webrtc::JsepSessionDescription* pr_answer = |
| 526 | new webrtc::JsepSessionDescription( |
| 527 | SessionDescriptionInterface::kPrAnswer); |
| 528 | EXPECT_TRUE(pr_answer->Initialize(offer, NULL)); |
| 529 | EXPECT_TRUE(DoSetRemoteDescription(pr_answer)); |
| 530 | EXPECT_EQ(PeerConnectionInterface::kHaveRemotePrAnswer, observer_.state_); |
| 531 | webrtc::JsepSessionDescription* answer = |
| 532 | new webrtc::JsepSessionDescription( |
| 533 | SessionDescriptionInterface::kAnswer); |
| 534 | EXPECT_TRUE(answer->Initialize(offer, NULL)); |
| 535 | EXPECT_TRUE(DoSetRemoteDescription(answer)); |
| 536 | EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
| 537 | } |
| 538 | |
| 539 | // Help function used for waiting until a the last signaled remote stream has |
| 540 | // the same label as |stream_label|. In a few of the tests in this file we |
| 541 | // answer with the same session description as we offer and thus we can |
| 542 | // check if OnAddStream have been called with the same stream as we offer to |
| 543 | // send. |
| 544 | void WaitAndVerifyOnAddStream(const std::string& stream_label) { |
| 545 | EXPECT_EQ_WAIT(stream_label, observer_.GetLastAddedStreamLabel(), kTimeout); |
| 546 | } |
| 547 | |
| 548 | // Creates an offer and applies it as a local session description. |
| 549 | // Creates an answer with the same SDP an the offer but removes all lines |
| 550 | // that start with a:ssrc" |
| 551 | void CreateOfferReceiveAnswerWithoutSsrc() { |
| 552 | CreateOfferAsLocalDescription(); |
| 553 | std::string sdp; |
| 554 | EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
| 555 | SetSsrcToZero(&sdp); |
| 556 | CreateAnswerAsRemoteDescription(sdp); |
| 557 | } |
| 558 | |
| 559 | scoped_refptr<FakePortAllocatorFactory> port_allocator_factory_; |
| 560 | scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; |
| 561 | scoped_refptr<PeerConnectionInterface> pc_; |
| 562 | MockPeerConnectionObserver observer_; |
| 563 | }; |
| 564 | |
| 565 | TEST_F(PeerConnectionInterfaceTest, |
| 566 | CreatePeerConnectionWithDifferentConfigurations) { |
| 567 | CreatePeerConnectionWithDifferentConfigurations(); |
| 568 | } |
| 569 | |
| 570 | TEST_F(PeerConnectionInterfaceTest, AddStreams) { |
| 571 | CreatePeerConnection(); |
| 572 | AddStream(kStreamLabel1); |
| 573 | AddVoiceStream(kStreamLabel2); |
| 574 | ASSERT_EQ(2u, pc_->local_streams()->count()); |
| 575 | |
wu@webrtc.org | 9dba525 | 2013-08-05 20:36:57 +0000 | [diff] [blame] | 576 | // Test we can add multiple local streams to one peerconnection. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 577 | scoped_refptr<MediaStreamInterface> stream( |
| 578 | pc_factory_->CreateLocalMediaStream(kStreamLabel3)); |
| 579 | scoped_refptr<AudioTrackInterface> audio_track( |
| 580 | pc_factory_->CreateAudioTrack( |
| 581 | kStreamLabel3, static_cast<AudioSourceInterface*>(NULL))); |
| 582 | stream->AddTrack(audio_track.get()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 583 | EXPECT_TRUE(pc_->AddStream(stream, NULL)); |
wu@webrtc.org | 9dba525 | 2013-08-05 20:36:57 +0000 | [diff] [blame] | 584 | EXPECT_EQ(3u, pc_->local_streams()->count()); |
| 585 | |
| 586 | // Remove the third stream. |
| 587 | pc_->RemoveStream(pc_->local_streams()->at(2)); |
| 588 | EXPECT_EQ(2u, pc_->local_streams()->count()); |
| 589 | |
| 590 | // Remove the second stream. |
| 591 | pc_->RemoveStream(pc_->local_streams()->at(1)); |
| 592 | EXPECT_EQ(1u, pc_->local_streams()->count()); |
| 593 | |
| 594 | // Remove the first stream. |
| 595 | pc_->RemoveStream(pc_->local_streams()->at(0)); |
| 596 | EXPECT_EQ(0u, pc_->local_streams()->count()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | TEST_F(PeerConnectionInterfaceTest, RemoveStream) { |
| 600 | CreatePeerConnection(); |
| 601 | AddStream(kStreamLabel1); |
| 602 | ASSERT_EQ(1u, pc_->local_streams()->count()); |
| 603 | pc_->RemoveStream(pc_->local_streams()->at(0)); |
| 604 | EXPECT_EQ(0u, pc_->local_streams()->count()); |
| 605 | } |
| 606 | |
| 607 | TEST_F(PeerConnectionInterfaceTest, CreateOfferReceiveAnswer) { |
| 608 | InitiateCall(); |
| 609 | WaitAndVerifyOnAddStream(kStreamLabel1); |
| 610 | VerifyRemoteRtpHeaderExtensions(); |
| 611 | } |
| 612 | |
| 613 | TEST_F(PeerConnectionInterfaceTest, CreateOfferReceivePrAnswerAndAnswer) { |
| 614 | CreatePeerConnection(); |
| 615 | AddStream(kStreamLabel1); |
| 616 | CreateOfferAsLocalDescription(); |
| 617 | std::string offer; |
| 618 | EXPECT_TRUE(pc_->local_description()->ToString(&offer)); |
| 619 | CreatePrAnswerAndAnswerAsRemoteDescription(offer); |
| 620 | WaitAndVerifyOnAddStream(kStreamLabel1); |
| 621 | } |
| 622 | |
| 623 | TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreateAnswer) { |
| 624 | CreatePeerConnection(); |
| 625 | AddStream(kStreamLabel1); |
| 626 | |
| 627 | CreateOfferAsRemoteDescription(); |
| 628 | CreateAnswerAsLocalDescription(); |
| 629 | |
| 630 | WaitAndVerifyOnAddStream(kStreamLabel1); |
| 631 | } |
| 632 | |
| 633 | TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreatePrAnswerAndAnswer) { |
| 634 | CreatePeerConnection(); |
| 635 | AddStream(kStreamLabel1); |
| 636 | |
| 637 | CreateOfferAsRemoteDescription(); |
| 638 | CreatePrAnswerAsLocalDescription(); |
| 639 | CreateAnswerAsLocalDescription(); |
| 640 | |
| 641 | WaitAndVerifyOnAddStream(kStreamLabel1); |
| 642 | } |
| 643 | |
| 644 | TEST_F(PeerConnectionInterfaceTest, Renegotiate) { |
| 645 | InitiateCall(); |
| 646 | ASSERT_EQ(1u, pc_->remote_streams()->count()); |
| 647 | pc_->RemoveStream(pc_->local_streams()->at(0)); |
| 648 | CreateOfferReceiveAnswer(); |
| 649 | EXPECT_EQ(0u, pc_->remote_streams()->count()); |
| 650 | AddStream(kStreamLabel1); |
| 651 | CreateOfferReceiveAnswer(); |
| 652 | } |
| 653 | |
| 654 | // Tests that after negotiating an audio only call, the respondent can perform a |
| 655 | // renegotiation that removes the audio stream. |
| 656 | TEST_F(PeerConnectionInterfaceTest, RenegotiateAudioOnly) { |
| 657 | CreatePeerConnection(); |
| 658 | AddVoiceStream(kStreamLabel1); |
| 659 | CreateOfferAsRemoteDescription(); |
| 660 | CreateAnswerAsLocalDescription(); |
| 661 | |
| 662 | ASSERT_EQ(1u, pc_->remote_streams()->count()); |
| 663 | pc_->RemoveStream(pc_->local_streams()->at(0)); |
| 664 | CreateOfferReceiveAnswer(); |
| 665 | EXPECT_EQ(0u, pc_->remote_streams()->count()); |
| 666 | } |
| 667 | |
| 668 | // Test that candidates are generated and that we can parse our own candidates. |
| 669 | TEST_F(PeerConnectionInterfaceTest, IceCandidates) { |
| 670 | CreatePeerConnection(); |
| 671 | |
| 672 | EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get())); |
| 673 | // SetRemoteDescription takes ownership of offer. |
| 674 | SessionDescriptionInterface* offer = NULL; |
| 675 | AddStream(kStreamLabel1); |
| 676 | EXPECT_TRUE(DoCreateOffer(&offer)); |
| 677 | EXPECT_TRUE(DoSetRemoteDescription(offer)); |
| 678 | |
| 679 | // SetLocalDescription takes ownership of answer. |
| 680 | SessionDescriptionInterface* answer = NULL; |
| 681 | EXPECT_TRUE(DoCreateAnswer(&answer)); |
| 682 | EXPECT_TRUE(DoSetLocalDescription(answer)); |
| 683 | |
| 684 | EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); |
| 685 | EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); |
| 686 | |
| 687 | EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); |
| 688 | } |
| 689 | |
| 690 | // Test that the CreateOffer and CreatAnswer will fail if the track labels are |
| 691 | // not unique. |
| 692 | TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { |
| 693 | CreatePeerConnection(); |
| 694 | // Create a regular offer for the CreateAnswer test later. |
| 695 | SessionDescriptionInterface* offer = NULL; |
| 696 | EXPECT_TRUE(DoCreateOffer(&offer)); |
| 697 | EXPECT_TRUE(offer != NULL); |
| 698 | delete offer; |
| 699 | offer = NULL; |
| 700 | |
| 701 | // Create a local stream with audio&video tracks having same label. |
| 702 | AddAudioVideoStream(kStreamLabel1, "track_label", "track_label"); |
| 703 | |
| 704 | // Test CreateOffer |
| 705 | EXPECT_FALSE(DoCreateOffer(&offer)); |
| 706 | |
| 707 | // Test CreateAnswer |
| 708 | SessionDescriptionInterface* answer = NULL; |
| 709 | EXPECT_FALSE(DoCreateAnswer(&answer)); |
| 710 | } |
| 711 | |
| 712 | // Test that we will get different SSRCs for each tracks in the offer and answer |
| 713 | // we created. |
| 714 | TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { |
| 715 | CreatePeerConnection(); |
| 716 | // Create a local stream with audio&video tracks having different labels. |
| 717 | AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
| 718 | |
| 719 | // Test CreateOffer |
| 720 | scoped_ptr<SessionDescriptionInterface> offer; |
| 721 | EXPECT_TRUE(DoCreateOffer(offer.use())); |
| 722 | int audio_ssrc = 0; |
| 723 | int video_ssrc = 0; |
| 724 | EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), |
| 725 | &audio_ssrc)); |
| 726 | EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(offer->description()), |
| 727 | &video_ssrc)); |
| 728 | EXPECT_NE(audio_ssrc, video_ssrc); |
| 729 | |
| 730 | // Test CreateAnswer |
| 731 | EXPECT_TRUE(DoSetRemoteDescription(offer.release())); |
| 732 | scoped_ptr<SessionDescriptionInterface> answer; |
| 733 | EXPECT_TRUE(DoCreateAnswer(answer.use())); |
| 734 | audio_ssrc = 0; |
| 735 | video_ssrc = 0; |
| 736 | EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(answer->description()), |
| 737 | &audio_ssrc)); |
| 738 | EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), |
| 739 | &video_ssrc)); |
| 740 | EXPECT_NE(audio_ssrc, video_ssrc); |
| 741 | } |
| 742 | |
| 743 | // Test that we can specify a certain track that we want statistics about. |
| 744 | TEST_F(PeerConnectionInterfaceTest, GetStatsForSpecificTrack) { |
| 745 | InitiateCall(); |
| 746 | ASSERT_LT(0u, pc_->remote_streams()->count()); |
| 747 | ASSERT_LT(0u, pc_->remote_streams()->at(0)->GetAudioTracks().size()); |
| 748 | scoped_refptr<MediaStreamTrackInterface> remote_audio = |
| 749 | pc_->remote_streams()->at(0)->GetAudioTracks()[0]; |
| 750 | EXPECT_TRUE(DoGetStats(remote_audio)); |
| 751 | |
| 752 | // Remove the stream. Since we are sending to our selves the local |
| 753 | // and the remote stream is the same. |
| 754 | pc_->RemoveStream(pc_->local_streams()->at(0)); |
| 755 | // Do a re-negotiation. |
| 756 | CreateOfferReceiveAnswer(); |
| 757 | |
| 758 | ASSERT_EQ(0u, pc_->remote_streams()->count()); |
| 759 | |
| 760 | // Test that we still can get statistics for the old track. Even if it is not |
| 761 | // sent any longer. |
| 762 | EXPECT_TRUE(DoGetStats(remote_audio)); |
| 763 | } |
| 764 | |
| 765 | // Test that we can get stats on a video track. |
| 766 | TEST_F(PeerConnectionInterfaceTest, GetStatsForVideoTrack) { |
| 767 | InitiateCall(); |
| 768 | ASSERT_LT(0u, pc_->remote_streams()->count()); |
| 769 | ASSERT_LT(0u, pc_->remote_streams()->at(0)->GetVideoTracks().size()); |
| 770 | scoped_refptr<MediaStreamTrackInterface> remote_video = |
| 771 | pc_->remote_streams()->at(0)->GetVideoTracks()[0]; |
| 772 | EXPECT_TRUE(DoGetStats(remote_video)); |
| 773 | } |
| 774 | |
| 775 | // Test that we don't get statistics for an invalid track. |
| 776 | TEST_F(PeerConnectionInterfaceTest, GetStatsForInvalidTrack) { |
| 777 | InitiateCall(); |
| 778 | scoped_refptr<AudioTrackInterface> unknown_audio_track( |
| 779 | pc_factory_->CreateAudioTrack("unknown track", NULL)); |
| 780 | EXPECT_FALSE(DoGetStats(unknown_audio_track)); |
| 781 | } |
| 782 | |
| 783 | // This test setup two RTP data channels in loop back. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 784 | TEST_F(PeerConnectionInterfaceTest, TestDataChannel) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 785 | FakeConstraints constraints; |
| 786 | constraints.SetAllowRtpDataChannels(); |
| 787 | CreatePeerConnection(&constraints); |
| 788 | scoped_refptr<DataChannelInterface> data1 = |
| 789 | pc_->CreateDataChannel("test1", NULL); |
| 790 | scoped_refptr<DataChannelInterface> data2 = |
| 791 | pc_->CreateDataChannel("test2", NULL); |
| 792 | ASSERT_TRUE(data1 != NULL); |
| 793 | talk_base::scoped_ptr<MockDataChannelObserver> observer1( |
| 794 | new MockDataChannelObserver(data1)); |
| 795 | talk_base::scoped_ptr<MockDataChannelObserver> observer2( |
| 796 | new MockDataChannelObserver(data2)); |
| 797 | |
| 798 | EXPECT_EQ(DataChannelInterface::kConnecting, data1->state()); |
| 799 | EXPECT_EQ(DataChannelInterface::kConnecting, data2->state()); |
| 800 | std::string data_to_send1 = "testing testing"; |
| 801 | std::string data_to_send2 = "testing something else"; |
| 802 | EXPECT_FALSE(data1->Send(DataBuffer(data_to_send1))); |
| 803 | |
| 804 | CreateOfferReceiveAnswer(); |
| 805 | EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); |
| 806 | EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); |
| 807 | |
| 808 | EXPECT_EQ(DataChannelInterface::kOpen, data1->state()); |
| 809 | EXPECT_EQ(DataChannelInterface::kOpen, data2->state()); |
| 810 | EXPECT_TRUE(data1->Send(DataBuffer(data_to_send1))); |
| 811 | EXPECT_TRUE(data2->Send(DataBuffer(data_to_send2))); |
| 812 | |
| 813 | EXPECT_EQ_WAIT(data_to_send1, observer1->last_message(), kTimeout); |
| 814 | EXPECT_EQ_WAIT(data_to_send2, observer2->last_message(), kTimeout); |
| 815 | |
| 816 | data1->Close(); |
| 817 | EXPECT_EQ(DataChannelInterface::kClosing, data1->state()); |
| 818 | CreateOfferReceiveAnswer(); |
| 819 | EXPECT_FALSE(observer1->IsOpen()); |
| 820 | EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); |
| 821 | EXPECT_TRUE(observer2->IsOpen()); |
| 822 | |
| 823 | data_to_send2 = "testing something else again"; |
| 824 | EXPECT_TRUE(data2->Send(DataBuffer(data_to_send2))); |
| 825 | |
| 826 | EXPECT_EQ_WAIT(data_to_send2, observer2->last_message(), kTimeout); |
| 827 | } |
| 828 | |
| 829 | // This test verifies that sendnig binary data over RTP data channels should |
| 830 | // fail. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 831 | TEST_F(PeerConnectionInterfaceTest, TestSendBinaryOnRtpDataChannel) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 832 | FakeConstraints constraints; |
| 833 | constraints.SetAllowRtpDataChannels(); |
| 834 | CreatePeerConnection(&constraints); |
| 835 | scoped_refptr<DataChannelInterface> data1 = |
| 836 | pc_->CreateDataChannel("test1", NULL); |
| 837 | scoped_refptr<DataChannelInterface> data2 = |
| 838 | pc_->CreateDataChannel("test2", NULL); |
| 839 | ASSERT_TRUE(data1 != NULL); |
| 840 | talk_base::scoped_ptr<MockDataChannelObserver> observer1( |
| 841 | new MockDataChannelObserver(data1)); |
| 842 | talk_base::scoped_ptr<MockDataChannelObserver> observer2( |
| 843 | new MockDataChannelObserver(data2)); |
| 844 | |
| 845 | EXPECT_EQ(DataChannelInterface::kConnecting, data1->state()); |
| 846 | EXPECT_EQ(DataChannelInterface::kConnecting, data2->state()); |
| 847 | |
| 848 | CreateOfferReceiveAnswer(); |
| 849 | EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); |
| 850 | EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); |
| 851 | |
| 852 | EXPECT_EQ(DataChannelInterface::kOpen, data1->state()); |
| 853 | EXPECT_EQ(DataChannelInterface::kOpen, data2->state()); |
| 854 | |
| 855 | talk_base::Buffer buffer("test", 4); |
| 856 | EXPECT_FALSE(data1->Send(DataBuffer(buffer, true))); |
| 857 | } |
| 858 | |
| 859 | // This test setup a RTP data channels in loop back and test that a channel is |
| 860 | // opened even if the remote end answer with a zero SSRC. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 861 | TEST_F(PeerConnectionInterfaceTest, TestSendOnlyDataChannel) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 862 | FakeConstraints constraints; |
| 863 | constraints.SetAllowRtpDataChannels(); |
| 864 | CreatePeerConnection(&constraints); |
| 865 | scoped_refptr<DataChannelInterface> data1 = |
| 866 | pc_->CreateDataChannel("test1", NULL); |
| 867 | talk_base::scoped_ptr<MockDataChannelObserver> observer1( |
| 868 | new MockDataChannelObserver(data1)); |
| 869 | |
| 870 | CreateOfferReceiveAnswerWithoutSsrc(); |
| 871 | |
| 872 | EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); |
| 873 | |
| 874 | data1->Close(); |
| 875 | EXPECT_EQ(DataChannelInterface::kClosing, data1->state()); |
| 876 | CreateOfferReceiveAnswerWithoutSsrc(); |
| 877 | EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); |
| 878 | EXPECT_FALSE(observer1->IsOpen()); |
| 879 | } |
| 880 | |
| 881 | // This test that if a data channel is added in an answer a receive only channel |
| 882 | // channel is created. |
| 883 | TEST_F(PeerConnectionInterfaceTest, TestReceiveOnlyDataChannel) { |
| 884 | FakeConstraints constraints; |
| 885 | constraints.SetAllowRtpDataChannels(); |
| 886 | CreatePeerConnection(&constraints); |
| 887 | |
| 888 | std::string offer_label = "offer_channel"; |
| 889 | scoped_refptr<DataChannelInterface> offer_channel = |
| 890 | pc_->CreateDataChannel(offer_label, NULL); |
| 891 | |
| 892 | CreateOfferAsLocalDescription(); |
| 893 | |
| 894 | // Replace the data channel label in the offer and apply it as an answer. |
| 895 | std::string receive_label = "answer_channel"; |
| 896 | std::string sdp; |
| 897 | EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
| 898 | talk_base::replace_substrs(offer_label.c_str(), offer_label.length(), |
| 899 | receive_label.c_str(), receive_label.length(), |
| 900 | &sdp); |
| 901 | CreateAnswerAsRemoteDescription(sdp); |
| 902 | |
| 903 | // Verify that a new incoming data channel has been created and that |
| 904 | // it is open but can't we written to. |
| 905 | ASSERT_TRUE(observer_.last_datachannel_ != NULL); |
| 906 | DataChannelInterface* received_channel = observer_.last_datachannel_; |
| 907 | EXPECT_EQ(DataChannelInterface::kConnecting, received_channel->state()); |
| 908 | EXPECT_EQ(receive_label, received_channel->label()); |
| 909 | EXPECT_FALSE(received_channel->Send(DataBuffer("something"))); |
| 910 | |
| 911 | // Verify that the channel we initially offered has been rejected. |
| 912 | EXPECT_EQ(DataChannelInterface::kClosed, offer_channel->state()); |
| 913 | |
| 914 | // Do another offer / answer exchange and verify that the data channel is |
| 915 | // opened. |
| 916 | CreateOfferReceiveAnswer(); |
| 917 | EXPECT_EQ_WAIT(DataChannelInterface::kOpen, received_channel->state(), |
| 918 | kTimeout); |
| 919 | } |
| 920 | |
| 921 | // This test that no data channel is returned if a reliable channel is |
| 922 | // requested. |
| 923 | // TODO(perkj): Remove this test once reliable channels are implemented. |
| 924 | TEST_F(PeerConnectionInterfaceTest, CreateReliableRtpDataChannelShouldFail) { |
| 925 | FakeConstraints constraints; |
| 926 | constraints.SetAllowRtpDataChannels(); |
| 927 | CreatePeerConnection(&constraints); |
| 928 | |
| 929 | std::string label = "test"; |
| 930 | webrtc::DataChannelInit config; |
| 931 | config.reliable = true; |
| 932 | scoped_refptr<DataChannelInterface> channel = |
| 933 | pc_->CreateDataChannel(label, &config); |
| 934 | EXPECT_TRUE(channel == NULL); |
| 935 | } |
| 936 | |
| 937 | // This tests that a SCTP data channel is returned using different |
| 938 | // DataChannelInit configurations. |
| 939 | TEST_F(PeerConnectionInterfaceTest, CreateSctpDataChannel) { |
| 940 | FakeConstraints constraints; |
| 941 | constraints.SetAllowDtlsSctpDataChannels(); |
| 942 | CreatePeerConnection(&constraints); |
| 943 | |
| 944 | webrtc::DataChannelInit config; |
| 945 | |
| 946 | scoped_refptr<DataChannelInterface> channel = |
| 947 | pc_->CreateDataChannel("1", &config); |
| 948 | EXPECT_TRUE(channel != NULL); |
| 949 | EXPECT_TRUE(channel->reliable()); |
| 950 | |
| 951 | config.ordered = false; |
| 952 | channel = pc_->CreateDataChannel("2", &config); |
| 953 | EXPECT_TRUE(channel != NULL); |
| 954 | EXPECT_TRUE(channel->reliable()); |
| 955 | |
| 956 | config.ordered = true; |
| 957 | config.maxRetransmits = 0; |
| 958 | channel = pc_->CreateDataChannel("3", &config); |
| 959 | EXPECT_TRUE(channel != NULL); |
| 960 | EXPECT_FALSE(channel->reliable()); |
| 961 | |
| 962 | config.maxRetransmits = -1; |
| 963 | config.maxRetransmitTime = 0; |
| 964 | channel = pc_->CreateDataChannel("4", &config); |
| 965 | EXPECT_TRUE(channel != NULL); |
| 966 | EXPECT_FALSE(channel->reliable()); |
| 967 | } |
| 968 | |
| 969 | // This tests that no data channel is returned if both maxRetransmits and |
| 970 | // maxRetransmitTime are set for SCTP data channels. |
| 971 | TEST_F(PeerConnectionInterfaceTest, |
| 972 | CreateSctpDataChannelShouldFailForInvalidConfig) { |
| 973 | FakeConstraints constraints; |
| 974 | constraints.SetAllowDtlsSctpDataChannels(); |
| 975 | CreatePeerConnection(&constraints); |
| 976 | |
| 977 | std::string label = "test"; |
| 978 | webrtc::DataChannelInit config; |
| 979 | config.maxRetransmits = 0; |
| 980 | config.maxRetransmitTime = 0; |
| 981 | |
| 982 | scoped_refptr<DataChannelInterface> channel = |
| 983 | pc_->CreateDataChannel(label, &config); |
| 984 | EXPECT_TRUE(channel == NULL); |
| 985 | } |
| 986 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 987 | // The test verifies that creating a SCTP data channel with an id already in use |
| 988 | // or out of range should fail. |
| 989 | TEST_F(PeerConnectionInterfaceTest, |
| 990 | CreateSctpDataChannelWithInvalidIdShouldFail) { |
| 991 | FakeConstraints constraints; |
| 992 | constraints.SetAllowDtlsSctpDataChannels(); |
| 993 | CreatePeerConnection(&constraints); |
| 994 | |
| 995 | webrtc::DataChannelInit config; |
wu@webrtc.org | cecfd18 | 2013-10-30 05:18:12 +0000 | [diff] [blame] | 996 | scoped_refptr<DataChannelInterface> channel; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 997 | |
wu@webrtc.org | cecfd18 | 2013-10-30 05:18:12 +0000 | [diff] [blame] | 998 | config.id = 1; |
| 999 | channel = pc_->CreateDataChannel("1", &config); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1000 | EXPECT_TRUE(channel != NULL); |
| 1001 | EXPECT_EQ(1, channel->id()); |
| 1002 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1003 | channel = pc_->CreateDataChannel("x", &config); |
| 1004 | EXPECT_TRUE(channel == NULL); |
| 1005 | |
| 1006 | config.id = cricket::kMaxSctpSid; |
| 1007 | channel = pc_->CreateDataChannel("max", &config); |
| 1008 | EXPECT_TRUE(channel != NULL); |
| 1009 | EXPECT_EQ(config.id, channel->id()); |
| 1010 | |
| 1011 | config.id = cricket::kMaxSctpSid + 1; |
| 1012 | channel = pc_->CreateDataChannel("x", &config); |
| 1013 | EXPECT_TRUE(channel == NULL); |
| 1014 | } |
| 1015 | |
| 1016 | // This test that a data channel closes when a PeerConnection is deleted/closed. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1017 | TEST_F(PeerConnectionInterfaceTest, DataChannelCloseWhenPeerConnectionClose) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1018 | FakeConstraints constraints; |
| 1019 | constraints.SetAllowRtpDataChannels(); |
| 1020 | CreatePeerConnection(&constraints); |
| 1021 | |
| 1022 | scoped_refptr<DataChannelInterface> data1 = |
| 1023 | pc_->CreateDataChannel("test1", NULL); |
| 1024 | scoped_refptr<DataChannelInterface> data2 = |
| 1025 | pc_->CreateDataChannel("test2", NULL); |
| 1026 | ASSERT_TRUE(data1 != NULL); |
| 1027 | talk_base::scoped_ptr<MockDataChannelObserver> observer1( |
| 1028 | new MockDataChannelObserver(data1)); |
| 1029 | talk_base::scoped_ptr<MockDataChannelObserver> observer2( |
| 1030 | new MockDataChannelObserver(data2)); |
| 1031 | |
| 1032 | CreateOfferReceiveAnswer(); |
| 1033 | EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); |
| 1034 | EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); |
| 1035 | |
| 1036 | ReleasePeerConnection(); |
| 1037 | EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); |
| 1038 | EXPECT_EQ(DataChannelInterface::kClosed, data2->state()); |
| 1039 | } |
| 1040 | |
| 1041 | // This test that data channels can be rejected in an answer. |
| 1042 | TEST_F(PeerConnectionInterfaceTest, TestRejectDataChannelInAnswer) { |
| 1043 | FakeConstraints constraints; |
| 1044 | constraints.SetAllowRtpDataChannels(); |
| 1045 | CreatePeerConnection(&constraints); |
| 1046 | |
| 1047 | scoped_refptr<DataChannelInterface> offer_channel( |
| 1048 | pc_->CreateDataChannel("offer_channel", NULL)); |
| 1049 | |
| 1050 | CreateOfferAsLocalDescription(); |
| 1051 | |
| 1052 | // Create an answer where the m-line for data channels are rejected. |
| 1053 | std::string sdp; |
| 1054 | EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
| 1055 | webrtc::JsepSessionDescription* answer = new webrtc::JsepSessionDescription( |
| 1056 | SessionDescriptionInterface::kAnswer); |
| 1057 | EXPECT_TRUE(answer->Initialize(sdp, NULL)); |
| 1058 | cricket::ContentInfo* data_info = |
| 1059 | answer->description()->GetContentByName("data"); |
| 1060 | data_info->rejected = true; |
| 1061 | |
| 1062 | DoSetRemoteDescription(answer); |
| 1063 | EXPECT_EQ(DataChannelInterface::kClosed, offer_channel->state()); |
| 1064 | } |
| 1065 | |
| 1066 | // Test that we can create a session description from an SDP string from |
| 1067 | // FireFox, use it as a remote session description, generate an answer and use |
| 1068 | // the answer as a local description. |
sergeyu@chromium.org | a23f0ca | 2013-11-13 22:48:52 +0000 | [diff] [blame] | 1069 | TEST_F(PeerConnectionInterfaceTest, ReceiveFireFoxOffer) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1070 | MAYBE_SKIP_TEST(talk_base::SSLStreamAdapter::HaveDtlsSrtp); |
| 1071 | FakeConstraints constraints; |
| 1072 | constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 1073 | true); |
| 1074 | CreatePeerConnection(&constraints); |
| 1075 | AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
| 1076 | SessionDescriptionInterface* desc = |
| 1077 | webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 1078 | webrtc::kFireFoxSdpOffer); |
| 1079 | EXPECT_TRUE(DoSetSessionDescription(desc, false)); |
| 1080 | CreateAnswerAsLocalDescription(); |
| 1081 | ASSERT_TRUE(pc_->local_description() != NULL); |
| 1082 | ASSERT_TRUE(pc_->remote_description() != NULL); |
| 1083 | |
| 1084 | const cricket::ContentInfo* content = |
| 1085 | cricket::GetFirstAudioContent(pc_->local_description()->description()); |
| 1086 | ASSERT_TRUE(content != NULL); |
| 1087 | EXPECT_FALSE(content->rejected); |
| 1088 | |
| 1089 | content = |
| 1090 | cricket::GetFirstVideoContent(pc_->local_description()->description()); |
| 1091 | ASSERT_TRUE(content != NULL); |
| 1092 | EXPECT_FALSE(content->rejected); |
sergeyu@chromium.org | a23f0ca | 2013-11-13 22:48:52 +0000 | [diff] [blame] | 1093 | #ifdef HAVE_SCTP |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1094 | content = |
| 1095 | cricket::GetFirstDataContent(pc_->local_description()->description()); |
| 1096 | ASSERT_TRUE(content != NULL); |
| 1097 | EXPECT_TRUE(content->rejected); |
sergeyu@chromium.org | a23f0ca | 2013-11-13 22:48:52 +0000 | [diff] [blame] | 1098 | #endif |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | // Test that we can create an audio only offer and receive an answer with a |
| 1102 | // limited set of audio codecs and receive an updated offer with more audio |
| 1103 | // codecs, where the added codecs are not supported. |
| 1104 | TEST_F(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) { |
| 1105 | CreatePeerConnection(); |
| 1106 | AddVoiceStream("audio_label"); |
| 1107 | CreateOfferAsLocalDescription(); |
| 1108 | |
| 1109 | SessionDescriptionInterface* answer = |
| 1110 | webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, |
| 1111 | webrtc::kAudioSdp); |
| 1112 | EXPECT_TRUE(DoSetSessionDescription(answer, false)); |
| 1113 | |
| 1114 | SessionDescriptionInterface* updated_offer = |
| 1115 | webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 1116 | webrtc::kAudioSdpWithUnsupportedCodecs); |
| 1117 | EXPECT_TRUE(DoSetSessionDescription(updated_offer, false)); |
| 1118 | CreateAnswerAsLocalDescription(); |
| 1119 | } |
| 1120 | |
| 1121 | // Test that PeerConnection::Close changes the states to closed and all remote |
| 1122 | // tracks change state to ended. |
| 1123 | TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { |
| 1124 | // Initialize a PeerConnection and negotiate local and remote session |
| 1125 | // description. |
| 1126 | InitiateCall(); |
| 1127 | ASSERT_EQ(1u, pc_->local_streams()->count()); |
| 1128 | ASSERT_EQ(1u, pc_->remote_streams()->count()); |
| 1129 | |
| 1130 | pc_->Close(); |
| 1131 | |
| 1132 | EXPECT_EQ(PeerConnectionInterface::kClosed, pc_->signaling_state()); |
| 1133 | EXPECT_EQ(PeerConnectionInterface::kIceConnectionClosed, |
| 1134 | pc_->ice_connection_state()); |
| 1135 | EXPECT_EQ(PeerConnectionInterface::kIceGatheringComplete, |
| 1136 | pc_->ice_gathering_state()); |
| 1137 | |
| 1138 | EXPECT_EQ(1u, pc_->local_streams()->count()); |
| 1139 | EXPECT_EQ(1u, pc_->remote_streams()->count()); |
| 1140 | |
| 1141 | scoped_refptr<MediaStreamInterface> remote_stream = |
| 1142 | pc_->remote_streams()->at(0); |
| 1143 | EXPECT_EQ(MediaStreamTrackInterface::kEnded, |
| 1144 | remote_stream->GetVideoTracks()[0]->state()); |
| 1145 | EXPECT_EQ(MediaStreamTrackInterface::kEnded, |
| 1146 | remote_stream->GetAudioTracks()[0]->state()); |
| 1147 | } |
| 1148 | |
| 1149 | // Test that PeerConnection methods fails gracefully after |
| 1150 | // PeerConnection::Close has been called. |
| 1151 | TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) { |
| 1152 | CreatePeerConnection(); |
| 1153 | AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
| 1154 | CreateOfferAsRemoteDescription(); |
| 1155 | CreateAnswerAsLocalDescription(); |
| 1156 | |
| 1157 | ASSERT_EQ(1u, pc_->local_streams()->count()); |
| 1158 | scoped_refptr<MediaStreamInterface> local_stream = |
| 1159 | pc_->local_streams()->at(0); |
| 1160 | |
| 1161 | pc_->Close(); |
| 1162 | |
| 1163 | pc_->RemoveStream(local_stream); |
| 1164 | EXPECT_FALSE(pc_->AddStream(local_stream, NULL)); |
| 1165 | |
| 1166 | ASSERT_FALSE(local_stream->GetAudioTracks().empty()); |
| 1167 | talk_base::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender( |
| 1168 | pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0])); |
wu@webrtc.org | 6603736 | 2013-08-13 00:09:35 +0000 | [diff] [blame] | 1169 | EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1170 | |
| 1171 | EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL); |
| 1172 | |
| 1173 | EXPECT_TRUE(pc_->local_description() != NULL); |
| 1174 | EXPECT_TRUE(pc_->remote_description() != NULL); |
| 1175 | |
| 1176 | talk_base::scoped_ptr<SessionDescriptionInterface> offer; |
| 1177 | EXPECT_TRUE(DoCreateOffer(offer.use())); |
| 1178 | talk_base::scoped_ptr<SessionDescriptionInterface> answer; |
| 1179 | EXPECT_TRUE(DoCreateAnswer(answer.use())); |
| 1180 | |
| 1181 | std::string sdp; |
| 1182 | ASSERT_TRUE(pc_->remote_description()->ToString(&sdp)); |
| 1183 | SessionDescriptionInterface* remote_offer = |
| 1184 | webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 1185 | sdp, NULL); |
| 1186 | EXPECT_FALSE(DoSetRemoteDescription(remote_offer)); |
| 1187 | |
| 1188 | ASSERT_TRUE(pc_->local_description()->ToString(&sdp)); |
| 1189 | SessionDescriptionInterface* local_offer = |
| 1190 | webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 1191 | sdp, NULL); |
| 1192 | EXPECT_FALSE(DoSetLocalDescription(local_offer)); |
| 1193 | } |
| 1194 | |
| 1195 | // Test that GetStats can still be called after PeerConnection::Close. |
| 1196 | TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) { |
| 1197 | InitiateCall(); |
| 1198 | pc_->Close(); |
| 1199 | DoGetStats(NULL); |
| 1200 | } |