| 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/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "remoting/base/auto_thread_task_runner.h" | 6 #include "remoting/base/auto_thread_task_runner.h" |
| 7 #include "remoting/base/constants.h" | 7 #include "remoting/base/constants.h" |
| 8 #include "remoting/host/audio_capturer.h" | 8 #include "remoting/host/audio_capturer.h" |
| 9 #include "remoting/host/client_session.h" | 9 #include "remoting/host/client_session.h" |
| 10 #include "remoting/host/desktop_environment.h" | 10 #include "remoting/host/desktop_environment.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 EXPECT_CALL(*capturer_, Stop()); | 61 EXPECT_CALL(*capturer_, Stop()); |
| 62 EXPECT_CALL(*capturer_, InvalidateRegion(_)).Times(AnyNumber()); | 62 EXPECT_CALL(*capturer_, InvalidateRegion(_)).Times(AnyNumber()); |
| 63 EXPECT_CALL(*capturer_, CaptureInvalidRegion(_)).Times(AnyNumber()); | 63 EXPECT_CALL(*capturer_, CaptureInvalidRegion(_)).Times(AnyNumber()); |
| 64 | 64 |
| 65 scoped_ptr<DesktopEnvironment> desktop_environment(new DesktopEnvironment( | 65 scoped_ptr<DesktopEnvironment> desktop_environment(new DesktopEnvironment( |
| 66 scoped_ptr<AudioCapturer>(NULL), | 66 scoped_ptr<AudioCapturer>(NULL), |
| 67 scoped_ptr<EventExecutor>(event_executor_), | 67 scoped_ptr<EventExecutor>(event_executor_), |
| 68 scoped_ptr<VideoFrameCapturer>(capturer_))); | 68 scoped_ptr<VideoFrameCapturer>(capturer_))); |
| 69 | 69 |
| 70 // Set up a large default screen size that won't affect most tests. | 70 // Set up a large default screen size that won't affect most tests. |
| 71 default_screen_size_.set(1000, 1000); | 71 screen_size_.set(1000, 1000); |
| 72 EXPECT_CALL(*capturer_, size_most_recent()) | 72 EXPECT_CALL(*capturer_, size_most_recent()) |
| 73 .WillRepeatedly(ReturnRef(default_screen_size_)); | 73 .WillRepeatedly(ReturnRef(screen_size_)); |
| 74 | 74 |
| 75 session_config_ = SessionConfig::GetDefault(); | 75 session_config_ = SessionConfig::GetDefault(); |
| 76 | 76 |
| 77 protocol::MockSession* session = new MockSession(); | 77 protocol::MockSession* session = new MockSession(); |
| 78 EXPECT_CALL(*session, config()).WillRepeatedly(ReturnRef(session_config_)); | 78 EXPECT_CALL(*session, config()).WillRepeatedly(ReturnRef(session_config_)); |
| 79 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_)); | 79 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_)); |
| 80 EXPECT_CALL(*session, SetEventHandler(_)); | 80 EXPECT_CALL(*session, SetEventHandler(_)); |
| 81 EXPECT_CALL(*session, Close()); | 81 EXPECT_CALL(*session, Close()); |
| 82 scoped_ptr<protocol::ConnectionToClient> connection( | 82 scoped_ptr<protocol::ConnectionToClient> connection( |
| 83 new protocol::ConnectionToClient(session)); | 83 new protocol::ConnectionToClient(session)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 119 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void OnClientStopped() { | 122 void OnClientStopped() { |
| 123 client_session_ = NULL; | 123 client_session_ = NULL; |
| 124 } | 124 } |
| 125 | 125 |
| 126 MessageLoop message_loop_; | 126 MessageLoop message_loop_; |
| 127 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; | 127 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; |
| 128 MockChromotingHostContext context_; | 128 MockChromotingHostContext context_; |
| 129 SkISize default_screen_size_; | 129 SkISize screen_size_; |
| 130 std::string client_jid_; | 130 std::string client_jid_; |
| 131 MockHostStub host_stub_; | 131 MockHostStub host_stub_; |
| 132 MockEventExecutor* event_executor_; | 132 MockEventExecutor* event_executor_; |
| 133 MockVideoFrameCapturer* capturer_; | 133 MockVideoFrameCapturer* capturer_; |
| 134 MockClientSessionEventHandler session_event_handler_; | 134 MockClientSessionEventHandler session_event_handler_; |
| 135 scoped_refptr<ClientSession> client_session_; | 135 scoped_refptr<ClientSession> client_session_; |
| 136 SessionConfig session_config_; | 136 SessionConfig session_config_; |
| 137 | 137 |
| 138 // ClientSession owns |connection_| but tests need it to inject fake events. | 138 // ClientSession owns |connection_| but tests need it to inject fake events. |
| 139 protocol::ConnectionToClient* connection_; | 139 protocol::ConnectionToClient* connection_; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 317 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
| 318 | 318 |
| 319 connection_->input_stub()->InjectKeyEvent(key1); | 319 connection_->input_stub()->InjectKeyEvent(key1); |
| 320 connection_->input_stub()->InjectKeyEvent(key2); | 320 connection_->input_stub()->InjectKeyEvent(key2); |
| 321 connection_->input_stub()->InjectMouseEvent(mousedown); | 321 connection_->input_stub()->InjectMouseEvent(mousedown); |
| 322 | 322 |
| 323 DisconnectClientSession(); | 323 DisconnectClientSession(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 TEST_F(ClientSessionTest, ClampMouseEvents) { | 326 TEST_F(ClientSessionTest, ClampMouseEvents) { |
| 327 SkISize screen(SkISize::Make(200, 100)); | 327 screen_size_.set(200, 100); |
| 328 EXPECT_CALL(*capturer_, size_most_recent()) | |
| 329 .WillRepeatedly(ReturnRef(screen)); | |
| 330 | 328 |
| 331 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 329 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); |
| 332 EXPECT_CALL(*event_executor_, StartPtr(_)); | 330 EXPECT_CALL(*event_executor_, StartPtr(_)); |
| 333 Expectation connected = | 331 Expectation connected = |
| 334 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); | 332 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); |
| 335 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); | 333 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); |
| 336 EXPECT_CALL(*event_executor_, StopAndDeleteMock()); | 334 EXPECT_CALL(*event_executor_, StopAndDeleteMock()); |
| 337 | 335 |
| 338 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 336 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
| 339 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 337 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 354 expected_y[j]))) | 352 expected_y[j]))) |
| 355 .After(connected); | 353 .After(connected); |
| 356 connection_->input_stub()->InjectMouseEvent(event); | 354 connection_->input_stub()->InjectMouseEvent(event); |
| 357 } | 355 } |
| 358 } | 356 } |
| 359 | 357 |
| 360 DisconnectClientSession(); | 358 DisconnectClientSession(); |
| 361 } | 359 } |
| 362 | 360 |
| 363 } // namespace remoting | 361 } // namespace remoting |
| OLD | NEW |