OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/jingle_session.h" | 5 #include "remoting/protocol/jingle_session.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "jingle/glue/thread_wrapper.h" | 12 #include "jingle/glue/thread_wrapper.h" |
13 #include "net/socket/socket.h" | 13 #include "net/socket/socket.h" |
14 #include "net/socket/stream_socket.h" | 14 #include "net/socket/stream_socket.h" |
15 #include "net/url_request/url_request_context_getter.h" | 15 #include "net/url_request/url_request_context_getter.h" |
16 #include "remoting/base/constants.h" | 16 #include "remoting/base/constants.h" |
17 #include "remoting/protocol/authenticator.h" | 17 #include "remoting/protocol/authenticator.h" |
18 #include "remoting/protocol/channel_authenticator.h" | 18 #include "remoting/protocol/channel_authenticator.h" |
19 #include "remoting/protocol/chromium_port_allocator.h" | 19 #include "remoting/protocol/chromium_port_allocator.h" |
20 #include "remoting/protocol/connection_tester.h" | 20 #include "remoting/protocol/connection_tester.h" |
21 #include "remoting/protocol/fake_authenticator.h" | 21 #include "remoting/protocol/fake_authenticator.h" |
22 #include "remoting/protocol/jingle_session_manager.h" | 22 #include "remoting/protocol/jingle_session_manager.h" |
23 #include "remoting/protocol/libjingle_transport_factory.h" | 23 #include "remoting/protocol/libjingle_transport_factory.h" |
24 #include "remoting/protocol/network_settings.h" | 24 #include "remoting/protocol/network_settings.h" |
| 25 #include "remoting/protocol/stream_channel_factory.h" |
25 #include "remoting/signaling/fake_signal_strategy.h" | 26 #include "remoting/signaling/fake_signal_strategy.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
28 | 29 |
29 using testing::_; | 30 using testing::_; |
30 using testing::AtLeast; | 31 using testing::AtLeast; |
31 using testing::AtMost; | 32 using testing::AtMost; |
32 using testing::DeleteArg; | 33 using testing::DeleteArg; |
33 using testing::DoAll; | 34 using testing::DoAll; |
34 using testing::InSequence; | 35 using testing::InSequence; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 133 } |
133 | 134 |
134 void CloseSessions() { | 135 void CloseSessions() { |
135 host_socket_.reset(); | 136 host_socket_.reset(); |
136 host_session_.reset(); | 137 host_session_.reset(); |
137 client_socket_.reset(); | 138 client_socket_.reset(); |
138 client_session_.reset(); | 139 client_session_.reset(); |
139 } | 140 } |
140 | 141 |
141 void CreateSessionManagers(int auth_round_trips, int messages_till_start, | 142 void CreateSessionManagers(int auth_round_trips, int messages_till_start, |
142 FakeAuthenticator::Action auth_action) { | 143 FakeAuthenticator::Action auth_action) { |
143 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); | 144 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); |
144 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); | 145 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); |
145 FakeSignalStrategy::Connect(host_signal_strategy_.get(), | 146 FakeSignalStrategy::Connect(host_signal_strategy_.get(), |
146 client_signal_strategy_.get()); | 147 client_signal_strategy_.get()); |
147 | 148 |
148 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) | 149 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) |
149 .Times(1); | 150 .Times(1); |
150 | 151 |
151 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING); | 152 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING); |
152 | 153 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, | 504 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, |
504 base::Unretained(this))); | 505 base::Unretained(this))); |
505 host_session_->GetTransportChannelFactory()->CreateChannel( | 506 host_session_->GetTransportChannelFactory()->CreateChannel( |
506 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, | 507 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, |
507 base::Unretained(this))); | 508 base::Unretained(this))); |
508 | 509 |
509 // Terminate the message loop when we get rejection notification | 510 // Terminate the message loop when we get rejection notification |
510 // from the host. | 511 // from the host. |
511 EXPECT_CALL(host_channel_callback_, OnDone(NULL)) | 512 EXPECT_CALL(host_channel_callback_, OnDone(NULL)) |
512 .WillOnce(QuitThread()); | 513 .WillOnce(QuitThread()); |
513 EXPECT_CALL(client_channel_callback_, OnDone(_)) | |
514 .Times(AtMost(1)); | |
515 ExpectRouteChange(kChannelName); | 514 ExpectRouteChange(kChannelName); |
516 | 515 |
517 message_loop_->Run(); | 516 message_loop_->Run(); |
518 | 517 |
| 518 client_session_->GetTransportChannelFactory()->CancelChannelCreation( |
| 519 kChannelName); |
| 520 |
519 EXPECT_TRUE(!host_socket_.get()); | 521 EXPECT_TRUE(!host_socket_.get()); |
520 } | 522 } |
521 | 523 |
522 } // namespace protocol | 524 } // namespace protocol |
523 } // namespace remoting | 525 } // namespace remoting |
OLD | NEW |