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

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

Issue 2606123002: Remove the dependency of TransportChannel and TransportChannelImpl. (Closed)
Patch Set: Fix the memory leak. 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
« no previous file with comments | « webrtc/p2p/base/jseptransport.cc ('k') | webrtc/p2p/base/packettransportinterface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/faketransportcontroller.h"
17 17
18 using cricket::JsepTransport; 18 using cricket::JsepTransport;
19 using cricket::TransportChannel; 19 using cricket::TransportChannel;
20 using cricket::FakeTransportChannel; 20 using cricket::FakeDtlsTransport;
21 using cricket::FakeIceTransport;
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 FakeIceTransport(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<FakeIceTransport> 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 30 matching lines...) Expand all
105 ice_restart_local_desc, cricket::CA_OFFER, nullptr)); 106 ice_restart_local_desc, cricket::CA_OFFER, nullptr));
106 ASSERT_TRUE(transport_->SetRemoteTransportDescription( 107 ASSERT_TRUE(transport_->SetRemoteTransportDescription(
107 ice_restart_remote_desc, cricket::CA_ANSWER, nullptr)); 108 ice_restart_remote_desc, cricket::CA_ANSWER, nullptr));
108 EXPECT_FALSE(transport_->NeedsIceRestart()); 109 EXPECT_FALSE(transport_->NeedsIceRestart());
109 } 110 }
110 111
111 TEST_F(JsepTransportTest, TestGetStats) { 112 TEST_F(JsepTransportTest, TestGetStats) {
112 EXPECT_TRUE(SetupChannel()); 113 EXPECT_TRUE(SetupChannel());
113 cricket::TransportStats stats; 114 cricket::TransportStats stats;
114 EXPECT_TRUE(transport_->GetStats(&stats)); 115 EXPECT_TRUE(transport_->GetStats(&stats));
115 // Note that this tests the behavior of a FakeTransportChannel. 116 // Note that this tests the behavior of a FakeIceTransport.
116 ASSERT_EQ(1U, stats.channel_stats.size()); 117 ASSERT_EQ(1U, stats.channel_stats.size());
117 EXPECT_EQ(1, stats.channel_stats[0].component); 118 EXPECT_EQ(1, stats.channel_stats[0].component);
118 // Set local transport description for FakeTransport before connecting. 119 // Set local transport description for FakeTransport before connecting.
119 TransportDescription faketransport_desc( 120 TransportDescription faketransport_desc(
120 std::vector<std::string>(), 121 std::vector<std::string>(),
121 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH), 122 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH),
122 rtc::CreateRandomString(cricket::ICE_PWD_LENGTH), cricket::ICEMODE_FULL, 123 rtc::CreateRandomString(cricket::ICE_PWD_LENGTH), cricket::ICEMODE_FULL,
123 cricket::CONNECTIONROLE_NONE, nullptr); 124 cricket::CONNECTIONROLE_NONE, nullptr);
124 transport_->SetLocalTransportDescription(faketransport_desc, 125 transport_->SetLocalTransportDescription(faketransport_desc,
125 cricket::CA_OFFER, nullptr); 126 cricket::CA_OFFER, nullptr);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/jseptransport.cc ('k') | webrtc/p2p/base/packettransportinterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698