OLD | NEW |
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/webrtc_transport.h" | 5 #include "remoting/protocol/webrtc_transport.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "jingle/glue/thread_wrapper.h" | 9 #include "jingle/glue/thread_wrapper.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/url_request/url_request_context_getter.h" | 11 #include "net/url_request/url_request_context_getter.h" |
12 #include "remoting/protocol/chromium_port_allocator_factory.h" | |
13 #include "remoting/protocol/connection_tester.h" | 12 #include "remoting/protocol/connection_tester.h" |
14 #include "remoting/protocol/fake_authenticator.h" | 13 #include "remoting/protocol/fake_authenticator.h" |
15 #include "remoting/protocol/network_settings.h" | 14 #include "remoting/protocol/network_settings.h" |
16 #include "remoting/protocol/p2p_stream_socket.h" | 15 #include "remoting/protocol/p2p_stream_socket.h" |
17 #include "remoting/signaling/fake_signal_strategy.h" | 16 #include "remoting/signaling/fake_signal_strategy.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 18 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
20 | 19 |
21 namespace remoting { | 20 namespace remoting { |
22 namespace protocol { | 21 namespace protocol { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ASSERT_TRUE(target_transport); | 82 ASSERT_TRUE(target_transport); |
84 EXPECT_TRUE((*target_transport) | 83 EXPECT_TRUE((*target_transport) |
85 ->ProcessTransportInfo(transport_info.get())); | 84 ->ProcessTransportInfo(transport_info.get())); |
86 } | 85 } |
87 | 86 |
88 protected: | 87 protected: |
89 void InitializeConnection() { | 88 void InitializeConnection() { |
90 signal_strategy_.reset(new FakeSignalStrategy(kTestJid)); | 89 signal_strategy_.reset(new FakeSignalStrategy(kTestJid)); |
91 | 90 |
92 host_transport_factory_.reset(new WebrtcTransportFactory( | 91 host_transport_factory_.reset(new WebrtcTransportFactory( |
93 signal_strategy_.get(), | 92 signal_strategy_.get(), network_settings_, TransportRole::SERVER)); |
94 ChromiumPortAllocatorFactory::Create(network_settings_, nullptr), | |
95 TransportRole::SERVER)); | |
96 host_transport_ = host_transport_factory_->CreateTransport(); | 93 host_transport_ = host_transport_factory_->CreateTransport(); |
97 host_authenticator_.reset(new FakeAuthenticator( | 94 host_authenticator_.reset(new FakeAuthenticator( |
98 FakeAuthenticator::HOST, 0, FakeAuthenticator::ACCEPT, false)); | 95 FakeAuthenticator::HOST, 0, FakeAuthenticator::ACCEPT, false)); |
99 | 96 |
100 client_transport_factory_.reset(new WebrtcTransportFactory( | 97 client_transport_factory_.reset(new WebrtcTransportFactory( |
101 signal_strategy_.get(), | 98 signal_strategy_.get(), network_settings_, TransportRole::CLIENT)); |
102 ChromiumPortAllocatorFactory::Create(network_settings_, nullptr), | |
103 TransportRole::CLIENT)); | |
104 client_transport_ = client_transport_factory_->CreateTransport(); | 99 client_transport_ = client_transport_factory_->CreateTransport(); |
105 host_authenticator_.reset(new FakeAuthenticator( | 100 host_authenticator_.reset(new FakeAuthenticator( |
106 FakeAuthenticator::CLIENT, 0, FakeAuthenticator::ACCEPT, false)); | 101 FakeAuthenticator::CLIENT, 0, FakeAuthenticator::ACCEPT, false)); |
107 | 102 |
108 // Connect signaling between the two WebrtcTransport objects. | 103 // Connect signaling between the two WebrtcTransport objects. |
109 host_event_handler_.set_transport_info_callback( | 104 host_event_handler_.set_transport_info_callback( |
110 base::Bind(&WebrtcTransportTest::ProcessTransportInfo, | 105 base::Bind(&WebrtcTransportTest::ProcessTransportInfo, |
111 base::Unretained(this), &client_transport_)); | 106 base::Unretained(this), &client_transport_)); |
112 client_event_handler_.set_transport_info_callback( | 107 client_event_handler_.set_transport_info_callback( |
113 base::Bind(&WebrtcTransportTest::ProcessTransportInfo, | 108 base::Bind(&WebrtcTransportTest::ProcessTransportInfo, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 const int kMessages = 100; | 212 const int kMessages = 100; |
218 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | 213 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
219 kMessageSize, kMessages); | 214 kMessageSize, kMessages); |
220 tester.Start(); | 215 tester.Start(); |
221 message_loop_.Run(); | 216 message_loop_.Run(); |
222 tester.CheckResults(); | 217 tester.CheckResults(); |
223 } | 218 } |
224 | 219 |
225 } // namespace protocol | 220 } // namespace protocol |
226 } // namespace remoting | 221 } // namespace remoting |
OLD | NEW |