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 "remoting/host/client_session.h" | 5 #include "remoting/host/client_session.h" |
6 #include "remoting/host/host_mock_objects.h" | 6 #include "remoting/host/host_mock_objects.h" |
7 #include "remoting/protocol/protocol_mock_objects.h" | 7 #include "remoting/protocol/protocol_mock_objects.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace remoting { | 10 namespace remoting { |
(...skipping 27 matching lines...) Expand all Loading... |
38 virtual void SetUp() { | 38 virtual void SetUp() { |
39 client_jid_ = "user@domain/rest-of-jid"; | 39 client_jid_ = "user@domain/rest-of-jid"; |
40 EXPECT_CALL(session_, jid()).WillRepeatedly(ReturnRef(client_jid_)); | 40 EXPECT_CALL(session_, jid()).WillRepeatedly(ReturnRef(client_jid_)); |
41 | 41 |
42 connection_ = new MockConnectionToClient( | 42 connection_ = new MockConnectionToClient( |
43 &connection_event_handler_, &host_stub_, &input_stub_); | 43 &connection_event_handler_, &host_stub_, &input_stub_); |
44 | 44 |
45 EXPECT_CALL(*connection_, session()).WillRepeatedly(Return(&session_)); | 45 EXPECT_CALL(*connection_, session()).WillRepeatedly(Return(&session_)); |
46 | 46 |
47 // Set up a large default screen size that won't affect most tests. | 47 // Set up a large default screen size that won't affect most tests. |
48 default_screen_size_.SetSize(1000, 1000); | 48 default_screen_size_.set(1000, 1000); |
49 ON_CALL(capturer_, size_most_recent()).WillByDefault(ReturnRef( | 49 ON_CALL(capturer_, size_most_recent()).WillByDefault(ReturnRef( |
50 default_screen_size_)); | 50 default_screen_size_)); |
51 | 51 |
52 user_authenticator_ = new MockUserAuthenticator(); | 52 user_authenticator_ = new MockUserAuthenticator(); |
53 client_session_ = new ClientSession( | 53 client_session_ = new ClientSession( |
54 &session_event_handler_, | 54 &session_event_handler_, |
55 user_authenticator_, | 55 user_authenticator_, |
56 connection_, | 56 connection_, |
57 &input_stub_, | 57 &input_stub_, |
58 &capturer_); | 58 &capturer_); |
59 } | 59 } |
60 | 60 |
61 protected: | 61 protected: |
62 gfx::Size default_screen_size_; | 62 SkISize default_screen_size_; |
63 MessageLoop message_loop_; | 63 MessageLoop message_loop_; |
64 std::string client_jid_; | 64 std::string client_jid_; |
65 MockSession session_; | 65 MockSession session_; |
66 MockConnectionToClientEventHandler connection_event_handler_; | 66 MockConnectionToClientEventHandler connection_event_handler_; |
67 MockHostStub host_stub_; | 67 MockHostStub host_stub_; |
68 MockInputStub input_stub_; | 68 MockInputStub input_stub_; |
69 MockCapturer capturer_; | 69 MockCapturer capturer_; |
70 MockClientSessionEventHandler session_event_handler_; | 70 MockClientSessionEventHandler session_event_handler_; |
71 MockUserAuthenticator* user_authenticator_; | 71 MockUserAuthenticator* user_authenticator_; |
72 scoped_refptr<MockConnectionToClient> connection_; | 72 scoped_refptr<MockConnectionToClient> connection_; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) | 163 EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) |
164 .WillOnce(Return(true)); | 164 .WillOnce(Return(true)); |
165 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); | 165 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); |
166 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(100, 101))); | 166 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(100, 101))); |
167 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); | 167 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); |
168 | 168 |
169 client_session_->BeginSessionRequest(&credentials, new DummyTask()); | 169 client_session_->BeginSessionRequest(&credentials, new DummyTask()); |
170 // This event should get through to the input stub. | 170 // This event should get through to the input stub. |
171 client_session_->InjectMouseEvent(mouse_event1); | 171 client_session_->InjectMouseEvent(mouse_event1); |
172 // This one should too because the local event echoes the remote one. | 172 // This one should too because the local event echoes the remote one. |
173 client_session_->LocalMouseMoved(gfx::Point(mouse_event1.x(), | 173 client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), |
174 mouse_event1.y())); | 174 mouse_event1.y())); |
175 client_session_->InjectMouseEvent(mouse_event2); | 175 client_session_->InjectMouseEvent(mouse_event2); |
176 // This one should not. | 176 // This one should not. |
177 client_session_->LocalMouseMoved(gfx::Point(mouse_event1.x(), | 177 client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), |
178 mouse_event1.y())); | 178 mouse_event1.y())); |
179 client_session_->InjectMouseEvent(mouse_event3); | 179 client_session_->InjectMouseEvent(mouse_event3); |
180 // TODO(jamiewalch): Verify that remote inputs are re-enabled eventually | 180 // TODO(jamiewalch): Verify that remote inputs are re-enabled eventually |
181 // (via dependency injection, not sleep!) | 181 // (via dependency injection, not sleep!) |
182 client_session_->OnDisconnected(); | 182 client_session_->OnDisconnected(); |
183 } | 183 } |
184 | 184 |
185 TEST_F(ClientSessionTest, RestoreEventState) { | 185 TEST_F(ClientSessionTest, RestoreEventState) { |
186 protocol::KeyEvent key1; | 186 protocol::KeyEvent key1; |
187 key1.set_pressed(true); | 187 key1.set_pressed(true); |
188 key1.set_keycode(1); | 188 key1.set_keycode(1); |
(...skipping 12 matching lines...) Expand all Loading... |
201 | 201 |
202 EXPECT_CALL(input_stub_, InjectKeyEvent(EqualsKeyEvent(1, false))); | 202 EXPECT_CALL(input_stub_, InjectKeyEvent(EqualsKeyEvent(1, false))); |
203 EXPECT_CALL(input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); | 203 EXPECT_CALL(input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); |
204 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseUpEvent( | 204 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseUpEvent( |
205 protocol::MouseEvent::BUTTON_LEFT))); | 205 protocol::MouseEvent::BUTTON_LEFT))); |
206 | 206 |
207 client_session_->RestoreEventState(); | 207 client_session_->RestoreEventState(); |
208 } | 208 } |
209 | 209 |
210 TEST_F(ClientSessionTest, ClampMouseEvents) { | 210 TEST_F(ClientSessionTest, ClampMouseEvents) { |
211 gfx::Size screen(200, 100); | 211 SkISize screen(SkISize::Make(200, 100)); |
212 EXPECT_CALL(capturer_, size_most_recent()) | 212 EXPECT_CALL(capturer_, size_most_recent()) |
213 .WillRepeatedly(ReturnRef(screen)); | 213 .WillRepeatedly(ReturnRef(screen)); |
214 | 214 |
215 protocol::LocalLoginCredentials credentials; | 215 protocol::LocalLoginCredentials credentials; |
216 credentials.set_type(protocol::PASSWORD); | 216 credentials.set_type(protocol::PASSWORD); |
217 credentials.set_username("user"); | 217 credentials.set_username("user"); |
218 credentials.set_credential("password"); | 218 credentials.set_credential("password"); |
219 EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) | 219 EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) |
220 .WillOnce(Return(true)); | 220 .WillOnce(Return(true)); |
221 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); | 221 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); |
(...skipping 10 matching lines...) Expand all Loading... |
232 event.set_x(input_x[i]); | 232 event.set_x(input_x[i]); |
233 event.set_y(input_y[j]); | 233 event.set_y(input_y[j]); |
234 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent( | 234 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent( |
235 expected_x[i], expected_y[j]))); | 235 expected_x[i], expected_y[j]))); |
236 client_session_->InjectMouseEvent(event); | 236 client_session_->InjectMouseEvent(event); |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 } // namespace remoting | 241 } // namespace remoting |
OLD | NEW |