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 "media/video/capture/screen/screen_capturer_fake.h" | 6 #include "media/video/capture/screen/screen_capturer_fake.h" |
7 #include "media/video/capture/screen/screen_capturer_mock_objects.h" | 7 #include "media/video/capture/screen/screen_capturer_mock_objects.h" |
8 #include "remoting/base/auto_thread_task_runner.h" | 8 #include "remoting/base/auto_thread_task_runner.h" |
9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
10 #include "remoting/host/audio_capturer.h" | 10 #include "remoting/host/audio_capturer.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 protocol::ClipboardEvent clipboard_event2; | 233 protocol::ClipboardEvent clipboard_event2; |
234 clipboard_event2.set_mime_type(kMimeTypeTextUtf8); | 234 clipboard_event2.set_mime_type(kMimeTypeTextUtf8); |
235 clipboard_event2.set_data("b"); | 235 clipboard_event2.set_data("b"); |
236 | 236 |
237 protocol::ClipboardEvent clipboard_event3; | 237 protocol::ClipboardEvent clipboard_event3; |
238 clipboard_event3.set_mime_type(kMimeTypeTextUtf8); | 238 clipboard_event3.set_mime_type(kMimeTypeTextUtf8); |
239 clipboard_event3.set_data("c"); | 239 clipboard_event3.set_data("c"); |
240 | 240 |
241 Expectation authenticated = | 241 Expectation authenticated = |
242 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 242 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) |
| 243 .WillOnce(Return(true)); |
243 EXPECT_CALL(*input_injector_, StartPtr(_)) | 244 EXPECT_CALL(*input_injector_, StartPtr(_)) |
244 .After(authenticated); | 245 .After(authenticated); |
245 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 246 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
246 .After(authenticated); | 247 .After(authenticated); |
247 | 248 |
248 // Wait for the first video packet to be captured to make sure that | 249 // Wait for the first video packet to be captured to make sure that |
249 // the injected input will go though. Otherwise mouse events will be blocked | 250 // the injected input will go though. Otherwise mouse events will be blocked |
250 // by the mouse clamping filter. | 251 // by the mouse clamping filter. |
251 Sequence s; | 252 Sequence s; |
252 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) | 253 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 311 |
311 protocol::MouseEvent mouse_event2; | 312 protocol::MouseEvent mouse_event2; |
312 mouse_event2.set_x(200); | 313 mouse_event2.set_x(200); |
313 mouse_event2.set_y(201); | 314 mouse_event2.set_y(201); |
314 | 315 |
315 protocol::MouseEvent mouse_event3; | 316 protocol::MouseEvent mouse_event3; |
316 mouse_event3.set_x(300); | 317 mouse_event3.set_x(300); |
317 mouse_event3.set_y(301); | 318 mouse_event3.set_y(301); |
318 | 319 |
319 Expectation authenticated = | 320 Expectation authenticated = |
320 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 321 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) |
| 322 .WillOnce(Return(true)); |
321 EXPECT_CALL(*input_injector_, StartPtr(_)) | 323 EXPECT_CALL(*input_injector_, StartPtr(_)) |
322 .After(authenticated); | 324 .After(authenticated); |
323 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 325 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
324 .After(authenticated); | 326 .After(authenticated); |
325 | 327 |
326 // Wait for the first video packet to be captured to make sure that | 328 // Wait for the first video packet to be captured to make sure that |
327 // the injected input will go though. Otherwise mouse events will be blocked | 329 // the injected input will go though. Otherwise mouse events will be blocked |
328 // by the mouse clamping filter. | 330 // by the mouse clamping filter. |
329 Sequence s; | 331 Sequence s; |
330 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) | 332 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 mouse_event1.set_x(100); | 366 mouse_event1.set_x(100); |
365 mouse_event1.set_y(101); | 367 mouse_event1.set_y(101); |
366 protocol::MouseEvent mouse_event2; | 368 protocol::MouseEvent mouse_event2; |
367 mouse_event2.set_x(200); | 369 mouse_event2.set_x(200); |
368 mouse_event2.set_y(201); | 370 mouse_event2.set_y(201); |
369 protocol::MouseEvent mouse_event3; | 371 protocol::MouseEvent mouse_event3; |
370 mouse_event3.set_x(300); | 372 mouse_event3.set_x(300); |
371 mouse_event3.set_y(301); | 373 mouse_event3.set_y(301); |
372 | 374 |
373 Expectation authenticated = | 375 Expectation authenticated = |
374 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 376 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) |
| 377 .WillOnce(Return(true)); |
375 EXPECT_CALL(*input_injector_, StartPtr(_)) | 378 EXPECT_CALL(*input_injector_, StartPtr(_)) |
376 .After(authenticated); | 379 .After(authenticated); |
377 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 380 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
378 .After(authenticated); | 381 .After(authenticated); |
379 | 382 |
380 // Wait for the first video packet to be captured to make sure that | 383 // Wait for the first video packet to be captured to make sure that |
381 // the injected input will go though. Otherwise mouse events will be blocked | 384 // the injected input will go though. Otherwise mouse events will be blocked |
382 // by the mouse clamping filter. | 385 // by the mouse clamping filter. |
383 Sequence s; | 386 Sequence s; |
384 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) | 387 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 423 |
421 protocol::KeyEvent key2; | 424 protocol::KeyEvent key2; |
422 key2.set_pressed(true); | 425 key2.set_pressed(true); |
423 key2.set_usb_keycode(2); | 426 key2.set_usb_keycode(2); |
424 | 427 |
425 protocol::MouseEvent mousedown; | 428 protocol::MouseEvent mousedown; |
426 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT); | 429 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT); |
427 mousedown.set_button_down(true); | 430 mousedown.set_button_down(true); |
428 | 431 |
429 Expectation authenticated = | 432 Expectation authenticated = |
430 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 433 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) |
| 434 .WillOnce(Return(true)); |
431 EXPECT_CALL(*input_injector_, StartPtr(_)) | 435 EXPECT_CALL(*input_injector_, StartPtr(_)) |
432 .After(authenticated); | 436 .After(authenticated); |
433 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 437 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
434 .After(authenticated); | 438 .After(authenticated); |
435 | 439 |
436 // Wait for the first video packet to be captured to make sure that | 440 // Wait for the first video packet to be captured to make sure that |
437 // the injected input will go though. Otherwise mouse events will be blocked | 441 // the injected input will go though. Otherwise mouse events will be blocked |
438 // by the mouse clamping filter. | 442 // by the mouse clamping filter. |
439 Sequence s; | 443 Sequence s; |
440 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) | 444 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) |
(...skipping 21 matching lines...) Expand all Loading... |
462 .InSequence(s); | 466 .InSequence(s); |
463 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) | 467 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) |
464 .InSequence(s); | 468 .InSequence(s); |
465 | 469 |
466 ConnectClientSession(); | 470 ConnectClientSession(); |
467 message_loop_.Run(); | 471 message_loop_.Run(); |
468 } | 472 } |
469 | 473 |
470 TEST_F(ClientSessionTest, ClampMouseEvents) { | 474 TEST_F(ClientSessionTest, ClampMouseEvents) { |
471 Expectation authenticated = | 475 Expectation authenticated = |
472 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 476 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) |
| 477 .WillOnce(Return(true)); |
473 EXPECT_CALL(*input_injector_, StartPtr(_)) | 478 EXPECT_CALL(*input_injector_, StartPtr(_)) |
474 .After(authenticated); | 479 .After(authenticated); |
475 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 480 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
476 .After(authenticated); | 481 .After(authenticated); |
477 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) | 482 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) |
478 .After(authenticated); | 483 .After(authenticated); |
479 | 484 |
480 Expectation connected = authenticated; | 485 Expectation connected = authenticated; |
481 | 486 |
482 int input_x[3] = { -999, 100, 999 }; | 487 int input_x[3] = { -999, 100, 999 }; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 .After(connected) | 525 .After(connected) |
521 .WillOnce(DoAll( | 526 .WillOnce(DoAll( |
522 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), | 527 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), |
523 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); | 528 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); |
524 | 529 |
525 ConnectClientSession(); | 530 ConnectClientSession(); |
526 message_loop_.Run(); | 531 message_loop_.Run(); |
527 } | 532 } |
528 | 533 |
529 } // namespace remoting | 534 } // namespace remoting |
OLD | NEW |