OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 using ::testing::_; | 26 using ::testing::_; |
27 using ::testing::AnyNumber; | 27 using ::testing::AnyNumber; |
28 using ::testing::Return; | 28 using ::testing::Return; |
29 | 29 |
30 namespace webrtc { | 30 namespace webrtc { |
31 | 31 |
32 class ScreenCapturerMacTest : public testing::Test { | 32 class ScreenCapturerMacTest : public testing::Test { |
33 public: | 33 public: |
34 // Verifies that the whole screen is initially dirty. | 34 // Verifies that the whole screen is initially dirty. |
35 void CaptureDoneCallback1(DesktopFrame* frame); | 35 void CaptureDoneCallback1(DesktopCapturer::Result result, |
| 36 std::unique_ptr<DesktopFrame>* frame); |
36 | 37 |
37 // Verifies that a rectangle explicitly marked as dirty is propagated | 38 // Verifies that a rectangle explicitly marked as dirty is propagated |
38 // correctly. | 39 // correctly. |
39 void CaptureDoneCallback2(DesktopFrame* frame); | 40 void CaptureDoneCallback2(DesktopCapturer::Result result, |
| 41 std::unique_ptr<DesktopFrame>* frame); |
40 | 42 |
41 protected: | 43 protected: |
42 void SetUp() override { | 44 void SetUp() override { |
43 capturer_.reset( | 45 capturer_.reset( |
44 ScreenCapturer::Create(DesktopCaptureOptions::CreateDefault())); | 46 ScreenCapturer::Create(DesktopCaptureOptions::CreateDefault())); |
45 } | 47 } |
46 | 48 |
47 std::unique_ptr<ScreenCapturer> capturer_; | 49 std::unique_ptr<ScreenCapturer> capturer_; |
48 MockScreenCapturerCallback callback_; | 50 MockScreenCapturerCallback callback_; |
49 }; | 51 }; |
50 | 52 |
51 void ScreenCapturerMacTest::CaptureDoneCallback1( | 53 void ScreenCapturerMacTest::CaptureDoneCallback1( |
52 DesktopFrame* frame) { | 54 DesktopCapturer::Result result, |
53 std::unique_ptr<DesktopFrame> owned_frame(frame); | 55 std::unique_ptr<DesktopFrame>* frame) { |
| 56 EXPECT_EQ(result, DesktopCapturer::Result::SUCCESS); |
54 | 57 |
55 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( | 58 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( |
56 MacDesktopConfiguration::BottomLeftOrigin); | 59 MacDesktopConfiguration::BottomLeftOrigin); |
57 | 60 |
58 // Verify that the region contains full frame. | 61 // Verify that the region contains full frame. |
59 DesktopRegion::Iterator it(frame->updated_region()); | 62 DesktopRegion::Iterator it((*frame)->updated_region()); |
60 EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds)); | 63 EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds)); |
61 } | 64 } |
62 | 65 |
63 void ScreenCapturerMacTest::CaptureDoneCallback2( | 66 void ScreenCapturerMacTest::CaptureDoneCallback2( |
64 DesktopFrame* frame) { | 67 DesktopCapturer::Result result, |
65 std::unique_ptr<DesktopFrame> owned_frame(frame); | 68 std::unique_ptr<DesktopFrame>* frame) { |
| 69 EXPECT_EQ(result, DesktopCapturer::Result::SUCCESS); |
66 | 70 |
67 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( | 71 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( |
68 MacDesktopConfiguration::BottomLeftOrigin); | 72 MacDesktopConfiguration::BottomLeftOrigin); |
69 int width = config.pixel_bounds.width(); | 73 int width = config.pixel_bounds.width(); |
70 int height = config.pixel_bounds.height(); | 74 int height = config.pixel_bounds.height(); |
71 | 75 |
72 EXPECT_EQ(width, frame->size().width()); | 76 EXPECT_EQ(width, (*frame)->size().width()); |
73 EXPECT_EQ(height, frame->size().height()); | 77 EXPECT_EQ(height, (*frame)->size().height()); |
74 EXPECT_TRUE(frame->data() != NULL); | 78 EXPECT_TRUE((*frame)->data() != NULL); |
75 // Depending on the capture method, the screen may be flipped or not, so | 79 // Depending on the capture method, the screen may be flipped or not, so |
76 // the stride may be positive or negative. | 80 // the stride may be positive or negative. |
77 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), | 81 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), |
78 abs(frame->stride())); | 82 abs((*frame)->stride())); |
79 } | 83 } |
80 | 84 |
81 TEST_F(ScreenCapturerMacTest, Capture) { | 85 TEST_F(ScreenCapturerMacTest, Capture) { |
82 EXPECT_CALL(callback_, OnCaptureCompleted(_)) | 86 EXPECT_CALL(callback_, |
| 87 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
83 .Times(2) | 88 .Times(2) |
84 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback1)) | 89 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback1)) |
85 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback2)); | 90 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback2)); |
86 | 91 |
87 SCOPED_TRACE(""); | 92 SCOPED_TRACE(""); |
88 capturer_->Start(&callback_); | 93 capturer_->Start(&callback_); |
89 | 94 |
90 // Check that we get an initial full-screen updated. | 95 // Check that we get an initial full-screen updated. |
91 capturer_->Capture(DesktopRegion()); | 96 capturer_->Capture(DesktopRegion()); |
92 | 97 |
93 // Check that subsequent dirty rects are propagated correctly. | 98 // Check that subsequent dirty rects are propagated correctly. |
94 capturer_->Capture(DesktopRegion()); | 99 capturer_->Capture(DesktopRegion()); |
95 } | 100 } |
96 | 101 |
97 } // namespace webrtc | 102 } // namespace webrtc |
OLD | NEW |