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/message_loop_proxy.h" |
8 #include "base/task.h" | 8 #include "base/task.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" |
11 #include "remoting/host/chromoting_host_context.h" | 11 #include "remoting/host/chromoting_host_context.h" |
12 #include "remoting/host/host_mock_objects.h" | 12 #include "remoting/host/host_mock_objects.h" |
13 #include "remoting/host/in_memory_host_config.h" | 13 #include "remoting/host/in_memory_host_config.h" |
| 14 #include "remoting/host/it2me_observer.h" |
14 #include "remoting/proto/video.pb.h" | 15 #include "remoting/proto/video.pb.h" |
15 #include "remoting/protocol/protocol_mock_objects.h" | 16 #include "remoting/protocol/protocol_mock_objects.h" |
16 #include "remoting/protocol/session_config.h" | 17 #include "remoting/protocol/session_config.h" |
17 #include "testing/gmock_mutant.h" | 18 #include "testing/gmock_mutant.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 using ::remoting::protocol::MockClientStub; | 22 using ::remoting::protocol::MockClientStub; |
22 using ::remoting::protocol::MockConnectionToClient; | 23 using ::remoting::protocol::MockConnectionToClient; |
23 using ::remoting::protocol::MockConnectionToClientEventHandler; | 24 using ::remoting::protocol::MockConnectionToClientEventHandler; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 EXPECT_CALL(context_, encode_message_loop()) | 84 EXPECT_CALL(context_, encode_message_loop()) |
84 .Times(AnyNumber()); | 85 .Times(AnyNumber()); |
85 EXPECT_CALL(context_, network_message_loop()) | 86 EXPECT_CALL(context_, network_message_loop()) |
86 .Times(AnyNumber()); | 87 .Times(AnyNumber()); |
87 EXPECT_CALL(context_, ui_message_loop()) | 88 EXPECT_CALL(context_, ui_message_loop()) |
88 .Times(AnyNumber()); | 89 .Times(AnyNumber()); |
89 | 90 |
90 Capturer* capturer = new CapturerFake(); | 91 Capturer* capturer = new CapturerFake(); |
91 event_executor_ = new MockEventExecutor(); | 92 event_executor_ = new MockEventExecutor(); |
92 curtain_ = new MockCurtain(); | 93 curtain_ = new MockCurtain(); |
93 disconnect_window_ = new MockDisconnectWindow(); | |
94 continue_window_ = new MockContinueWindow(); | |
95 local_input_monitor_ = new MockLocalInputMonitor(); | |
96 desktop_environment_.reset( | 94 desktop_environment_.reset( |
97 new DesktopEnvironment(&context_, capturer, event_executor_, curtain_, | 95 new DesktopEnvironment(&context_, capturer, event_executor_, curtain_)); |
98 disconnect_window_, continue_window_, | |
99 local_input_monitor_)); | |
100 MockAccessVerifier* access_verifier = new MockAccessVerifier(); | 96 MockAccessVerifier* access_verifier = new MockAccessVerifier(); |
101 | 97 |
102 host_ = ChromotingHost::Create(&context_, config_, | 98 host_ = ChromotingHost::Create(&context_, config_, |
103 desktop_environment_.get(), | 99 desktop_environment_.get(), |
104 access_verifier, false); | 100 access_verifier, false); |
| 101 |
| 102 disconnect_window_ = new MockDisconnectWindow(); |
| 103 continue_window_ = new MockContinueWindow(); |
| 104 local_input_monitor_ = new MockLocalInputMonitor(); |
| 105 it2me_observer_.reset(new It2MeObserver(host_, &context_)); |
| 106 it2me_observer_->InitFrom(disconnect_window_, continue_window_, |
| 107 local_input_monitor_); |
| 108 host_->AddStatusObserver(it2me_observer_.get()); |
| 109 |
105 session_ = new MockSession(); | 110 session_ = new MockSession(); |
106 session2_ = new MockSession(); | 111 session2_ = new MockSession(); |
107 session_config_ = SessionConfig::GetDefault(); | 112 session_config_ = SessionConfig::GetDefault(); |
108 session_jid_ = "user@domain/rest-of-jid"; | 113 session_jid_ = "user@domain/rest-of-jid"; |
109 session_config2_ = SessionConfig::GetDefault(); | 114 session_config2_ = SessionConfig::GetDefault(); |
110 session2_jid_ = "user2@domain/rest-of-jid"; | 115 session2_jid_ = "user2@domain/rest-of-jid"; |
111 EXPECT_CALL(*session_, jid()) | 116 EXPECT_CALL(*session_, jid()) |
112 .WillRepeatedly(ReturnRef(session_jid_)); | 117 .WillRepeatedly(ReturnRef(session_jid_)); |
113 EXPECT_CALL(*session2_, jid()) | 118 EXPECT_CALL(*session2_, jid()) |
114 .WillRepeatedly(ReturnRef(session2_jid_)); | 119 .WillRepeatedly(ReturnRef(session2_jid_)); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 message_loop_.PostTask( | 215 message_loop_.PostTask( |
211 FROM_HERE, base::Bind(&ChromotingHost::Shutdown, host_, | 216 FROM_HERE, base::Bind(&ChromotingHost::Shutdown, host_, |
212 base::Bind(&PostQuitTask, &message_loop_))); | 217 base::Bind(&PostQuitTask, &message_loop_))); |
213 } | 218 } |
214 | 219 |
215 protected: | 220 protected: |
216 MessageLoop message_loop_; | 221 MessageLoop message_loop_; |
217 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 222 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
218 MockConnectionToClientEventHandler handler_; | 223 MockConnectionToClientEventHandler handler_; |
219 scoped_ptr<DesktopEnvironment> desktop_environment_; | 224 scoped_ptr<DesktopEnvironment> desktop_environment_; |
| 225 scoped_ptr<It2MeObserver> it2me_observer_; |
220 scoped_refptr<ChromotingHost> host_; | 226 scoped_refptr<ChromotingHost> host_; |
221 scoped_refptr<InMemoryHostConfig> config_; | 227 scoped_refptr<InMemoryHostConfig> config_; |
222 MockChromotingHostContext context_; | 228 MockChromotingHostContext context_; |
223 MockConnectionToClient* connection_; | 229 MockConnectionToClient* connection_; |
224 scoped_ptr<MockConnectionToClient> owned_connection_; | 230 scoped_ptr<MockConnectionToClient> owned_connection_; |
225 ClientSession* client_; | 231 ClientSession* client_; |
226 std::string session_jid_; | 232 std::string session_jid_; |
227 MockSession* session_; // Owned by |connection_|. | 233 MockSession* session_; // Owned by |connection_|. |
228 SessionConfig session_config_; | 234 SessionConfig session_config_; |
229 MockVideoStub video_stub_; | 235 MockVideoStub video_stub_; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 .Times(1) | 504 .Times(1) |
499 .InSequence(s2); | 505 .InSequence(s2); |
500 } | 506 } |
501 SimulateClientConnection(0, true); | 507 SimulateClientConnection(0, true); |
502 message_loop_.Run(); | 508 message_loop_.Run(); |
503 host_->set_it2me(false); | 509 host_->set_it2me(false); |
504 EXPECT_THAT(curtain_activated, false); | 510 EXPECT_THAT(curtain_activated, false); |
505 } | 511 } |
506 | 512 |
507 } // namespace remoting | 513 } // namespace remoting |
OLD | NEW |