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 "remoting/host/ipc_desktop_environment.h" | 5 #include "remoting/host/ipc_desktop_environment.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 using protocol::test::EqualsTouchEvent; | 59 using protocol::test::EqualsTouchEvent; |
60 using protocol::test::EqualsTouchEventTypeAndId; | 60 using protocol::test::EqualsTouchEventTypeAndId; |
61 | 61 |
62 namespace { | 62 namespace { |
63 | 63 |
64 class MockScreenCapturerCallback : public webrtc::ScreenCapturer::Callback { | 64 class MockScreenCapturerCallback : public webrtc::ScreenCapturer::Callback { |
65 public: | 65 public: |
66 MockScreenCapturerCallback() {} | 66 MockScreenCapturerCallback() {} |
67 virtual ~MockScreenCapturerCallback() {} | 67 virtual ~MockScreenCapturerCallback() {} |
68 | 68 |
69 MOCK_METHOD1(OnCaptureCompleted, void(webrtc::DesktopFrame*)); | 69 MOCK_METHOD2(OnCaptureResultPtr, |
| 70 void(webrtc::DesktopCapturer::Result result, |
| 71 std::unique_ptr<webrtc::DesktopFrame>* frame)); |
| 72 void OnCaptureResult(webrtc::DesktopCapturer::Result result, |
| 73 std::unique_ptr<webrtc::DesktopFrame> frame) override { |
| 74 OnCaptureResultPtr(result, &frame); |
| 75 } |
70 | 76 |
71 private: | 77 private: |
72 DISALLOW_COPY_AND_ASSIGN(MockScreenCapturerCallback); | 78 DISALLOW_COPY_AND_ASSIGN(MockScreenCapturerCallback); |
73 }; | 79 }; |
74 | 80 |
75 // Receives messages sent from the network process to the daemon. | 81 // Receives messages sent from the network process to the daemon. |
76 class FakeDaemonSender : public IPC::Sender { | 82 class FakeDaemonSender : public IPC::Sender { |
77 public: | 83 public: |
78 FakeDaemonSender() {} | 84 FakeDaemonSender() {} |
79 ~FakeDaemonSender() override {} | 85 ~FakeDaemonSender() override {} |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 .Times(0); | 542 .Times(0); |
537 | 543 |
538 // Start the input injector and screen capturer. | 544 // Start the input injector and screen capturer. |
539 input_injector_->Start(std::move(clipboard_stub)); | 545 input_injector_->Start(std::move(clipboard_stub)); |
540 video_capturer_->Start(&desktop_capturer_callback_); | 546 video_capturer_->Start(&desktop_capturer_callback_); |
541 | 547 |
542 // Run the message loop until the desktop is attached. | 548 // Run the message loop until the desktop is attached. |
543 setup_run_loop_->Run(); | 549 setup_run_loop_->Run(); |
544 | 550 |
545 // Stop the test when the first frame is captured. | 551 // Stop the test when the first frame is captured. |
546 EXPECT_CALL(desktop_capturer_callback_, OnCaptureCompleted(_)) | 552 EXPECT_CALL(desktop_capturer_callback_, OnCaptureResultPtr(_, _)) |
547 .WillOnce(DoAll( | 553 .WillOnce(InvokeWithoutArgs( |
548 DeleteArg<0>(), | 554 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
549 InvokeWithoutArgs( | |
550 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment))); | |
551 | 555 |
552 // Capture a single frame. | 556 // Capture a single frame. |
553 video_capturer_->Capture(webrtc::DesktopRegion()); | 557 video_capturer_->Capture(webrtc::DesktopRegion()); |
554 } | 558 } |
555 | 559 |
556 // Tests that attaching to a new desktop works. | 560 // Tests that attaching to a new desktop works. |
557 TEST_F(IpcDesktopEnvironmentTest, Reattach) { | 561 TEST_F(IpcDesktopEnvironmentTest, Reattach) { |
558 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( | 562 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
559 new protocol::MockClipboardStub()); | 563 new protocol::MockClipboardStub()); |
560 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 564 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 .WillOnce(InvokeWithoutArgs( | 754 .WillOnce(InvokeWithoutArgs( |
751 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 755 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
752 | 756 |
753 // Change the desktop resolution. | 757 // Change the desktop resolution. |
754 screen_controls_->SetScreenResolution(ScreenResolution( | 758 screen_controls_->SetScreenResolution(ScreenResolution( |
755 webrtc::DesktopSize(100, 100), | 759 webrtc::DesktopSize(100, 100), |
756 webrtc::DesktopVector(96, 96))); | 760 webrtc::DesktopVector(96, 96))); |
757 } | 761 } |
758 | 762 |
759 } // namespace remoting | 763 } // namespace remoting |
OLD | NEW |