| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * libjingle | 2  * libjingle | 
| 3  * Copyright 2012 Google Inc. | 3  * Copyright 2012 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, | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 26  */ | 26  */ | 
| 27 | 27 | 
| 28 #include <string> | 28 #include <string> | 
| 29 | 29 | 
| 30 #include "talk/app/webrtc/fakeportallocatorfactory.h" | 30 #include "talk/app/webrtc/fakeportallocatorfactory.h" | 
| 31 #include "talk/app/webrtc/jsepsessiondescription.h" | 31 #include "talk/app/webrtc/jsepsessiondescription.h" | 
| 32 #include "talk/app/webrtc/mediastreaminterface.h" | 32 #include "talk/app/webrtc/mediastreaminterface.h" | 
| 33 #include "talk/app/webrtc/peerconnectioninterface.h" | 33 #include "talk/app/webrtc/peerconnectioninterface.h" | 
| 34 #include "talk/app/webrtc/test/fakeconstraints.h" | 34 #include "talk/app/webrtc/test/fakeconstraints.h" | 
| 35 #include "talk/app/webrtc/test/fakedtlsidentityservice.h" | 35 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" | 
| 36 #include "talk/app/webrtc/test/mockpeerconnectionobservers.h" | 36 #include "talk/app/webrtc/test/mockpeerconnectionobservers.h" | 
| 37 #include "talk/app/webrtc/test/testsdpstrings.h" | 37 #include "talk/app/webrtc/test/testsdpstrings.h" | 
| 38 #include "talk/app/webrtc/videosource.h" | 38 #include "talk/app/webrtc/videosource.h" | 
| 39 #include "talk/media/base/fakevideocapturer.h" | 39 #include "talk/media/base/fakevideocapturer.h" | 
| 40 #include "talk/media/sctp/sctpdataengine.h" | 40 #include "talk/media/sctp/sctpdataengine.h" | 
| 41 #include "talk/session/media/mediasession.h" | 41 #include "talk/session/media/mediasession.h" | 
| 42 #include "webrtc/base/gunit.h" | 42 #include "webrtc/base/gunit.h" | 
| 43 #include "webrtc/base/scoped_ptr.h" | 43 #include "webrtc/base/scoped_ptr.h" | 
| 44 #include "webrtc/base/ssladapter.h" | 44 #include "webrtc/base/ssladapter.h" | 
| 45 #include "webrtc/base/sslstreamadapter.h" | 45 #include "webrtc/base/sslstreamadapter.h" | 
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 257     // tests in this file. We only create a FakeIdentityService if the test | 257     // tests in this file. We only create a FakeIdentityService if the test | 
| 258     // explicitly sets the constraint. | 258     // explicitly sets the constraint. | 
| 259     FakeConstraints default_constraints; | 259     FakeConstraints default_constraints; | 
| 260     if (!constraints) { | 260     if (!constraints) { | 
| 261       constraints = &default_constraints; | 261       constraints = &default_constraints; | 
| 262 | 262 | 
| 263       default_constraints.AddMandatory( | 263       default_constraints.AddMandatory( | 
| 264           webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); | 264           webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); | 
| 265     } | 265     } | 
| 266 | 266 | 
| 267     FakeIdentityService* dtls_service = NULL; | 267     dtls_identity_store_.reset(nullptr); | 
| 268     bool dtls; | 268     bool dtls; | 
| 269     if (FindConstraint(constraints, | 269     if (FindConstraint(constraints, | 
| 270                        webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 270                        webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 
| 271                        &dtls, | 271                        &dtls, | 
| 272                        NULL) && dtls) { | 272                        nullptr) && dtls) { | 
| 273       dtls_service = new FakeIdentityService(); | 273       dtls_identity_store_.reset(new FakeDtlsIdentityStore()); | 
| 274     } | 274     } | 
| 275     pc_ = pc_factory_->CreatePeerConnection(servers, constraints, | 275     pc_ = pc_factory_->CreatePeerConnection(servers, constraints, | 
| 276                                             port_allocator_factory_.get(), | 276                                             port_allocator_factory_.get(), | 
| 277                                             dtls_service, | 277                                             dtls_identity_store_.get(), | 
| 278                                             &observer_); | 278                                             &observer_); | 
| 279     ASSERT_TRUE(pc_.get() != NULL); | 279     ASSERT_TRUE(pc_.get() != NULL); | 
| 280     observer_.SetPeerConnectionInterface(pc_.get()); | 280     observer_.SetPeerConnectionInterface(pc_.get()); | 
| 281     EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); | 281     EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); | 
| 282   } | 282   } | 
| 283 | 283 | 
| 284   void CreatePeerConnectionWithDifferentConfigurations() { | 284   void CreatePeerConnectionWithDifferentConfigurations() { | 
| 285     CreatePeerConnection(kStunAddressOnly, "", NULL); | 285     CreatePeerConnection(kStunAddressOnly, "", NULL); | 
| 286     EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size()); | 286     EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size()); | 
| 287     EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); | 287     EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); | 
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 554     std::string sdp; | 554     std::string sdp; | 
| 555     EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); | 555     EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); | 
| 556     SetSsrcToZero(&sdp); | 556     SetSsrcToZero(&sdp); | 
| 557     CreateAnswerAsRemoteDescription(sdp); | 557     CreateAnswerAsRemoteDescription(sdp); | 
| 558   } | 558   } | 
| 559 | 559 | 
| 560   scoped_refptr<FakePortAllocatorFactory> port_allocator_factory_; | 560   scoped_refptr<FakePortAllocatorFactory> port_allocator_factory_; | 
| 561   scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; | 561   scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; | 
| 562   scoped_refptr<PeerConnectionInterface> pc_; | 562   scoped_refptr<PeerConnectionInterface> pc_; | 
| 563   MockPeerConnectionObserver observer_; | 563   MockPeerConnectionObserver observer_; | 
|  | 564   scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store_; | 
| 564 }; | 565 }; | 
| 565 | 566 | 
| 566 TEST_F(PeerConnectionInterfaceTest, | 567 TEST_F(PeerConnectionInterfaceTest, | 
| 567        CreatePeerConnectionWithDifferentConfigurations) { | 568        CreatePeerConnectionWithDifferentConfigurations) { | 
| 568   CreatePeerConnectionWithDifferentConfigurations(); | 569   CreatePeerConnectionWithDifferentConfigurations(); | 
| 569 } | 570 } | 
| 570 | 571 | 
| 571 TEST_F(PeerConnectionInterfaceTest, AddStreams) { | 572 TEST_F(PeerConnectionInterfaceTest, AddStreams) { | 
| 572   CreatePeerConnection(); | 573   CreatePeerConnection(); | 
| 573   AddStream(kStreamLabel1); | 574   AddStream(kStreamLabel1); | 
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1217                                          sdp, NULL); | 1218                                          sdp, NULL); | 
| 1218   EXPECT_FALSE(DoSetLocalDescription(local_offer)); | 1219   EXPECT_FALSE(DoSetLocalDescription(local_offer)); | 
| 1219 } | 1220 } | 
| 1220 | 1221 | 
| 1221 // Test that GetStats can still be called after PeerConnection::Close. | 1222 // Test that GetStats can still be called after PeerConnection::Close. | 
| 1222 TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) { | 1223 TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) { | 
| 1223   InitiateCall(); | 1224   InitiateCall(); | 
| 1224   pc_->Close(); | 1225   pc_->Close(); | 
| 1225   DoGetStats(NULL); | 1226   DoGetStats(NULL); | 
| 1226 } | 1227 } | 
| OLD | NEW | 
|---|