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_desktop_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 "remoting/host/fake_desktop_capturer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
12 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 12 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
13 | 13 |
14 namespace remoting { | 14 namespace remoting { |
15 | 15 |
16 class FakeDesktopShapeTracker : public DesktopShapeTracker { | 16 class FakeDesktopShapeTracker : public DesktopShapeTracker { |
17 public: | 17 public: |
18 FakeDesktopShapeTracker() {} | 18 FakeDesktopShapeTracker() {} |
(...skipping 13 matching lines...) Expand all Loading... |
32 virtual const webrtc::DesktopRegion& desktop_shape() OVERRIDE { | 32 virtual const webrtc::DesktopRegion& desktop_shape() OVERRIDE { |
33 // desktop_shape() can't be called before RefreshDesktopShape(). | 33 // desktop_shape() can't be called before RefreshDesktopShape(). |
34 EXPECT_FALSE(shape_.is_empty()); | 34 EXPECT_FALSE(shape_.is_empty()); |
35 return shape_; | 35 return shape_; |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 webrtc::DesktopRegion shape_; | 39 webrtc::DesktopRegion shape_; |
40 }; | 40 }; |
41 | 41 |
42 class ShapedScreenCapturerTest : public testing::Test, | 42 class ShapedDesktopCapturerTest : public testing::Test, |
43 public webrtc::DesktopCapturer::Callback { | 43 public webrtc::DesktopCapturer::Callback { |
44 public: | 44 public: |
45 // webrtc::DesktopCapturer::Callback interface | 45 // webrtc::DesktopCapturer::Callback interface |
46 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE { | 46 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE { |
47 return NULL; | 47 return NULL; |
48 } | 48 } |
49 | 49 |
50 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE { | 50 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE { |
51 last_frame_.reset(frame); | 51 last_frame_.reset(frame); |
52 } | 52 } |
53 | 53 |
54 scoped_ptr<webrtc::DesktopFrame> last_frame_; | 54 scoped_ptr<webrtc::DesktopFrame> last_frame_; |
55 }; | 55 }; |
56 | 56 |
57 // Verify that captured frame have shape. | 57 // Verify that captured frame have shape. |
58 TEST_F(ShapedScreenCapturerTest, Basic) { | 58 TEST_F(ShapedDesktopCapturerTest, Basic) { |
59 ShapedScreenCapturer capturer( | 59 ShapedDesktopCapturer capturer( |
60 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer()), | 60 scoped_ptr<webrtc::DesktopCapturer>(new FakeDesktopCapturer()), |
61 scoped_ptr<DesktopShapeTracker>(new FakeDesktopShapeTracker())); | 61 scoped_ptr<DesktopShapeTracker>(new FakeDesktopShapeTracker())); |
62 capturer.Start(this); | 62 capturer.Start(this); |
63 capturer.Capture(webrtc::DesktopRegion()); | 63 capturer.Capture(webrtc::DesktopRegion()); |
64 ASSERT_TRUE(last_frame_.get()); | 64 ASSERT_TRUE(last_frame_.get()); |
65 ASSERT_TRUE(last_frame_->shape()); | 65 ASSERT_TRUE(last_frame_->shape()); |
66 EXPECT_TRUE( | 66 EXPECT_TRUE( |
67 FakeDesktopShapeTracker::CreateShape().Equals(*last_frame_->shape())); | 67 FakeDesktopShapeTracker::CreateShape().Equals(*last_frame_->shape())); |
68 } | 68 } |
69 | 69 |
70 } // namespace remoting | 70 } // namespace remoting |
OLD | NEW |