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 a3cf6d93ccb39d1d20a8bbf2bd3342ff6c3e3a03..e2323c1747ee33b6fba11ce805c59f4617f3bedb 100644 |
--- a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc |
+++ b/webrtc/modules/desktop_capture/screen_capturer_unittest.cc |
@@ -28,8 +28,6 @@ namespace webrtc { |
class ScreenCapturerTest : public testing::Test { |
public: |
- SharedMemory* CreateSharedMemory(size_t size); |
- |
void SetUp() override { |
capturer_.reset( |
ScreenCapturer::Create(DesktopCaptureOptions::CreateDefault())); |
@@ -54,9 +52,18 @@ class FakeSharedMemory : public SharedMemory { |
RTC_DISALLOW_COPY_AND_ASSIGN(FakeSharedMemory); |
}; |
-SharedMemory* ScreenCapturerTest::CreateSharedMemory(size_t size) { |
- return new FakeSharedMemory(new char[size], size); |
-} |
+class FakeSharedMemoryFactory : public SharedMemoryFactory { |
+ public: |
+ FakeSharedMemoryFactory() {} |
+ ~FakeSharedMemoryFactory() override {} |
+ |
+ rtc::scoped_ptr<SharedMemory> CreateSharedMemory(size_t size) override { |
+ return rtc_make_scoped_ptr(new FakeSharedMemory(new char[size], size)) |
+ } |
+ |
+ private: |
+ RTC_DISALLOW_COPY_AND_ASSIGN(FakeSharedMemoryFactory); |
+}; |
TEST_F(ScreenCapturerTest, GetScreenListAndSelectScreen) { |
webrtc::ScreenCapturer::ScreenList screens; |
@@ -77,10 +84,6 @@ TEST_F(ScreenCapturerTest, Capture) { |
EXPECT_CALL(callback_, OnCaptureCompleted(_)) |
.WillOnce(SaveArg<0>(&frame)); |
- EXPECT_CALL(callback_, CreateSharedMemory(_)) |
- .Times(AnyNumber()) |
- .WillRepeatedly(Return(static_cast<SharedMemory*>(NULL))); |
- |
capturer_->Start(&callback_); |
capturer_->Capture(DesktopRegion()); |
@@ -109,11 +112,9 @@ TEST_F(ScreenCapturerTest, UseSharedBuffers) { |
EXPECT_CALL(callback_, OnCaptureCompleted(_)) |
.WillOnce(SaveArg<0>(&frame)); |
- EXPECT_CALL(callback_, CreateSharedMemory(_)) |
- .Times(AnyNumber()) |
- .WillRepeatedly(Invoke(this, &ScreenCapturerTest::CreateSharedMemory)); |
- |
capturer_->Start(&callback_); |
+ capturer_->SetSharedMemoryFactory( |
+ rtc_make_scoped_ptr(new FakeSharedMemoryFactory())); |
capturer_->Capture(DesktopRegion()); |
ASSERT_TRUE(frame); |