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/message_loop_proxy.h" |
7 #include "base/task.h" | 8 #include "base/task.h" |
8 #include "remoting/host/capturer_fake.h" | 9 #include "remoting/host/capturer_fake.h" |
9 #include "remoting/host/chromoting_host.h" | 10 #include "remoting/host/chromoting_host.h" |
10 #include "remoting/host/chromoting_host_context.h" | 11 #include "remoting/host/chromoting_host_context.h" |
11 #include "remoting/host/host_mock_objects.h" | 12 #include "remoting/host/host_mock_objects.h" |
12 #include "remoting/host/in_memory_host_config.h" | 13 #include "remoting/host/in_memory_host_config.h" |
13 #include "remoting/proto/video.pb.h" | 14 #include "remoting/proto/video.pb.h" |
14 #include "remoting/protocol/protocol_mock_objects.h" | 15 #include "remoting/protocol/protocol_mock_objects.h" |
15 #include "remoting/protocol/session_config.h" | 16 #include "remoting/protocol/session_config.h" |
16 #include "testing/gmock_mutant.h" | 17 #include "testing/gmock_mutant.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 62 } |
62 | 63 |
63 } // namespace | 64 } // namespace |
64 | 65 |
65 class ChromotingHostTest : public testing::Test { | 66 class ChromotingHostTest : public testing::Test { |
66 public: | 67 public: |
67 ChromotingHostTest() { | 68 ChromotingHostTest() { |
68 } | 69 } |
69 | 70 |
70 virtual void SetUp() OVERRIDE { | 71 virtual void SetUp() OVERRIDE { |
| 72 message_loop_proxy_ = base::MessageLoopProxy::CreateForCurrentThread(); |
71 config_ = new InMemoryHostConfig(); | 73 config_ = new InMemoryHostConfig(); |
72 ON_CALL(context_, main_message_loop()) | 74 ON_CALL(context_, main_message_loop()) |
73 .WillByDefault(Return(&message_loop_)); | 75 .WillByDefault(Return(&message_loop_)); |
74 ON_CALL(context_, encode_message_loop()) | 76 ON_CALL(context_, encode_message_loop()) |
75 .WillByDefault(Return(&message_loop_)); | 77 .WillByDefault(Return(&message_loop_)); |
76 ON_CALL(context_, network_message_loop()) | 78 ON_CALL(context_, network_message_loop()) |
77 .WillByDefault(Return(&message_loop_)); | 79 .WillByDefault(Return(message_loop_proxy_.get())); |
78 ON_CALL(context_, ui_message_loop()) | 80 ON_CALL(context_, ui_message_loop()) |
79 .WillByDefault(Return(&message_loop_)); | 81 .WillByDefault(Return(&message_loop_)); |
80 EXPECT_CALL(context_, main_message_loop()) | 82 EXPECT_CALL(context_, main_message_loop()) |
81 .Times(AnyNumber()); | 83 .Times(AnyNumber()); |
82 EXPECT_CALL(context_, encode_message_loop()) | 84 EXPECT_CALL(context_, encode_message_loop()) |
83 .Times(AnyNumber()); | 85 .Times(AnyNumber()); |
84 EXPECT_CALL(context_, network_message_loop()) | 86 EXPECT_CALL(context_, network_message_loop()) |
85 .Times(AnyNumber()); | 87 .Times(AnyNumber()); |
86 EXPECT_CALL(context_, ui_message_loop()) | 88 EXPECT_CALL(context_, ui_message_loop()) |
87 .Times(AnyNumber()); | 89 .Times(AnyNumber()); |
(...skipping 16 matching lines...) Expand all Loading... |
104 local_input_monitor_)); | 106 local_input_monitor_)); |
105 MockAccessVerifier* access_verifier = new MockAccessVerifier(); | 107 MockAccessVerifier* access_verifier = new MockAccessVerifier(); |
106 | 108 |
107 host_ = ChromotingHost::Create(&context_, config_, | 109 host_ = ChromotingHost::Create(&context_, config_, |
108 desktop_environment_.get(), | 110 desktop_environment_.get(), |
109 access_verifier, false); | 111 access_verifier, false); |
110 credentials_.set_type(protocol::PASSWORD); | 112 credentials_.set_type(protocol::PASSWORD); |
111 credentials_.set_username("user"); | 113 credentials_.set_username("user"); |
112 credentials_.set_credential("password"); | 114 credentials_.set_credential("password"); |
113 connection_ = new MockConnectionToClient( | 115 connection_ = new MockConnectionToClient( |
114 &message_loop_, &handler_, &host_stub_, event_executor_); | 116 &handler_, &host_stub_, event_executor_); |
115 connection2_ = new MockConnectionToClient( | 117 connection2_ = new MockConnectionToClient( |
116 &message_loop_, &handler_, &host_stub2_, &event_executor2_); | 118 &handler_, &host_stub2_, &event_executor2_); |
117 session_.reset(new MockSession()); | 119 session_.reset(new MockSession()); |
118 session2_.reset(new MockSession()); | 120 session2_.reset(new MockSession()); |
119 session_config_.reset(SessionConfig::CreateDefault()); | 121 session_config_.reset(SessionConfig::CreateDefault()); |
120 session_config2_.reset(SessionConfig::CreateDefault()); | 122 session_config2_.reset(SessionConfig::CreateDefault()); |
121 | 123 |
122 ON_CALL(video_stub_, ProcessVideoPacket(_, _)) | 124 ON_CALL(video_stub_, ProcessVideoPacket(_, _)) |
123 .WillByDefault( | 125 .WillByDefault( |
124 DoAll(DeleteArg<0>(), DeleteArg<1>())); | 126 DoAll(DeleteArg<0>(), DeleteArg<1>())); |
125 ON_CALL(video_stub2_, ProcessVideoPacket(_, _)) | 127 ON_CALL(video_stub2_, ProcessVideoPacket(_, _)) |
126 .WillByDefault( | 128 .WillByDefault( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 host->clients_.push_back(session); | 207 host->clients_.push_back(session); |
206 } | 208 } |
207 | 209 |
208 void ShutdownHost() { | 210 void ShutdownHost() { |
209 host_->Shutdown( | 211 host_->Shutdown( |
210 NewRunnableFunction(&PostQuitTask, &message_loop_)); | 212 NewRunnableFunction(&PostQuitTask, &message_loop_)); |
211 } | 213 } |
212 | 214 |
213 protected: | 215 protected: |
214 MessageLoop message_loop_; | 216 MessageLoop message_loop_; |
| 217 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
215 MockConnectionToClientEventHandler handler_; | 218 MockConnectionToClientEventHandler handler_; |
216 scoped_ptr<DesktopEnvironment> desktop_environment_; | 219 scoped_ptr<DesktopEnvironment> desktop_environment_; |
217 scoped_refptr<ChromotingHost> host_; | 220 scoped_refptr<ChromotingHost> host_; |
218 scoped_refptr<InMemoryHostConfig> config_; | 221 scoped_refptr<InMemoryHostConfig> config_; |
219 MockChromotingHostContext context_; | 222 MockChromotingHostContext context_; |
220 protocol::LocalLoginCredentials credentials_; | 223 protocol::LocalLoginCredentials credentials_; |
221 scoped_refptr<MockConnectionToClient> connection_; | 224 scoped_refptr<MockConnectionToClient> connection_; |
222 scoped_ptr<MockSession> session_; | 225 scoped_ptr<MockSession> session_; |
223 scoped_ptr<SessionConfig> session_config_; | 226 scoped_ptr<SessionConfig> session_config_; |
224 MockVideoStub video_stub_; | 227 MockVideoStub video_stub_; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 EXPECT_CALL(*connection_.get(), Disconnect()) | 497 EXPECT_CALL(*connection_.get(), Disconnect()) |
495 .InSequence(s1, s2) | 498 .InSequence(s1, s2) |
496 .RetiresOnSaturation(); | 499 .RetiresOnSaturation(); |
497 } | 500 } |
498 SimulateClientConnection(0, true); | 501 SimulateClientConnection(0, true); |
499 message_loop_.Run(); | 502 message_loop_.Run(); |
500 host_->set_it2me(false); | 503 host_->set_it2me(false); |
501 EXPECT_THAT(curtain_activated, false); | 504 EXPECT_THAT(curtain_activated, false); |
502 } | 505 } |
503 } // namespace remoting | 506 } // namespace remoting |
OLD | NEW |