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

Unified Diff: webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc

Issue 1988783003: 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc
diff --git a/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc b/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc
index 815c7f53afed130259803862731716836b99002a..47e721999666f1d0bbf96c8ce059426c0f563409 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc
+++ b/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc
@@ -32,11 +32,13 @@ namespace webrtc {
class ScreenCapturerMacTest : public testing::Test {
public:
// Verifies that the whole screen is initially dirty.
- void CaptureDoneCallback1(DesktopFrame* frame);
+ void CaptureDoneCallback1(DesktopCapturer::Result result,
+ std::unique_ptr<DesktopFrame>* frame);
// Verifies that a rectangle explicitly marked as dirty is propagated
// correctly.
- void CaptureDoneCallback2(DesktopFrame* frame);
+ void CaptureDoneCallback2(DesktopCapturer::Result result,
+ std::unique_ptr<DesktopFrame>* frame);
protected:
void SetUp() override {
@@ -49,37 +51,40 @@ class ScreenCapturerMacTest : public testing::Test {
};
void ScreenCapturerMacTest::CaptureDoneCallback1(
- DesktopFrame* frame) {
- std::unique_ptr<DesktopFrame> owned_frame(frame);
+ DesktopCapturer::Result result,
+ std::unique_ptr<DesktopFrame>* frame) {
+ EXPECT_EQ(result, DesktopCapturer::Result::SUCCESS);
MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent(
MacDesktopConfiguration::BottomLeftOrigin);
// Verify that the region contains full frame.
- DesktopRegion::Iterator it(frame->updated_region());
+ DesktopRegion::Iterator it((*frame)->updated_region());
EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds));
}
void ScreenCapturerMacTest::CaptureDoneCallback2(
- DesktopFrame* frame) {
- std::unique_ptr<DesktopFrame> owned_frame(frame);
+ DesktopCapturer::Result result,
+ std::unique_ptr<DesktopFrame>* frame) {
+ EXPECT_EQ(result, DesktopCapturer::Result::SUCCESS);
MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent(
MacDesktopConfiguration::BottomLeftOrigin);
int width = config.pixel_bounds.width();
int height = config.pixel_bounds.height();
- EXPECT_EQ(width, frame->size().width());
- EXPECT_EQ(height, frame->size().height());
- EXPECT_TRUE(frame->data() != NULL);
+ EXPECT_EQ(width, (*frame)->size().width());
+ EXPECT_EQ(height, (*frame)->size().height());
+ EXPECT_TRUE((*frame)->data() != NULL);
// Depending on the capture method, the screen may be flipped or not, so
// the stride may be positive or negative.
EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width),
- abs(frame->stride()));
+ abs((*frame)->stride()));
}
TEST_F(ScreenCapturerMacTest, Capture) {
- EXPECT_CALL(callback_, OnCaptureCompleted(_))
+ EXPECT_CALL(callback_,
+ OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
.Times(2)
.WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback1))
.WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback2));
« 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