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.h" | 8 #include "base/message_loop.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
11 #include "net/socket/socket.h" | 11 #include "net/socket/socket.h" |
12 #include "net/socket/stream_socket.h" | 12 #include "net/socket/stream_socket.h" |
13 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
14 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
15 #include "remoting/protocol/channel_authenticator.h" | 15 #include "remoting/protocol/channel_authenticator.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/jingle_session_manager.h" | 18 #include "remoting/protocol/jingle_session_manager.h" |
19 #include "remoting/protocol/libjingle_transport_factory.h" | 19 #include "remoting/protocol/libjingle_transport_factory.h" |
20 #include "remoting/jingle_glue/jingle_thread.h" | |
21 #include "remoting/jingle_glue/fake_signal_strategy.h" | 20 #include "remoting/jingle_glue/fake_signal_strategy.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
24 | 23 |
25 using testing::_; | 24 using testing::_; |
26 using testing::AtLeast; | 25 using testing::AtLeast; |
27 using testing::AtMost; | 26 using testing::AtMost; |
28 using testing::DeleteArg; | 27 using testing::DeleteArg; |
29 using testing::DoAll; | 28 using testing::DoAll; |
30 using testing::InSequence; | 29 using testing::InSequence; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 class MockStreamChannelCallback { | 81 class MockStreamChannelCallback { |
83 public: | 82 public: |
84 MOCK_METHOD1(OnDone, void(net::StreamSocket* socket)); | 83 MOCK_METHOD1(OnDone, void(net::StreamSocket* socket)); |
85 }; | 84 }; |
86 | 85 |
87 } // namespace | 86 } // namespace |
88 | 87 |
89 class JingleSessionTest : public testing::Test { | 88 class JingleSessionTest : public testing::Test { |
90 public: | 89 public: |
91 JingleSessionTest() { | 90 JingleSessionTest() { |
92 talk_base::ThreadManager::Instance()->WrapCurrentThread(); | 91 message_loop_.reset(new MessageLoopForIO()); |
93 message_loop_.reset( | |
94 new JingleThreadMessageLoop(talk_base::Thread::Current())); | |
95 } | 92 } |
96 | 93 |
97 // Helper method that handles OnIncomingSession(). | 94 // Helper method that handles OnIncomingSession(). |
98 void SetHostSession(Session* session) { | 95 void SetHostSession(Session* session) { |
99 DCHECK(session); | 96 DCHECK(session); |
100 host_session_.reset(session); | 97 host_session_.reset(session); |
101 host_session_->SetEventHandler(&host_session_event_handler_); | 98 host_session_->SetEventHandler(&host_session_event_handler_); |
102 | 99 |
103 session->set_config(SessionConfig::GetDefault()); | 100 session->set_config(SessionConfig::GetDefault()); |
104 } | 101 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 247 |
251 void ExpectRouteChange() { | 248 void ExpectRouteChange() { |
252 EXPECT_CALL(host_session_event_handler_, | 249 EXPECT_CALL(host_session_event_handler_, |
253 OnSessionRouteChange(kChannelName, _)) | 250 OnSessionRouteChange(kChannelName, _)) |
254 .Times(AtLeast(1)); | 251 .Times(AtLeast(1)); |
255 EXPECT_CALL(client_session_event_handler_, | 252 EXPECT_CALL(client_session_event_handler_, |
256 OnSessionRouteChange(kChannelName, _)) | 253 OnSessionRouteChange(kChannelName, _)) |
257 .Times(AtLeast(1)); | 254 .Times(AtLeast(1)); |
258 } | 255 } |
259 | 256 |
260 scoped_ptr<JingleThreadMessageLoop> message_loop_; | 257 scoped_ptr<MessageLoopForIO> message_loop_; |
261 | 258 |
262 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; | 259 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; |
263 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; | 260 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; |
264 | 261 |
265 scoped_ptr<JingleSessionManager> host_server_; | 262 scoped_ptr<JingleSessionManager> host_server_; |
266 MockSessionManagerListener host_server_listener_; | 263 MockSessionManagerListener host_server_listener_; |
267 scoped_ptr<JingleSessionManager> client_server_; | 264 scoped_ptr<JingleSessionManager> client_server_; |
268 MockSessionManagerListener client_server_listener_; | 265 MockSessionManagerListener client_server_listener_; |
269 | 266 |
270 scoped_ptr<Session> host_session_; | 267 scoped_ptr<Session> host_session_; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 .Times(AtMost(1)); | 391 .Times(AtMost(1)); |
395 ExpectRouteChange(); | 392 ExpectRouteChange(); |
396 | 393 |
397 message_loop_->Run(); | 394 message_loop_->Run(); |
398 | 395 |
399 EXPECT_TRUE(!host_socket_.get()); | 396 EXPECT_TRUE(!host_socket_.get()); |
400 } | 397 } |
401 | 398 |
402 } // namespace protocol | 399 } // namespace protocol |
403 } // namespace remoting | 400 } // namespace remoting |
OLD | NEW |