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 { |
11 | 11 |
12 namespace { | |
13 | |
14 // A task that does nothing. | |
15 class DummyTask : public Task { | |
16 public: | |
17 void Run() {} | |
18 }; | |
19 | |
20 } // namespace | |
21 | |
22 using protocol::MockConnectionToClient; | 12 using protocol::MockConnectionToClient; |
23 using protocol::MockConnectionToClientEventHandler; | 13 using protocol::MockConnectionToClientEventHandler; |
24 using protocol::MockHostStub; | 14 using protocol::MockHostStub; |
25 using protocol::MockInputStub; | 15 using protocol::MockInputStub; |
26 using protocol::MockSession; | 16 using protocol::MockSession; |
27 | 17 |
28 using testing::_; | 18 using testing::_; |
29 using testing::DeleteArg; | 19 using testing::DeleteArg; |
30 using testing::InSequence; | 20 using testing::InSequence; |
31 using testing::Return; | 21 using testing::Return; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 .WillOnce(Return(true)); | 114 .WillOnce(Return(true)); |
125 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); | 115 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); |
126 EXPECT_CALL(input_stub_, InjectKeyEvent(EqualsKeyEvent(2, true))); | 116 EXPECT_CALL(input_stub_, InjectKeyEvent(EqualsKeyEvent(2, true))); |
127 EXPECT_CALL(input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); | 117 EXPECT_CALL(input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); |
128 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); | 118 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); |
129 | 119 |
130 // These events should not get through to the input stub, | 120 // These events should not get through to the input stub, |
131 // because the client isn't authenticated yet. | 121 // because the client isn't authenticated yet. |
132 client_session_->InjectKeyEvent(key_event1); | 122 client_session_->InjectKeyEvent(key_event1); |
133 client_session_->InjectMouseEvent(mouse_event1); | 123 client_session_->InjectMouseEvent(mouse_event1); |
134 client_session_->BeginSessionRequest(&credentials, new DummyTask()); | 124 client_session_->BeginSessionRequest(&credentials, base::Closure()); |
135 // These events should get through to the input stub. | 125 // These events should get through to the input stub. |
136 client_session_->InjectKeyEvent(key_event2_down); | 126 client_session_->InjectKeyEvent(key_event2_down); |
137 client_session_->InjectKeyEvent(key_event2_up); | 127 client_session_->InjectKeyEvent(key_event2_up); |
138 client_session_->InjectMouseEvent(mouse_event2); | 128 client_session_->InjectMouseEvent(mouse_event2); |
139 client_session_->OnDisconnected(); | 129 client_session_->OnDisconnected(); |
140 // These events should not get through to the input stub, | 130 // These events should not get through to the input stub, |
141 // because the client has disconnected. | 131 // because the client has disconnected. |
142 client_session_->InjectKeyEvent(key_event3); | 132 client_session_->InjectKeyEvent(key_event3); |
143 client_session_->InjectMouseEvent(mouse_event3); | 133 client_session_->InjectMouseEvent(mouse_event3); |
144 } | 134 } |
(...skipping 14 matching lines...) Expand all Loading... |
159 credentials.set_username("user"); | 149 credentials.set_username("user"); |
160 credentials.set_credential("password"); | 150 credentials.set_credential("password"); |
161 | 151 |
162 InSequence s; | 152 InSequence s; |
163 EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) | 153 EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) |
164 .WillOnce(Return(true)); | 154 .WillOnce(Return(true)); |
165 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); | 155 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); |
166 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(100, 101))); | 156 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(100, 101))); |
167 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); | 157 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); |
168 | 158 |
169 client_session_->BeginSessionRequest(&credentials, new DummyTask()); | 159 client_session_->BeginSessionRequest(&credentials, base::Closure()); |
170 // This event should get through to the input stub. | 160 // This event should get through to the input stub. |
171 client_session_->InjectMouseEvent(mouse_event1); | 161 client_session_->InjectMouseEvent(mouse_event1); |
172 // This one should too because the local event echoes the remote one. | 162 // This one should too because the local event echoes the remote one. |
173 client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), | 163 client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), |
174 mouse_event1.y())); | 164 mouse_event1.y())); |
175 client_session_->InjectMouseEvent(mouse_event2); | 165 client_session_->InjectMouseEvent(mouse_event2); |
176 // This one should not. | 166 // This one should not. |
177 client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), | 167 client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), |
178 mouse_event1.y())); | 168 mouse_event1.y())); |
179 client_session_->InjectMouseEvent(mouse_event3); | 169 client_session_->InjectMouseEvent(mouse_event3); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 EXPECT_CALL(capturer_, size_most_recent()) | 202 EXPECT_CALL(capturer_, size_most_recent()) |
213 .WillRepeatedly(ReturnRef(screen)); | 203 .WillRepeatedly(ReturnRef(screen)); |
214 | 204 |
215 protocol::LocalLoginCredentials credentials; | 205 protocol::LocalLoginCredentials credentials; |
216 credentials.set_type(protocol::PASSWORD); | 206 credentials.set_type(protocol::PASSWORD); |
217 credentials.set_username("user"); | 207 credentials.set_username("user"); |
218 credentials.set_credential("password"); | 208 credentials.set_credential("password"); |
219 EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) | 209 EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) |
220 .WillOnce(Return(true)); | 210 .WillOnce(Return(true)); |
221 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); | 211 EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); |
222 client_session_->BeginSessionRequest(&credentials, new DummyTask()); | 212 client_session_->BeginSessionRequest(&credentials, base::Closure()); |
223 | 213 |
224 int input_x[3] = { -999, 100, 999 }; | 214 int input_x[3] = { -999, 100, 999 }; |
225 int expected_x[3] = { 0, 100, 199 }; | 215 int expected_x[3] = { 0, 100, 199 }; |
226 int input_y[3] = { -999, 50, 999 }; | 216 int input_y[3] = { -999, 50, 999 }; |
227 int expected_y[3] = { 0, 50, 99 }; | 217 int expected_y[3] = { 0, 50, 99 }; |
228 | 218 |
229 protocol::MouseEvent event; | 219 protocol::MouseEvent event; |
230 for (int j = 0; j < 3; j++) { | 220 for (int j = 0; j < 3; j++) { |
231 for (int i = 0; i < 3; i++) { | 221 for (int i = 0; i < 3; i++) { |
232 event.set_x(input_x[i]); | 222 event.set_x(input_x[i]); |
233 event.set_y(input_y[j]); | 223 event.set_y(input_y[j]); |
234 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent( | 224 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent( |
235 expected_x[i], expected_y[j]))); | 225 expected_x[i], expected_y[j]))); |
236 client_session_->InjectMouseEvent(event); | 226 client_session_->InjectMouseEvent(event); |
237 } | 227 } |
238 } | 228 } |
239 } | 229 } |
240 | 230 |
241 } // namespace remoting | 231 } // namespace remoting |
OLD | NEW |