Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: webrtc/p2p/base/jseptransport_unittest.cc

Issue 2648233003: Adding ability for BaseChannel to use PacketTransportInterface. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/fakedtlstransport.h"
17 #include "webrtc/p2p/base/fakeicetransport.h"
17 18
18 using cricket::JsepTransport; 19 using cricket::JsepTransport;
19 using cricket::TransportChannel; 20 using cricket::TransportChannel;
20 using cricket::FakeDtlsTransport; 21 using cricket::FakeDtlsTransport;
21 using cricket::FakeIceTransport; 22 using cricket::FakeIceTransport;
22 using cricket::IceRole; 23 using cricket::IceRole;
23 using cricket::TransportDescription; 24 using cricket::TransportDescription;
24 using rtc::SocketAddress; 25 using rtc::SocketAddress;
25 26
26 static const char kIceUfrag1[] = "TESTICEUFRAG0001"; 27 static const char kIceUfrag1[] = "TESTICEUFRAG0001";
27 static const char kIcePwd1[] = "TESTICEPWD00000000000001"; 28 static const char kIcePwd1[] = "TESTICEPWD00000000000001";
28 29
29 static const char kIceUfrag2[] = "TESTICEUFRAG0002"; 30 static const char kIceUfrag2[] = "TESTICEUFRAG0002";
30 static const char kIcePwd2[] = "TESTICEPWD00000000000002"; 31 static const char kIcePwd2[] = "TESTICEPWD00000000000002";
31 32
32 class JsepTransportTest : public testing::Test, public sigslot::has_slots<> { 33 class JsepTransportTest : public testing::Test, public sigslot::has_slots<> {
33 public: 34 public:
34 JsepTransportTest() 35 JsepTransportTest()
35 : transport_(new JsepTransport("test content name", nullptr)) {} 36 : transport_(new JsepTransport("test content name", nullptr)) {}
36 bool SetupChannel() { 37 bool SetupChannel() {
37 fake_ice_channel_.reset(new FakeIceTransport(transport_->mid(), 1)); 38 fake_ice_transport_.reset(new FakeIceTransport(transport_->mid(), 1));
38 fake_dtls_transport_.reset(new FakeDtlsTransport(fake_ice_channel_.get())); 39 fake_dtls_transport_.reset(
40 new FakeDtlsTransport(fake_ice_transport_.get()));
39 return transport_->AddChannel(fake_dtls_transport_.get(), 1); 41 return transport_->AddChannel(fake_dtls_transport_.get(), 1);
40 } 42 }
41 void DestroyChannel() { transport_->RemoveChannel(1); } 43 void DestroyChannel() { transport_->RemoveChannel(1); }
42 44
43 protected: 45 protected:
44 std::unique_ptr<FakeDtlsTransport> fake_dtls_transport_; 46 std::unique_ptr<FakeDtlsTransport> fake_dtls_transport_;
45 std::unique_ptr<FakeIceTransport> fake_ice_channel_; 47 std::unique_ptr<FakeIceTransport> fake_ice_transport_;
46 std::unique_ptr<JsepTransport> transport_; 48 std::unique_ptr<JsepTransport> transport_;
47 }; 49 };
48 50
49 // This test verifies channels are created with proper ICE 51 // This test verifies channels are created with proper ICE
50 // ufrag/password after a transport description is applied. 52 // ufrag/password after a transport description is applied.
51 TEST_F(JsepTransportTest, TestChannelIceParameters) { 53 TEST_F(JsepTransportTest, TestChannelIceParameters) {
52 cricket::TransportDescription local_desc(kIceUfrag1, kIcePwd1); 54 cricket::TransportDescription local_desc(kIceUfrag1, kIcePwd1);
53 ASSERT_TRUE(transport_->SetLocalTransportDescription( 55 ASSERT_TRUE(transport_->SetLocalTransportDescription(
54 local_desc, cricket::CA_OFFER, NULL)); 56 local_desc, cricket::CA_OFFER, NULL));
55 EXPECT_TRUE(SetupChannel()); 57 EXPECT_TRUE(SetupChannel());
56 EXPECT_EQ(cricket::ICEMODE_FULL, fake_dtls_transport_->remote_ice_mode()); 58 EXPECT_EQ(cricket::ICEMODE_FULL, fake_ice_transport_->remote_ice_mode());
57 EXPECT_EQ(kIceUfrag1, fake_dtls_transport_->ice_ufrag()); 59 EXPECT_EQ(kIceUfrag1, fake_ice_transport_->ice_ufrag());
58 EXPECT_EQ(kIcePwd1, fake_dtls_transport_->ice_pwd()); 60 EXPECT_EQ(kIcePwd1, fake_ice_transport_->ice_pwd());
59 61
60 cricket::TransportDescription remote_desc(kIceUfrag1, kIcePwd1); 62 cricket::TransportDescription remote_desc(kIceUfrag1, kIcePwd1);
61 ASSERT_TRUE(transport_->SetRemoteTransportDescription( 63 ASSERT_TRUE(transport_->SetRemoteTransportDescription(
62 remote_desc, cricket::CA_ANSWER, NULL)); 64 remote_desc, cricket::CA_ANSWER, NULL));
63 EXPECT_EQ(cricket::ICEMODE_FULL, fake_dtls_transport_->remote_ice_mode()); 65 EXPECT_EQ(cricket::ICEMODE_FULL, fake_ice_transport_->remote_ice_mode());
64 EXPECT_EQ(kIceUfrag1, fake_dtls_transport_->remote_ice_ufrag()); 66 EXPECT_EQ(kIceUfrag1, fake_ice_transport_->remote_ice_ufrag());
65 EXPECT_EQ(kIcePwd1, fake_dtls_transport_->remote_ice_pwd()); 67 EXPECT_EQ(kIcePwd1, fake_ice_transport_->remote_ice_pwd());
66 } 68 }
67 69
68 // Verifies that IceCredentialsChanged returns true when either ufrag or pwd 70 // Verifies that IceCredentialsChanged returns true when either ufrag or pwd
69 // changed, and false in other cases. 71 // changed, and false in other cases.
70 TEST_F(JsepTransportTest, TestIceCredentialsChanged) { 72 TEST_F(JsepTransportTest, TestIceCredentialsChanged) {
71 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p2")); 73 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p2"));
72 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p1")); 74 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p1"));
73 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p2")); 75 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p2"));
74 EXPECT_FALSE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p1")); 76 EXPECT_FALSE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p1"));
75 } 77 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 remote_desc.connection_role = param.remote_role; 301 remote_desc.connection_role = param.remote_role;
300 302
301 ASSERT_TRUE(transport_->SetRemoteTransportDescription( 303 ASSERT_TRUE(transport_->SetRemoteTransportDescription(
302 remote_desc, param.remote_action, nullptr)); 304 remote_desc, param.remote_action, nullptr));
303 ASSERT_TRUE(transport_->SetLocalTransportDescription( 305 ASSERT_TRUE(transport_->SetLocalTransportDescription(
304 local_desc, param.local_action, nullptr)); 306 local_desc, param.local_action, nullptr));
305 EXPECT_FALSE( 307 EXPECT_FALSE(
306 transport_->NegotiateRole(param.local_action, &ssl_role, &error_desc)); 308 transport_->NegotiateRole(param.local_action, &ssl_role, &error_desc));
307 } 309 }
308 } 310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698