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

Side by Side Diff: remoting/protocol/ice_transport_unittest.cc

Issue 1521883006: Add TransportContext class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/ice_transport.h" 5 #include "remoting/protocol/ice_transport.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
13 #include "jingle/glue/thread_wrapper.h" 13 #include "jingle/glue/thread_wrapper.h"
14 #include "net/url_request/url_request_context_getter.h" 14 #include "net/url_request/url_request_context_getter.h"
15 #include "remoting/protocol/chromium_port_allocator.h" 15 #include "remoting/protocol/chromium_port_allocator.h"
16 #include "remoting/protocol/connection_tester.h" 16 #include "remoting/protocol/connection_tester.h"
17 #include "remoting/protocol/fake_authenticator.h" 17 #include "remoting/protocol/fake_authenticator.h"
18 #include "remoting/protocol/p2p_stream_socket.h" 18 #include "remoting/protocol/p2p_stream_socket.h"
19 #include "remoting/protocol/stream_channel_factory.h" 19 #include "remoting/protocol/stream_channel_factory.h"
20 #include "remoting/protocol/transport_context.h"
20 #include "remoting/signaling/fake_signal_strategy.h" 21 #include "remoting/signaling/fake_signal_strategy.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 24 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
24 25
25 using testing::_; 26 using testing::_;
26 27
27 namespace remoting { 28 namespace remoting {
28 namespace protocol { 29 namespace protocol {
29 30
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 122 }
122 123
123 void DeliverTransportInfo(scoped_ptr<IceTransport>* target_transport, 124 void DeliverTransportInfo(scoped_ptr<IceTransport>* target_transport,
124 scoped_ptr<buzz::XmlElement> transport_info) { 125 scoped_ptr<buzz::XmlElement> transport_info) {
125 ASSERT_TRUE(target_transport); 126 ASSERT_TRUE(target_transport);
126 EXPECT_TRUE( 127 EXPECT_TRUE(
127 (*target_transport)->ProcessTransportInfo(transport_info.get())); 128 (*target_transport)->ProcessTransportInfo(transport_info.get()));
128 } 129 }
129 130
130 void InitializeConnection() { 131 void InitializeConnection() {
131 port_allocator_ = ChromiumPortAllocator::Create(nullptr, network_settings_); 132 host_transport_.reset(new IceTransport(new TransportContext(
132 133 signal_strategy_.get(),
133 host_transport_.reset(new IceTransport( 134 make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)),
134 port_allocator_.get(), network_settings_, TransportRole::SERVER)); 135 network_settings_, TransportRole::SERVER)));
135 host_transport_->GetCanStartClosure().Run();
136
137 if (!host_authenticator_) { 136 if (!host_authenticator_) {
138 host_authenticator_.reset(new FakeAuthenticator( 137 host_authenticator_.reset(new FakeAuthenticator(
139 FakeAuthenticator::HOST, 0, FakeAuthenticator::ACCEPT, true)); 138 FakeAuthenticator::HOST, 0, FakeAuthenticator::ACCEPT, true));
140 } 139 }
141 140
142 client_transport_.reset(new IceTransport( 141 client_transport_.reset(new IceTransport(new TransportContext(
143 port_allocator_.get(), network_settings_, TransportRole::CLIENT)); 142 signal_strategy_.get(),
144 client_transport_->GetCanStartClosure().Run(); 143 make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)),
144 network_settings_, TransportRole::CLIENT)));
145 if (!client_authenticator_) { 145 if (!client_authenticator_) {
146 client_authenticator_.reset(new FakeAuthenticator( 146 client_authenticator_.reset(new FakeAuthenticator(
147 FakeAuthenticator::CLIENT, 0, FakeAuthenticator::ACCEPT, true)); 147 FakeAuthenticator::CLIENT, 0, FakeAuthenticator::ACCEPT, true));
148 } 148 }
149 149
150 // Connect signaling between the two IceTransport objects. 150 // Connect signaling between the two IceTransport objects.
151 host_event_handler_.set_transport_info_callback( 151 host_event_handler_.set_transport_info_callback(
152 base::Bind(&IceTransportTest::ProcessTransportInfo, 152 base::Bind(&IceTransportTest::ProcessTransportInfo,
153 base::Unretained(this), &client_transport_)); 153 base::Unretained(this), &client_transport_));
154 client_event_handler_.set_transport_info_callback( 154 client_event_handler_.set_transport_info_callback(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 protected: 201 protected:
202 base::MessageLoopForIO message_loop_; 202 base::MessageLoopForIO message_loop_;
203 scoped_ptr<base::RunLoop> run_loop_; 203 scoped_ptr<base::RunLoop> run_loop_;
204 204
205 NetworkSettings network_settings_; 205 NetworkSettings network_settings_;
206 206
207 scoped_ptr<FakeSignalStrategy> signal_strategy_; 207 scoped_ptr<FakeSignalStrategy> signal_strategy_;
208 208
209 base::TimeDelta transport_info_delay_; 209 base::TimeDelta transport_info_delay_;
210 210
211 scoped_ptr<cricket::PortAllocator> port_allocator_;
212
213 // scoped_ptr<IceTransportFactory> host_transport_factory_;
214 scoped_ptr<IceTransport> host_transport_; 211 scoped_ptr<IceTransport> host_transport_;
215 TestTransportEventHandler host_event_handler_; 212 TestTransportEventHandler host_event_handler_;
216 scoped_ptr<FakeAuthenticator> host_authenticator_; 213 scoped_ptr<FakeAuthenticator> host_authenticator_;
217 214
218 // scoped_ptr<IceTransportFactory> client_transport_factory_;
219 scoped_ptr<IceTransport> client_transport_; 215 scoped_ptr<IceTransport> client_transport_;
220 TestTransportEventHandler client_event_handler_; 216 TestTransportEventHandler client_event_handler_;
221 scoped_ptr<FakeAuthenticator> client_authenticator_; 217 scoped_ptr<FakeAuthenticator> client_authenticator_;
222 218
223 MockChannelCreatedCallback client_channel_callback_; 219 MockChannelCreatedCallback client_channel_callback_;
224 MockChannelCreatedCallback host_channel_callback_; 220 MockChannelCreatedCallback host_channel_callback_;
225 221
226 scoped_ptr<P2PStreamSocket> client_socket_; 222 scoped_ptr<P2PStreamSocket> client_socket_;
227 scoped_ptr<P2PStreamSocket> host_socket_; 223 scoped_ptr<P2PStreamSocket> host_socket_;
228 224
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), 349 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
354 kMessageSize, kMessages); 350 kMessageSize, kMessages);
355 tester.Start(); 351 tester.Start();
356 message_loop_.Run(); 352 message_loop_.Run();
357 tester.CheckResults(); 353 tester.CheckResults();
358 } 354 }
359 355
360 356
361 } // namespace protocol 357 } // namespace protocol
362 } // namespace remoting 358 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/ice_transport_factory.cc ('k') | remoting/protocol/jingle_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698