| 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 |
| 11 #include "webrtc/modules/desktop_capture/screen_capturer.h" | 11 #include "webrtc/modules/desktop_capture/screen_capturer.h" |
| 12 | 12 |
| 13 #include <ApplicationServices/ApplicationServices.h> | 13 #include <ApplicationServices/ApplicationServices.h> |
| 14 | 14 |
| 15 #include <memory> |
| 15 #include <ostream> | 16 #include <ostream> |
| 16 | 17 |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "webrtc/base/scoped_ptr.h" | |
| 19 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 19 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 20 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | 20 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
| 21 #include "webrtc/modules/desktop_capture/desktop_region.h" | 21 #include "webrtc/modules/desktop_capture/desktop_region.h" |
| 22 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" | 22 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" |
| 23 #include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" | 23 #include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" |
| 24 | 24 |
| 25 using ::testing::_; | 25 using ::testing::_; |
| 26 using ::testing::AnyNumber; | 26 using ::testing::AnyNumber; |
| 27 using ::testing::Return; | 27 using ::testing::Return; |
| 28 | 28 |
| 29 namespace webrtc { | 29 namespace webrtc { |
| 30 | 30 |
| 31 class ScreenCapturerMacTest : public testing::Test { | 31 class ScreenCapturerMacTest : public testing::Test { |
| 32 public: | 32 public: |
| 33 // Verifies that the whole screen is initially dirty. | 33 // Verifies that the whole screen is initially dirty. |
| 34 void CaptureDoneCallback1(DesktopFrame* frame); | 34 void CaptureDoneCallback1(DesktopFrame* frame); |
| 35 | 35 |
| 36 // Verifies that a rectangle explicitly marked as dirty is propagated | 36 // Verifies that a rectangle explicitly marked as dirty is propagated |
| 37 // correctly. | 37 // correctly. |
| 38 void CaptureDoneCallback2(DesktopFrame* frame); | 38 void CaptureDoneCallback2(DesktopFrame* frame); |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 void SetUp() override { capturer_.reset(ScreenCapturer::Create()); } | 41 void SetUp() override { capturer_.reset(ScreenCapturer::Create()); } |
| 42 | 42 |
| 43 rtc::scoped_ptr<ScreenCapturer> capturer_; | 43 std::unique_ptr<ScreenCapturer> capturer_; |
| 44 MockScreenCapturerCallback callback_; | 44 MockScreenCapturerCallback callback_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 void ScreenCapturerMacTest::CaptureDoneCallback1( | 47 void ScreenCapturerMacTest::CaptureDoneCallback1( |
| 48 DesktopFrame* frame) { | 48 DesktopFrame* frame) { |
| 49 rtc::scoped_ptr<DesktopFrame> owned_frame(frame); | 49 std::unique_ptr<DesktopFrame> owned_frame(frame); |
| 50 | 50 |
| 51 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( | 51 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( |
| 52 MacDesktopConfiguration::BottomLeftOrigin); | 52 MacDesktopConfiguration::BottomLeftOrigin); |
| 53 | 53 |
| 54 // Verify that the region contains full frame. | 54 // Verify that the region contains full frame. |
| 55 DesktopRegion::Iterator it(frame->updated_region()); | 55 DesktopRegion::Iterator it(frame->updated_region()); |
| 56 EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds)); | 56 EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ScreenCapturerMacTest::CaptureDoneCallback2( | 59 void ScreenCapturerMacTest::CaptureDoneCallback2( |
| 60 DesktopFrame* frame) { | 60 DesktopFrame* frame) { |
| 61 rtc::scoped_ptr<DesktopFrame> owned_frame(frame); | 61 std::unique_ptr<DesktopFrame> owned_frame(frame); |
| 62 | 62 |
| 63 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( | 63 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( |
| 64 MacDesktopConfiguration::BottomLeftOrigin); | 64 MacDesktopConfiguration::BottomLeftOrigin); |
| 65 int width = config.pixel_bounds.width(); | 65 int width = config.pixel_bounds.width(); |
| 66 int height = config.pixel_bounds.height(); | 66 int height = config.pixel_bounds.height(); |
| 67 | 67 |
| 68 EXPECT_EQ(width, frame->size().width()); | 68 EXPECT_EQ(width, frame->size().width()); |
| 69 EXPECT_EQ(height, frame->size().height()); | 69 EXPECT_EQ(height, frame->size().height()); |
| 70 EXPECT_TRUE(frame->data() != NULL); | 70 EXPECT_TRUE(frame->data() != NULL); |
| 71 // Depending on the capture method, the screen may be flipped or not, so | 71 // Depending on the capture method, the screen may be flipped or not, so |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 capturer_->Start(&callback_); | 84 capturer_->Start(&callback_); |
| 85 | 85 |
| 86 // Check that we get an initial full-screen updated. | 86 // Check that we get an initial full-screen updated. |
| 87 capturer_->Capture(DesktopRegion()); | 87 capturer_->Capture(DesktopRegion()); |
| 88 | 88 |
| 89 // Check that subsequent dirty rects are propagated correctly. | 89 // Check that subsequent dirty rects are propagated correctly. |
| 90 capturer_->Capture(DesktopRegion()); | 90 capturer_->Capture(DesktopRegion()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace webrtc | 93 } // namespace webrtc |
| OLD | NEW |