Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc

Issue 2030333003: Revert of Use std::unique_ptr<> to pass frame ownership in DesktopCapturer impls. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(DesktopCapturer::Result result, 35 void CaptureDoneCallback1(DesktopFrame* frame);
36 std::unique_ptr<DesktopFrame>* frame);
37 36
38 // Verifies that a rectangle explicitly marked as dirty is propagated 37 // Verifies that a rectangle explicitly marked as dirty is propagated
39 // correctly. 38 // correctly.
40 void CaptureDoneCallback2(DesktopCapturer::Result result, 39 void CaptureDoneCallback2(DesktopFrame* frame);
41 std::unique_ptr<DesktopFrame>* frame);
42 40
43 protected: 41 protected:
44 void SetUp() override { 42 void SetUp() override {
45 capturer_.reset( 43 capturer_.reset(
46 ScreenCapturer::Create(DesktopCaptureOptions::CreateDefault())); 44 ScreenCapturer::Create(DesktopCaptureOptions::CreateDefault()));
47 } 45 }
48 46
49 std::unique_ptr<ScreenCapturer> capturer_; 47 std::unique_ptr<ScreenCapturer> capturer_;
50 MockScreenCapturerCallback callback_; 48 MockScreenCapturerCallback callback_;
51 }; 49 };
52 50
53 void ScreenCapturerMacTest::CaptureDoneCallback1( 51 void ScreenCapturerMacTest::CaptureDoneCallback1(
54 DesktopCapturer::Result result, 52 DesktopFrame* frame) {
55 std::unique_ptr<DesktopFrame>* frame) { 53 std::unique_ptr<DesktopFrame> owned_frame(frame);
56 EXPECT_EQ(result, DesktopCapturer::Result::SUCCESS);
57 54
58 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( 55 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent(
59 MacDesktopConfiguration::BottomLeftOrigin); 56 MacDesktopConfiguration::BottomLeftOrigin);
60 57
61 // Verify that the region contains full frame. 58 // Verify that the region contains full frame.
62 DesktopRegion::Iterator it((*frame)->updated_region()); 59 DesktopRegion::Iterator it(frame->updated_region());
63 EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds)); 60 EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds));
64 } 61 }
65 62
66 void ScreenCapturerMacTest::CaptureDoneCallback2( 63 void ScreenCapturerMacTest::CaptureDoneCallback2(
67 DesktopCapturer::Result result, 64 DesktopFrame* frame) {
68 std::unique_ptr<DesktopFrame>* frame) { 65 std::unique_ptr<DesktopFrame> owned_frame(frame);
69 EXPECT_EQ(result, DesktopCapturer::Result::SUCCESS);
70 66
71 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( 67 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent(
72 MacDesktopConfiguration::BottomLeftOrigin); 68 MacDesktopConfiguration::BottomLeftOrigin);
73 int width = config.pixel_bounds.width(); 69 int width = config.pixel_bounds.width();
74 int height = config.pixel_bounds.height(); 70 int height = config.pixel_bounds.height();
75 71
76 EXPECT_EQ(width, (*frame)->size().width()); 72 EXPECT_EQ(width, frame->size().width());
77 EXPECT_EQ(height, (*frame)->size().height()); 73 EXPECT_EQ(height, frame->size().height());
78 EXPECT_TRUE((*frame)->data() != NULL); 74 EXPECT_TRUE(frame->data() != NULL);
79 // Depending on the capture method, the screen may be flipped or not, so 75 // Depending on the capture method, the screen may be flipped or not, so
80 // the stride may be positive or negative. 76 // the stride may be positive or negative.
81 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), 77 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width),
82 abs((*frame)->stride())); 78 abs(frame->stride()));
83 } 79 }
84 80
85 TEST_F(ScreenCapturerMacTest, Capture) { 81 TEST_F(ScreenCapturerMacTest, Capture) {
86 EXPECT_CALL(callback_, 82 EXPECT_CALL(callback_, OnCaptureCompleted(_))
87 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
88 .Times(2) 83 .Times(2)
89 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback1)) 84 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback1))
90 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback2)); 85 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback2));
91 86
92 SCOPED_TRACE(""); 87 SCOPED_TRACE("");
93 capturer_->Start(&callback_); 88 capturer_->Start(&callback_);
94 89
95 // Check that we get an initial full-screen updated. 90 // Check that we get an initial full-screen updated.
96 capturer_->Capture(DesktopRegion()); 91 capturer_->Capture(DesktopRegion());
97 92
98 // Check that subsequent dirty rects are propagated correctly. 93 // Check that subsequent dirty rects are propagated correctly.
99 capturer_->Capture(DesktopRegion()); 94 capturer_->Capture(DesktopRegion());
100 } 95 }
101 96
102 } // namespace webrtc 97 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/screen_capturer_mac.mm ('k') | webrtc/modules/desktop_capture/screen_capturer_mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698