OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 .Times(0); | 488 .Times(0); |
489 | 489 |
490 // Stop the test. | 490 // Stop the test. |
491 DeleteDesktopEnvironment(); | 491 DeleteDesktopEnvironment(); |
492 | 492 |
493 task_runner_ = NULL; | 493 task_runner_ = NULL; |
494 io_task_runner_ = NULL; | 494 io_task_runner_ = NULL; |
495 main_run_loop_.Run(); | 495 main_run_loop_.Run(); |
496 } | 496 } |
497 | 497 |
498 // Tests InvalidateRegion(). | |
499 TEST_F(IpcDesktopEnvironmentTest, InvalidateRegion) { | |
500 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | |
501 new protocol::MockClipboardStub()); | |
502 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | |
503 .Times(0); | |
504 | |
505 // Start the input injector and screen capturer. | |
506 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); | |
507 video_capturer_->Start(&screen_capturer_delegate_); | |
508 | |
509 // Run the message loop until the desktop is attached. | |
510 setup_run_loop_->Run(); | |
511 | |
512 // Input injector should receive no events. | |
513 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) | |
514 .Times(0); | |
515 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) | |
516 .Times(0); | |
517 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) | |
518 .Times(0); | |
519 | |
520 // Stop the test when the first frame is captured. | |
521 EXPECT_CALL(screen_capturer_delegate_, OnCaptureCompleted(_)) | |
522 .WillOnce(InvokeWithoutArgs( | |
523 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | |
524 | |
525 // Invalidate a region that is larger than the screen. | |
526 SkIRect horizontal_rect = SkIRect::MakeXYWH( | |
527 -100, | |
528 media::ScreenCapturerFake::kHeight / 4, | |
529 media::ScreenCapturerFake::kWidth + 200, | |
530 media::ScreenCapturerFake::kHeight / 2); | |
531 SkIRect vertical_rect = SkIRect::MakeXYWH( | |
532 media::ScreenCapturerFake::kWidth / 4, | |
533 -100, | |
534 media::ScreenCapturerFake::kWidth / 2, | |
535 media::ScreenCapturerFake::kHeight + 200); | |
536 | |
537 SkRegion invalid_region; | |
538 invalid_region.op(horizontal_rect, SkRegion::kUnion_Op); | |
539 invalid_region.op(vertical_rect, SkRegion::kUnion_Op); | |
540 video_capturer_->InvalidateRegion(invalid_region); | |
541 | |
542 // Capture a single frame. | |
543 video_capturer_->CaptureFrame(); | |
544 | |
545 task_runner_ = NULL; | |
546 io_task_runner_ = NULL; | |
547 main_run_loop_.Run(); | |
548 } | |
549 | |
550 // Tests injection of clipboard events. | 498 // Tests injection of clipboard events. |
551 TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { | 499 TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { |
552 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 500 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
553 new protocol::MockClipboardStub()); | 501 new protocol::MockClipboardStub()); |
554 clipboard_stub_ = clipboard_stub.get(); | 502 clipboard_stub_ = clipboard_stub.get(); |
555 | 503 |
556 // Stop the test when a clipboard event is received from the desktop process. | 504 // Stop the test when a clipboard event is received from the desktop process. |
557 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 505 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
558 .Times(1) | 506 .Times(1) |
559 .WillOnce(InvokeWithoutArgs( | 507 .WillOnce(InvokeWithoutArgs( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 event.set_x(0); | 599 event.set_x(0); |
652 event.set_y(0); | 600 event.set_y(0); |
653 input_injector_->InjectMouseEvent(event); | 601 input_injector_->InjectMouseEvent(event); |
654 | 602 |
655 task_runner_ = NULL; | 603 task_runner_ = NULL; |
656 io_task_runner_ = NULL; | 604 io_task_runner_ = NULL; |
657 main_run_loop_.Run(); | 605 main_run_loop_.Run(); |
658 } | 606 } |
659 | 607 |
660 } // namespace remoting | 608 } // namespace remoting |
OLD | NEW |