| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/shaped_screen_capturer.h" | 5 #include "remoting/host/shaped_screen_capturer.h" |
| 6 | 6 |
| 7 #include "remoting/host/desktop_shape_tracker.h" | 7 #include "remoting/host/desktop_shape_tracker.h" |
| 8 #include "remoting/host/fake_screen_capturer.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 10 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 11 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 12 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
| 12 | 13 |
| 13 namespace remoting { | 14 namespace remoting { |
| 14 | 15 |
| 15 const int kScreenSize = 10; | |
| 16 | |
| 17 class FakeScreenCapturer : public webrtc::ScreenCapturer { | |
| 18 public: | |
| 19 FakeScreenCapturer() {} | |
| 20 virtual ~FakeScreenCapturer() {} | |
| 21 | |
| 22 virtual void Start(Callback* callback) OVERRIDE { | |
| 23 callback_ = callback; | |
| 24 } | |
| 25 | |
| 26 virtual void Capture(const webrtc::DesktopRegion& region) OVERRIDE { | |
| 27 webrtc::DesktopFrame* frame = new webrtc::BasicDesktopFrame( | |
| 28 webrtc::DesktopSize(kScreenSize, kScreenSize)); | |
| 29 memset(frame->data(), 0, frame->stride() * kScreenSize); | |
| 30 callback_->OnCaptureCompleted(frame); | |
| 31 } | |
| 32 | |
| 33 virtual void SetMouseShapeObserver( | |
| 34 MouseShapeObserver* mouse_shape_observer) OVERRIDE { | |
| 35 } | |
| 36 virtual bool GetScreenList(ScreenList* screens) OVERRIDE { | |
| 37 return false; | |
| 38 } | |
| 39 virtual bool SelectScreen(webrtc::ScreenId id) OVERRIDE { | |
| 40 return false; | |
| 41 } | |
| 42 | |
| 43 private: | |
| 44 Callback* callback_; | |
| 45 }; | |
| 46 | |
| 47 class FakeDesktopShapeTracker : public DesktopShapeTracker { | 16 class FakeDesktopShapeTracker : public DesktopShapeTracker { |
| 48 public: | 17 public: |
| 49 FakeDesktopShapeTracker() {} | 18 FakeDesktopShapeTracker() {} |
| 50 virtual ~FakeDesktopShapeTracker() {} | 19 virtual ~FakeDesktopShapeTracker() {} |
| 51 | 20 |
| 52 static webrtc::DesktopRegion CreateShape() { | 21 static webrtc::DesktopRegion CreateShape() { |
| 53 webrtc::DesktopRegion result; | 22 webrtc::DesktopRegion result; |
| 54 result.AddRect(webrtc::DesktopRect::MakeXYWH(0, 0, 5, 5)); | 23 result.AddRect(webrtc::DesktopRect::MakeXYWH(0, 0, 5, 5)); |
| 55 result.AddRect(webrtc::DesktopRect::MakeXYWH(5, 5, 5, 5)); | 24 result.AddRect(webrtc::DesktopRect::MakeXYWH(5, 5, 5, 5)); |
| 56 return result; | 25 return result; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 scoped_ptr<DesktopShapeTracker>(new FakeDesktopShapeTracker())); | 61 scoped_ptr<DesktopShapeTracker>(new FakeDesktopShapeTracker())); |
| 93 capturer.Start(this); | 62 capturer.Start(this); |
| 94 capturer.Capture(webrtc::DesktopRegion()); | 63 capturer.Capture(webrtc::DesktopRegion()); |
| 95 ASSERT_TRUE(last_frame_.get()); | 64 ASSERT_TRUE(last_frame_.get()); |
| 96 ASSERT_TRUE(last_frame_->shape()); | 65 ASSERT_TRUE(last_frame_->shape()); |
| 97 EXPECT_TRUE( | 66 EXPECT_TRUE( |
| 98 FakeDesktopShapeTracker::CreateShape().Equals(*last_frame_->shape())); | 67 FakeDesktopShapeTracker::CreateShape().Equals(*last_frame_->shape())); |
| 99 } | 68 } |
| 100 | 69 |
| 101 } // namespace remoting | 70 } // namespace remoting |
| OLD | NEW |