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" | |
26 #include "remoting/signaling/fake_signal_strategy.h" | 25 #include "remoting/signaling/fake_signal_strategy.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
29 | 28 |
30 using testing::_; | 29 using testing::_; |
31 using testing::AtLeast; | 30 using testing::AtLeast; |
32 using testing::AtMost; | 31 using testing::AtMost; |
33 using testing::DeleteArg; | 32 using testing::DeleteArg; |
34 using testing::DoAll; | 33 using testing::DoAll; |
35 using testing::InSequence; | 34 using testing::InSequence; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 132 } |
134 | 133 |
135 void CloseSessions() { | 134 void CloseSessions() { |
136 host_socket_.reset(); | 135 host_socket_.reset(); |
137 host_session_.reset(); | 136 host_session_.reset(); |
138 client_socket_.reset(); | 137 client_socket_.reset(); |
139 client_session_.reset(); | 138 client_session_.reset(); |
140 } | 139 } |
141 | 140 |
142 void CreateSessionManagers(int auth_round_trips, int messages_till_start, | 141 void CreateSessionManagers(int auth_round_trips, int messages_till_start, |
143 FakeAuthenticator::Action auth_action) { | 142 FakeAuthenticator::Action auth_action) { |
144 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); | 143 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); |
145 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); | 144 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); |
146 FakeSignalStrategy::Connect(host_signal_strategy_.get(), | 145 FakeSignalStrategy::Connect(host_signal_strategy_.get(), |
147 client_signal_strategy_.get()); | 146 client_signal_strategy_.get()); |
148 | 147 |
149 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) | 148 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) |
150 .Times(1); | 149 .Times(1); |
151 | 150 |
152 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING); | 151 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING); |
153 | 152 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, | 503 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, |
505 base::Unretained(this))); | 504 base::Unretained(this))); |
506 host_session_->GetTransportChannelFactory()->CreateChannel( | 505 host_session_->GetTransportChannelFactory()->CreateChannel( |
507 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, | 506 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, |
508 base::Unretained(this))); | 507 base::Unretained(this))); |
509 | 508 |
510 // Terminate the message loop when we get rejection notification | 509 // Terminate the message loop when we get rejection notification |
511 // from the host. | 510 // from the host. |
512 EXPECT_CALL(host_channel_callback_, OnDone(NULL)) | 511 EXPECT_CALL(host_channel_callback_, OnDone(NULL)) |
513 .WillOnce(QuitThread()); | 512 .WillOnce(QuitThread()); |
| 513 EXPECT_CALL(client_channel_callback_, OnDone(_)) |
| 514 .Times(AtMost(1)); |
514 ExpectRouteChange(kChannelName); | 515 ExpectRouteChange(kChannelName); |
515 | 516 |
516 message_loop_->Run(); | 517 message_loop_->Run(); |
517 | 518 |
518 client_session_->GetTransportChannelFactory()->CancelChannelCreation( | |
519 kChannelName); | |
520 | |
521 EXPECT_TRUE(!host_socket_.get()); | 519 EXPECT_TRUE(!host_socket_.get()); |
522 } | 520 } |
523 | 521 |
524 } // namespace protocol | 522 } // namespace protocol |
525 } // namespace remoting | 523 } // namespace remoting |
OLD | NEW |