| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 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 <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "webrtc/base/fakesslidentity.h" | 13 #include "webrtc/base/fakesslidentity.h" |
| 14 #include "webrtc/base/gunit.h" | 14 #include "webrtc/base/gunit.h" |
| 15 #include "webrtc/base/network.h" | 15 #include "webrtc/base/network.h" |
| 16 #include "webrtc/p2p/base/faketransportcontroller.h" | 16 #include "webrtc/p2p/base/faketransportcontroller.h" |
| 17 | 17 |
| 18 using cricket::JsepTransport; | 18 using cricket::JsepTransport; |
| 19 using cricket::TransportChannel; | 19 using cricket::TransportChannel; |
| 20 using cricket::FakeDtlsTransport; |
| 20 using cricket::FakeTransportChannel; | 21 using cricket::FakeTransportChannel; |
| 21 using cricket::IceRole; | 22 using cricket::IceRole; |
| 22 using cricket::TransportDescription; | 23 using cricket::TransportDescription; |
| 23 using rtc::SocketAddress; | 24 using rtc::SocketAddress; |
| 24 | 25 |
| 25 static const char kIceUfrag1[] = "TESTICEUFRAG0001"; | 26 static const char kIceUfrag1[] = "TESTICEUFRAG0001"; |
| 26 static const char kIcePwd1[] = "TESTICEPWD00000000000001"; | 27 static const char kIcePwd1[] = "TESTICEPWD00000000000001"; |
| 27 | 28 |
| 28 static const char kIceUfrag2[] = "TESTICEUFRAG0002"; | 29 static const char kIceUfrag2[] = "TESTICEUFRAG0002"; |
| 29 static const char kIcePwd2[] = "TESTICEPWD00000000000002"; | 30 static const char kIcePwd2[] = "TESTICEPWD00000000000002"; |
| 30 | 31 |
| 31 class JsepTransportTest : public testing::Test, public sigslot::has_slots<> { | 32 class JsepTransportTest : public testing::Test, public sigslot::has_slots<> { |
| 32 public: | 33 public: |
| 33 JsepTransportTest() | 34 JsepTransportTest() |
| 34 : transport_(new JsepTransport("test content name", nullptr)) {} | 35 : transport_(new JsepTransport("test content name", nullptr)) {} |
| 35 bool SetupChannel() { | 36 bool SetupChannel() { |
| 36 fake_ice_channel_.reset(new FakeTransportChannel(transport_->mid(), 1)); | 37 fake_ice_channel_.reset(new FakeTransportChannel(transport_->mid(), 1)); |
| 37 fake_dtls_channel_.reset(new FakeTransportChannel(transport_->mid(), 1)); | 38 fake_dtls_transport_.reset(new FakeDtlsTransport(fake_ice_channel_.get())); |
| 38 return transport_->AddChannel(fake_dtls_channel_.get(), 1); | 39 return transport_->AddChannel(fake_dtls_transport_.get(), 1); |
| 39 } | 40 } |
| 40 void DestroyChannel() { transport_->RemoveChannel(1); } | 41 void DestroyChannel() { transport_->RemoveChannel(1); } |
| 41 | 42 |
| 42 protected: | 43 protected: |
| 43 std::unique_ptr<FakeTransportChannel> fake_dtls_channel_; | 44 std::unique_ptr<FakeDtlsTransport> fake_dtls_transport_; |
| 44 std::unique_ptr<FakeTransportChannel> fake_ice_channel_; | 45 std::unique_ptr<FakeTransportChannel> fake_ice_channel_; |
| 45 std::unique_ptr<JsepTransport> transport_; | 46 std::unique_ptr<JsepTransport> transport_; |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 // This test verifies channels are created with proper ICE | 49 // This test verifies channels are created with proper ICE |
| 49 // ufrag/password after a transport description is applied. | 50 // ufrag/password after a transport description is applied. |
| 50 TEST_F(JsepTransportTest, TestChannelIceParameters) { | 51 TEST_F(JsepTransportTest, TestChannelIceParameters) { |
| 51 cricket::TransportDescription local_desc(kIceUfrag1, kIcePwd1); | 52 cricket::TransportDescription local_desc(kIceUfrag1, kIcePwd1); |
| 52 ASSERT_TRUE(transport_->SetLocalTransportDescription( | 53 ASSERT_TRUE(transport_->SetLocalTransportDescription( |
| 53 local_desc, cricket::CA_OFFER, NULL)); | 54 local_desc, cricket::CA_OFFER, NULL)); |
| 54 EXPECT_TRUE(SetupChannel()); | 55 EXPECT_TRUE(SetupChannel()); |
| 55 EXPECT_EQ(cricket::ICEMODE_FULL, fake_dtls_channel_->remote_ice_mode()); | 56 EXPECT_EQ(cricket::ICEMODE_FULL, fake_dtls_transport_->remote_ice_mode()); |
| 56 EXPECT_EQ(kIceUfrag1, fake_dtls_channel_->ice_ufrag()); | 57 EXPECT_EQ(kIceUfrag1, fake_dtls_transport_->ice_ufrag()); |
| 57 EXPECT_EQ(kIcePwd1, fake_dtls_channel_->ice_pwd()); | 58 EXPECT_EQ(kIcePwd1, fake_dtls_transport_->ice_pwd()); |
| 58 | 59 |
| 59 cricket::TransportDescription remote_desc(kIceUfrag1, kIcePwd1); | 60 cricket::TransportDescription remote_desc(kIceUfrag1, kIcePwd1); |
| 60 ASSERT_TRUE(transport_->SetRemoteTransportDescription( | 61 ASSERT_TRUE(transport_->SetRemoteTransportDescription( |
| 61 remote_desc, cricket::CA_ANSWER, NULL)); | 62 remote_desc, cricket::CA_ANSWER, NULL)); |
| 62 EXPECT_EQ(cricket::ICEMODE_FULL, fake_dtls_channel_->remote_ice_mode()); | 63 EXPECT_EQ(cricket::ICEMODE_FULL, fake_dtls_transport_->remote_ice_mode()); |
| 63 EXPECT_EQ(kIceUfrag1, fake_dtls_channel_->remote_ice_ufrag()); | 64 EXPECT_EQ(kIceUfrag1, fake_dtls_transport_->remote_ice_ufrag()); |
| 64 EXPECT_EQ(kIcePwd1, fake_dtls_channel_->remote_ice_pwd()); | 65 EXPECT_EQ(kIcePwd1, fake_dtls_transport_->remote_ice_pwd()); |
| 65 } | 66 } |
| 66 | 67 |
| 67 // Verifies that IceCredentialsChanged returns true when either ufrag or pwd | 68 // Verifies that IceCredentialsChanged returns true when either ufrag or pwd |
| 68 // changed, and false in other cases. | 69 // changed, and false in other cases. |
| 69 TEST_F(JsepTransportTest, TestIceCredentialsChanged) { | 70 TEST_F(JsepTransportTest, TestIceCredentialsChanged) { |
| 70 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p2")); | 71 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p2")); |
| 71 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p1")); | 72 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p1")); |
| 72 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p2")); | 73 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p2")); |
| 73 EXPECT_FALSE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p1")); | 74 EXPECT_FALSE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p1")); |
| 74 } | 75 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 remote_desc.connection_role = param.remote_role; | 299 remote_desc.connection_role = param.remote_role; |
| 299 | 300 |
| 300 ASSERT_TRUE(transport_->SetRemoteTransportDescription( | 301 ASSERT_TRUE(transport_->SetRemoteTransportDescription( |
| 301 remote_desc, param.remote_action, nullptr)); | 302 remote_desc, param.remote_action, nullptr)); |
| 302 ASSERT_TRUE(transport_->SetLocalTransportDescription( | 303 ASSERT_TRUE(transport_->SetLocalTransportDescription( |
| 303 local_desc, param.local_action, nullptr)); | 304 local_desc, param.local_action, nullptr)); |
| 304 EXPECT_FALSE( | 305 EXPECT_FALSE( |
| 305 transport_->NegotiateRole(param.local_action, &ssl_role, &error_desc)); | 306 transport_->NegotiateRole(param.local_action, &ssl_role, &error_desc)); |
| 306 } | 307 } |
| 307 } | 308 } |
| OLD | NEW |