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::AtMost; | 25 using testing::AtMost; |
27 using testing::DeleteArg; | 26 using testing::DeleteArg; |
28 using testing::DoAll; | 27 using testing::DoAll; |
29 using testing::InSequence; | 28 using testing::InSequence; |
30 using testing::Invoke; | 29 using testing::Invoke; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 class MockStreamChannelCallback { | 80 class MockStreamChannelCallback { |
82 public: | 81 public: |
83 MOCK_METHOD1(OnDone, void(net::StreamSocket* socket)); | 82 MOCK_METHOD1(OnDone, void(net::StreamSocket* socket)); |
84 }; | 83 }; |
85 | 84 |
86 } // namespace | 85 } // namespace |
87 | 86 |
88 class JingleSessionTest : public testing::Test { | 87 class JingleSessionTest : public testing::Test { |
89 public: | 88 public: |
90 JingleSessionTest() { | 89 JingleSessionTest() { |
91 talk_base::ThreadManager::Instance()->WrapCurrentThread(); | 90 message_loop_.reset(new MessageLoopForIO()); |
92 message_loop_.reset( | |
93 new JingleThreadMessageLoop(talk_base::Thread::Current())); | |
94 } | 91 } |
95 | 92 |
96 // Helper method that handles OnIncomingSession(). | 93 // Helper method that handles OnIncomingSession(). |
97 void SetHostSession(Session* session) { | 94 void SetHostSession(Session* session) { |
98 DCHECK(session); | 95 DCHECK(session); |
99 host_session_.reset(session); | 96 host_session_.reset(session); |
100 host_session_->SetEventHandler(&host_session_event_handler_); | 97 host_session_->SetEventHandler(&host_session_event_handler_); |
101 | 98 |
102 session->set_config(SessionConfig::GetDefault()); | 99 session->set_config(SessionConfig::GetDefault()); |
103 } | 100 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 EXPECT_CALL(client_channel_callback_, OnDone(_)) | 236 EXPECT_CALL(client_channel_callback_, OnDone(_)) |
240 .WillOnce(QuitThreadOnCounter(&counter)); | 237 .WillOnce(QuitThreadOnCounter(&counter)); |
241 EXPECT_CALL(host_channel_callback_, OnDone(_)) | 238 EXPECT_CALL(host_channel_callback_, OnDone(_)) |
242 .WillOnce(QuitThreadOnCounter(&counter)); | 239 .WillOnce(QuitThreadOnCounter(&counter)); |
243 message_loop_->Run(); | 240 message_loop_->Run(); |
244 | 241 |
245 EXPECT_TRUE(client_socket_.get()); | 242 EXPECT_TRUE(client_socket_.get()); |
246 EXPECT_TRUE(host_socket_.get()); | 243 EXPECT_TRUE(host_socket_.get()); |
247 } | 244 } |
248 | 245 |
249 scoped_ptr<JingleThreadMessageLoop> message_loop_; | 246 scoped_ptr<MessageLoop> message_loop_; |
250 | 247 |
251 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; | 248 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; |
252 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; | 249 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; |
253 | 250 |
254 scoped_ptr<JingleSessionManager> host_server_; | 251 scoped_ptr<JingleSessionManager> host_server_; |
255 MockSessionManagerListener host_server_listener_; | 252 MockSessionManagerListener host_server_listener_; |
256 scoped_ptr<JingleSessionManager> client_server_; | 253 scoped_ptr<JingleSessionManager> client_server_; |
257 MockSessionManagerListener client_server_listener_; | 254 MockSessionManagerListener client_server_listener_; |
258 | 255 |
259 scoped_ptr<Session> host_session_; | 256 scoped_ptr<Session> host_session_; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 EXPECT_CALL(client_channel_callback_, OnDone(_)) | 379 EXPECT_CALL(client_channel_callback_, OnDone(_)) |
383 .Times(AtMost(1)); | 380 .Times(AtMost(1)); |
384 | 381 |
385 message_loop_->Run(); | 382 message_loop_->Run(); |
386 | 383 |
387 EXPECT_TRUE(!host_socket_.get()); | 384 EXPECT_TRUE(!host_socket_.get()); |
388 } | 385 } |
389 | 386 |
390 } // namespace protocol | 387 } // namespace protocol |
391 } // namespace remoting | 388 } // namespace remoting |
OLD | NEW |