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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "remoting/jingle_glue/mock_objects.h" | 8 #include "remoting/jingle_glue/mock_objects.h" |
9 #include "remoting/host/capturer_fake.h" | 9 #include "remoting/host/capturer_fake.h" |
10 #include "remoting/host/chromoting_host.h" | 10 #include "remoting/host/chromoting_host.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
64 class ChromotingHostTest : public testing::Test { | 64 class ChromotingHostTest : public testing::Test { |
65 public: | 65 public: |
66 ChromotingHostTest() { | 66 ChromotingHostTest() { |
67 } | 67 } |
68 | 68 |
69 virtual void SetUp() OVERRIDE { | 69 virtual void SetUp() OVERRIDE { |
70 message_loop_proxy_ = base::MessageLoopProxy::current(); | 70 message_loop_proxy_ = base::MessageLoopProxy::current(); |
71 ON_CALL(context_, main_message_loop()) | 71 |
72 .WillByDefault(Return(&message_loop_)); | 72 EXPECT_CALL(context_, ui_task_runner()) |
73 ON_CALL(context_, encode_message_loop()) | 73 .Times(AnyNumber()) |
74 .WillByDefault(Return(&message_loop_)); | 74 .WillRepeatedly(Return(message_loop_proxy_.get())); |
75 ON_CALL(context_, network_message_loop()) | 75 EXPECT_CALL(context_, capture_task_runner()) |
76 .WillByDefault(Return(message_loop_proxy_.get())); | 76 .Times(AnyNumber()) |
77 ON_CALL(context_, ui_message_loop()) | 77 .WillRepeatedly(Return(message_loop_proxy_.get())); |
78 .WillByDefault(Return(message_loop_proxy_.get())); | 78 EXPECT_CALL(context_, encode_task_runner()) |
79 EXPECT_CALL(context_, main_message_loop()) | 79 .Times(AnyNumber()) |
80 .Times(AnyNumber()); | 80 .WillRepeatedly(Return(message_loop_proxy_.get())); |
81 EXPECT_CALL(context_, encode_message_loop()) | 81 EXPECT_CALL(context_, network_task_runner()) |
82 .Times(AnyNumber()); | 82 .Times(AnyNumber()) |
83 EXPECT_CALL(context_, network_message_loop()) | 83 .WillRepeatedly(Return(message_loop_proxy_.get())); |
84 .Times(AnyNumber()); | |
85 EXPECT_CALL(context_, ui_message_loop()) | |
86 .Times(AnyNumber()); | |
87 | 84 |
88 scoped_ptr<Capturer> capturer(new CapturerFake()); | 85 scoped_ptr<Capturer> capturer(new CapturerFake()); |
89 event_executor_ = new MockEventExecutor(); | 86 event_executor_ = new MockEventExecutor(); |
90 desktop_environment_ = DesktopEnvironment::CreateFake( | 87 desktop_environment_ = DesktopEnvironment::CreateFake( |
91 &context_, | 88 &context_, |
92 capturer.Pass(), | 89 capturer.Pass(), |
93 scoped_ptr<EventExecutor>(event_executor_)); | 90 scoped_ptr<EventExecutor>(event_executor_)); |
94 session_manager_ = new protocol::MockSessionManager(); | 91 session_manager_ = new protocol::MockSessionManager(); |
95 | 92 |
96 host_ = new ChromotingHost( | 93 host_ = new ChromotingHost( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 bool reject) { | 197 bool reject) { |
201 scoped_ptr<protocol::ConnectionToClient> connection = | 198 scoped_ptr<protocol::ConnectionToClient> connection = |
202 ((connection_index == 0) ? owned_connection_ : owned_connection2_). | 199 ((connection_index == 0) ? owned_connection_ : owned_connection2_). |
203 PassAs<protocol::ConnectionToClient>(); | 200 PassAs<protocol::ConnectionToClient>(); |
204 protocol::ConnectionToClient* connection_ptr = connection.get(); | 201 protocol::ConnectionToClient* connection_ptr = connection.get(); |
205 ClientSession* client = new ClientSession( | 202 ClientSession* client = new ClientSession( |
206 host_.get(), connection.Pass(), desktop_environment_->event_executor(), | 203 host_.get(), connection.Pass(), desktop_environment_->event_executor(), |
207 desktop_environment_->capturer(), base::TimeDelta()); | 204 desktop_environment_->capturer(), base::TimeDelta()); |
208 connection_ptr->set_host_stub(client); | 205 connection_ptr->set_host_stub(client); |
209 | 206 |
210 context_.network_message_loop()->PostTask( | 207 context_.network_task_runner()->PostTask( |
211 FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost, | 208 FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost, |
212 host_, client)); | 209 host_, client)); |
213 | 210 |
214 if (authenticate) { | 211 if (authenticate) { |
215 context_.network_message_loop()->PostTask( | 212 context_.network_task_runner()->PostTask( |
216 FROM_HERE, base::Bind(&ClientSession::OnConnectionAuthenticated, | 213 FROM_HERE, base::Bind(&ClientSession::OnConnectionAuthenticated, |
217 base::Unretained(client), connection_ptr)); | 214 base::Unretained(client), connection_ptr)); |
218 if (!reject) { | 215 if (!reject) { |
219 context_.network_message_loop()->PostTask( | 216 context_.network_task_runner()->PostTask( |
220 FROM_HERE, | 217 FROM_HERE, |
221 base::Bind(&ClientSession::OnConnectionChannelsConnected, | 218 base::Bind(&ClientSession::OnConnectionChannelsConnected, |
222 base::Unretained(client), connection_ptr)); | 219 base::Unretained(client), connection_ptr)); |
223 } | 220 } |
224 } else { | 221 } else { |
225 context_.network_message_loop()->PostTask( | 222 context_.network_task_runner()->PostTask( |
226 FROM_HERE, base::Bind(&ClientSession::OnConnectionClosed, | 223 FROM_HERE, base::Bind(&ClientSession::OnConnectionClosed, |
227 base::Unretained(client), connection_ptr, | 224 base::Unretained(client), connection_ptr, |
228 protocol::AUTHENTICATION_FAILED)); | 225 protocol::AUTHENTICATION_FAILED)); |
229 } | 226 } |
230 | 227 |
231 if (connection_index == 0) { | 228 if (connection_index == 0) { |
232 client_ = client; | 229 client_ = client; |
233 } else { | 230 } else { |
234 client2_ = client; | 231 client2_ = client; |
235 } | 232 } |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 host_->OnIncomingSession(session_unowned_.release(), &response); | 638 host_->OnIncomingSession(session_unowned_.release(), &response); |
642 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); | 639 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); |
643 | 640 |
644 host_->OnIncomingSession(session2_unowned_.get(), &response); | 641 host_->OnIncomingSession(session2_unowned_.get(), &response); |
645 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response); | 642 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response); |
646 | 643 |
647 host_->Shutdown(base::Bind(&NullTask)); | 644 host_->Shutdown(base::Bind(&NullTask)); |
648 } | 645 } |
649 | 646 |
650 } // namespace remoting | 647 } // namespace remoting |
OLD | NEW |