OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/task.h" | 7 #include "base/task.h" |
8 #include "remoting/base/logger.h" | |
9 #include "remoting/host/capturer_fake.h" | 8 #include "remoting/host/capturer_fake.h" |
10 #include "remoting/host/chromoting_host.h" | 9 #include "remoting/host/chromoting_host.h" |
11 #include "remoting/host/chromoting_host_context.h" | 10 #include "remoting/host/chromoting_host_context.h" |
12 #include "remoting/host/host_mock_objects.h" | 11 #include "remoting/host/host_mock_objects.h" |
13 #include "remoting/host/in_memory_host_config.h" | 12 #include "remoting/host/in_memory_host_config.h" |
14 #include "remoting/proto/video.pb.h" | 13 #include "remoting/proto/video.pb.h" |
15 #include "remoting/protocol/protocol_mock_objects.h" | 14 #include "remoting/protocol/protocol_mock_objects.h" |
16 #include "remoting/protocol/session_config.h" | 15 #include "remoting/protocol/session_config.h" |
17 #include "testing/gmock_mutant.h" | 16 #include "testing/gmock_mutant.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 .WillByDefault(Return(&message_loop_)); | 79 .WillByDefault(Return(&message_loop_)); |
81 EXPECT_CALL(context_, main_message_loop()) | 80 EXPECT_CALL(context_, main_message_loop()) |
82 .Times(AnyNumber()); | 81 .Times(AnyNumber()); |
83 EXPECT_CALL(context_, encode_message_loop()) | 82 EXPECT_CALL(context_, encode_message_loop()) |
84 .Times(AnyNumber()); | 83 .Times(AnyNumber()); |
85 EXPECT_CALL(context_, network_message_loop()) | 84 EXPECT_CALL(context_, network_message_loop()) |
86 .Times(AnyNumber()); | 85 .Times(AnyNumber()); |
87 EXPECT_CALL(context_, ui_message_loop()) | 86 EXPECT_CALL(context_, ui_message_loop()) |
88 .Times(AnyNumber()); | 87 .Times(AnyNumber()); |
89 | 88 |
90 logger_.reset(new Logger()); | |
91 | |
92 context_.SetUITaskPostFunction(base::Bind( | 89 context_.SetUITaskPostFunction(base::Bind( |
93 static_cast<void(MessageLoop::*)( | 90 static_cast<void(MessageLoop::*)( |
94 const tracked_objects::Location&, Task*)>(&MessageLoop::PostTask), | 91 const tracked_objects::Location&, Task*)>(&MessageLoop::PostTask), |
95 base::Unretained(&message_loop_))); | 92 base::Unretained(&message_loop_))); |
96 | 93 |
97 Capturer* capturer = new CapturerFake(); | 94 Capturer* capturer = new CapturerFake(); |
98 event_executor_ = new MockEventExecutor(); | 95 event_executor_ = new MockEventExecutor(); |
99 curtain_ = new MockCurtain(); | 96 curtain_ = new MockCurtain(); |
100 disconnect_window_ = new MockDisconnectWindow(); | 97 disconnect_window_ = new MockDisconnectWindow(); |
101 continue_window_ = new MockContinueWindow(); | 98 continue_window_ = new MockContinueWindow(); |
102 local_input_monitor_ = new MockLocalInputMonitor(); | 99 local_input_monitor_ = new MockLocalInputMonitor(); |
103 DesktopEnvironment* desktop = | 100 DesktopEnvironment* desktop = |
104 new DesktopEnvironment(&context_, capturer, event_executor_, curtain_, | 101 new DesktopEnvironment(&context_, capturer, event_executor_, curtain_, |
105 disconnect_window_, continue_window_, | 102 disconnect_window_, continue_window_, |
106 local_input_monitor_); | 103 local_input_monitor_); |
107 MockAccessVerifier* access_verifier = new MockAccessVerifier(); | 104 MockAccessVerifier* access_verifier = new MockAccessVerifier(); |
108 | 105 |
109 host_ = ChromotingHost::Create(&context_, config_, | 106 host_ = ChromotingHost::Create(&context_, config_, |
110 desktop, access_verifier, logger_.get()); | 107 desktop, access_verifier); |
111 credentials_.set_type(protocol::PASSWORD); | 108 credentials_.set_type(protocol::PASSWORD); |
112 credentials_.set_username("user"); | 109 credentials_.set_username("user"); |
113 credentials_.set_credential("password"); | 110 credentials_.set_credential("password"); |
114 connection_ = new MockConnectionToClient( | 111 connection_ = new MockConnectionToClient( |
115 &message_loop_, &handler_, &host_stub_, event_executor_); | 112 &message_loop_, &handler_, &host_stub_, event_executor_); |
116 connection2_ = new MockConnectionToClient( | 113 connection2_ = new MockConnectionToClient( |
117 &message_loop_, &handler_, &host_stub2_, &event_executor2_); | 114 &message_loop_, &handler_, &host_stub2_, &event_executor2_); |
118 session_.reset(new MockSession()); | 115 session_.reset(new MockSession()); |
119 session2_.reset(new MockSession()); | 116 session2_.reset(new MockSession()); |
120 session_config_.reset(SessionConfig::CreateDefault()); | 117 session_config_.reset(SessionConfig::CreateDefault()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 scoped_refptr<ClientSession> session) { | 198 scoped_refptr<ClientSession> session) { |
202 host->clients_.push_back(session); | 199 host->clients_.push_back(session); |
203 } | 200 } |
204 | 201 |
205 void ShutdownHost() { | 202 void ShutdownHost() { |
206 host_->Shutdown( | 203 host_->Shutdown( |
207 NewRunnableFunction(&PostQuitTask, &message_loop_)); | 204 NewRunnableFunction(&PostQuitTask, &message_loop_)); |
208 } | 205 } |
209 | 206 |
210 protected: | 207 protected: |
211 scoped_ptr<Logger> logger_; | |
212 MessageLoop message_loop_; | 208 MessageLoop message_loop_; |
213 MockConnectionToClientEventHandler handler_; | 209 MockConnectionToClientEventHandler handler_; |
214 scoped_refptr<ChromotingHost> host_; | 210 scoped_refptr<ChromotingHost> host_; |
215 scoped_refptr<InMemoryHostConfig> config_; | 211 scoped_refptr<InMemoryHostConfig> config_; |
216 MockChromotingHostContext context_; | 212 MockChromotingHostContext context_; |
217 protocol::LocalLoginCredentials credentials_; | 213 protocol::LocalLoginCredentials credentials_; |
218 scoped_refptr<MockConnectionToClient> connection_; | 214 scoped_refptr<MockConnectionToClient> connection_; |
219 scoped_ptr<MockSession> session_; | 215 scoped_ptr<MockSession> session_; |
220 scoped_ptr<SessionConfig> session_config_; | 216 scoped_ptr<SessionConfig> session_config_; |
221 MockVideoStub video_stub_; | 217 MockVideoStub video_stub_; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 EXPECT_CALL(*connection_.get(), Disconnect()) | 487 EXPECT_CALL(*connection_.get(), Disconnect()) |
492 .InSequence(s1, s2) | 488 .InSequence(s1, s2) |
493 .RetiresOnSaturation(); | 489 .RetiresOnSaturation(); |
494 } | 490 } |
495 SimulateClientConnection(0, true); | 491 SimulateClientConnection(0, true); |
496 message_loop_.Run(); | 492 message_loop_.Run(); |
497 host_->set_it2me(false); | 493 host_->set_it2me(false); |
498 EXPECT_THAT(curtain_activated, false); | 494 EXPECT_THAT(curtain_activated, false); |
499 } | 495 } |
500 } // namespace remoting | 496 } // namespace remoting |
OLD | NEW |