Index: webrtc/modules/desktop_capture/screen_capturer_unittest.cc |
diff --git a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc b/webrtc/modules/desktop_capture/screen_capturer_unittest.cc |
index bc87ed3eba8ae5d67aa8d768cbeb1560e56df3d3..4d7799cc686ba54966f32e8571c976f02257b56f 100644 |
--- a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc |
+++ b/webrtc/modules/desktop_capture/screen_capturer_unittest.cc |
@@ -23,7 +23,6 @@ |
using ::testing::_; |
using ::testing::AnyNumber; |
using ::testing::Return; |
-using ::testing::SaveArg; |
const int kTestSharedMemoryId = 123; |
@@ -69,6 +68,10 @@ class FakeSharedMemoryFactory : public SharedMemoryFactory { |
RTC_DISALLOW_COPY_AND_ASSIGN(FakeSharedMemoryFactory); |
}; |
+ACTION_P(SaveUniquePtrArg, dest) { |
+ *dest = std::move(*arg1); |
+} |
+ |
TEST_F(ScreenCapturerTest, GetScreenListAndSelectScreen) { |
webrtc::ScreenCapturer::ScreenList screens; |
EXPECT_TRUE(capturer_->GetScreenList(&screens)); |
@@ -84,9 +87,10 @@ TEST_F(ScreenCapturerTest, StartCapturer) { |
TEST_F(ScreenCapturerTest, Capture) { |
// Assume that Start() treats the screen as invalid initially. |
- DesktopFrame* frame = NULL; |
- EXPECT_CALL(callback_, OnCaptureCompleted(_)) |
- .WillOnce(SaveArg<0>(&frame)); |
+ std::unique_ptr<DesktopFrame> frame; |
+ EXPECT_CALL(callback_, |
+ OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
+ .WillOnce(SaveUniquePtrArg(&frame)); |
capturer_->Start(&callback_); |
capturer_->Capture(DesktopRegion()); |
@@ -105,16 +109,15 @@ TEST_F(ScreenCapturerTest, Capture) { |
EXPECT_TRUE(it.rect().equals(DesktopRect::MakeSize(frame->size()))); |
it.Advance(); |
EXPECT_TRUE(it.IsAtEnd()); |
- |
- delete frame; |
} |
#if defined(WEBRTC_WIN) |
TEST_F(ScreenCapturerTest, UseSharedBuffers) { |
- DesktopFrame* frame = NULL; |
- EXPECT_CALL(callback_, OnCaptureCompleted(_)) |
- .WillOnce(SaveArg<0>(&frame)); |
+ std::unique_ptr<DesktopFrame> frame; |
+ EXPECT_CALL(callback_, |
+ OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
+ .WillOnce(SaveUniquePtrArg(&frame)); |
capturer_->Start(&callback_); |
capturer_->SetSharedMemoryFactory( |
@@ -124,8 +127,6 @@ TEST_F(ScreenCapturerTest, UseSharedBuffers) { |
ASSERT_TRUE(frame); |
ASSERT_TRUE(frame->shared_memory()); |
EXPECT_EQ(frame->shared_memory()->id(), kTestSharedMemoryId); |
- |
- delete frame; |
} |
TEST_F(ScreenCapturerTest, UseMagnifier) { |
@@ -133,13 +134,14 @@ TEST_F(ScreenCapturerTest, UseMagnifier) { |
options.set_allow_use_magnification_api(true); |
capturer_.reset(ScreenCapturer::Create(options)); |
- DesktopFrame* frame = NULL; |
- EXPECT_CALL(callback_, OnCaptureCompleted(_)).WillOnce(SaveArg<0>(&frame)); |
+ std::unique_ptr<DesktopFrame> frame; |
+ EXPECT_CALL(callback_, |
+ OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
+ .WillOnce(SaveUniquePtrArg(&frame)); |
capturer_->Start(&callback_); |
capturer_->Capture(DesktopRegion()); |
ASSERT_TRUE(frame); |
- delete frame; |
} |
#endif // defined(WEBRTC_WIN) |