diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index 18f8ba11da..d16c93d952 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -102,7 +102,10 @@ if (rtc_include_tests) { ] if (rtc_desktop_capture_supported) { - deps += [ "desktop_capture:screen_drawer" ] + deps += [ + "desktop_capture:desktop_capture_mock", + "desktop_capture:screen_drawer", + ] sources += [ "desktop_capture/screen_capturer_integration_test.cc", "desktop_capture/screen_drawer_unittest.cc", diff --git a/webrtc/modules/desktop_capture/BUILD.gn b/webrtc/modules/desktop_capture/BUILD.gn index ebf337d055..b43d905134 100644 --- a/webrtc/modules/desktop_capture/BUILD.gn +++ b/webrtc/modules/desktop_capture/BUILD.gn @@ -66,6 +66,7 @@ if (rtc_include_tests) { public_deps = [ ":desktop_capture", ":rgba_color", + "//testing/gmock", ] sources = [ @@ -73,6 +74,7 @@ if (rtc_include_tests) { "desktop_frame_generator.h", "fake_desktop_capturer.cc", "fake_desktop_capturer.h", + "mock_desktop_capturer_callback.cc", "mock_desktop_capturer_callback.h", "screen_capturer_mock_objects.h", ] diff --git a/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.cc b/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.cc new file mode 100644 index 0000000000..2a02e283b5 --- /dev/null +++ b/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.cc @@ -0,0 +1,23 @@ +/* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h" + +namespace webrtc { + +MockDesktopCapturerCallback::MockDesktopCapturerCallback() = default; +MockDesktopCapturerCallback::~MockDesktopCapturerCallback() = default; + +void MockDesktopCapturerCallback::OnCaptureResult( + DesktopCapturer::Result result, + std::unique_ptr frame) { + OnCaptureResultPtr(result, &frame); +} + +} // namespace webrtc diff --git a/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h b/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h index 3f67a9ef85..720075da54 100644 --- a/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h +++ b/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h @@ -10,11 +10,29 @@ #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_MOCK_DESKTOP_CAPTURER_CALLBACK_H_ #define WEBRTC_MODULES_DESKTOP_CAPTURE_MOCK_DESKTOP_CAPTURER_CALLBACK_H_ -#include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" +#include "webrtc/modules/desktop_capture/desktop_capturer.h" + +#include + +#include "webrtc/test/gmock.h" namespace webrtc { -// TODO(zijiehe): Remove MockScreenCapturerCallback. -class MockDesktopCapturerCallback : public MockScreenCapturerCallback {}; + +class MockDesktopCapturerCallback : public DesktopCapturer::Callback { + public: + MockDesktopCapturerCallback(); + ~MockDesktopCapturerCallback() override; + + MOCK_METHOD2(OnCaptureResultPtr, + void(DesktopCapturer::Result result, + std::unique_ptr* frame)); + void OnCaptureResult(DesktopCapturer::Result result, + std::unique_ptr frame) final; + + private: + RTC_DISALLOW_COPY_AND_ASSIGN(MockDesktopCapturerCallback); +}; + } // namespace webrtc #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_MOCK_DESKTOP_CAPTURER_CALLBACK_H_ diff --git a/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc b/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc index 1a1fb5b39c..7133a9ebbc 100644 --- a/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc +++ b/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc @@ -19,7 +19,7 @@ #include "webrtc/modules/desktop_capture/desktop_geometry.h" #include "webrtc/modules/desktop_capture/desktop_region.h" #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" -#include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" +#include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h" #include "webrtc/test/gtest.h" using ::testing::_; @@ -46,7 +46,7 @@ class ScreenCapturerMacTest : public testing::Test { } std::unique_ptr capturer_; - MockScreenCapturerCallback callback_; + MockDesktopCapturerCallback callback_; }; void ScreenCapturerMacTest::CaptureDoneCallback1( diff --git a/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h b/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h deleted file mode 100644 index eb650f62df..0000000000 --- a/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_ -#define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_ - -#include "webrtc/base/constructormagic.h" -#include "webrtc/modules/desktop_capture/desktop_capturer.h" -#include "webrtc/test/gmock.h" - -namespace webrtc { - -// Deprecated. -// Use webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h. -class MockScreenCapturerCallback : public DesktopCapturer::Callback { - public: - MockScreenCapturerCallback() {} - ~MockScreenCapturerCallback() override {} - - MOCK_METHOD2(OnCaptureResultPtr, - void(DesktopCapturer::Result result, - std::unique_ptr* frame)); - void OnCaptureResult(DesktopCapturer::Result result, - std::unique_ptr frame) override { - OnCaptureResultPtr(result, &frame); - } - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(MockScreenCapturerCallback); -}; - -} // namespace webrtc - -#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_ diff --git a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc b/webrtc/modules/desktop_capture/screen_capturer_unittest.cc index 99f4846416..81ca87a8e4 100644 --- a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc +++ b/webrtc/modules/desktop_capture/screen_capturer_unittest.cc @@ -16,7 +16,7 @@ #include "webrtc/modules/desktop_capture/desktop_capture_options.h" #include "webrtc/modules/desktop_capture/desktop_frame.h" #include "webrtc/modules/desktop_capture/desktop_region.h" -#include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" +#include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h" #include "webrtc/test/gmock.h" #include "webrtc/test/gtest.h" @@ -66,7 +66,7 @@ class ScreenCapturerTest : public testing::Test { #endif // defined(WEBRTC_WIN) std::unique_ptr capturer_; - MockScreenCapturerCallback callback_; + MockDesktopCapturerCallback callback_; }; class FakeSharedMemory : public SharedMemory {