| Index: webrtc/modules/desktop_capture/screen_capturer_mock_objects.h
|
| diff --git a/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h b/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h
|
| index 1f17e8c8be3e57b1caf53c5fe38d169ff5602708..1e68e6003d94d2dc2b510c065ef9136d62e02802 100644
|
| --- a/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h
|
| +++ b/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h
|
| @@ -11,23 +11,82 @@
|
| #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_
|
| #define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_
|
|
|
| +#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
| +
|
| +#include <memory>
|
| +
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "webrtc/base/constructormagic.h"
|
| -#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
| +#include "webrtc/modules/desktop_capture/desktop_geometry.h"
|
| +#include "webrtc/modules/desktop_capture/desktop_region.h"
|
| +#include "webrtc/modules/desktop_capture/shared_memory.h"
|
|
|
| namespace webrtc {
|
|
|
| class MockScreenCapturer : public ScreenCapturer {
|
| public:
|
| - MockScreenCapturer() {}
|
| - virtual ~MockScreenCapturer() {}
|
| + MockScreenCapturer();
|
| + // TODO(zijiehe): Use override instead of virtual for overrided functions,
|
| + // once http://crbug.com/428099 has been addressed.
|
| + virtual ~MockScreenCapturer();
|
| +
|
| + MOCK_METHOD1(Start, void(Callback*));
|
| + MOCK_METHOD1(Capture, void(const DesktopRegion&));
|
| + MOCK_METHOD1(GetScreenList, bool(ScreenList*));
|
| + MOCK_METHOD1(SelectScreen, bool(ScreenId));
|
| +
|
| + // MOCK_METHOD* cannot accept std::unique_ptr as parameter.
|
| + virtual void SetSharedMemoryFactory(
|
| + std::unique_ptr<SharedMemoryFactory> shared_memory_factory);
|
| +
|
| + // The size of the frame which will be returned in next Capture() callback.
|
| + DesktopSize* size() { return &size_; }
|
|
|
| - MOCK_METHOD1(Start, void(Callback* callback));
|
| - MOCK_METHOD1(Capture, void(const DesktopRegion& region));
|
| - MOCK_METHOD1(GetScreenList, bool(ScreenList* screens));
|
| - MOCK_METHOD1(SelectScreen, bool(ScreenId id));
|
| + // The dirty regions of the frame which will be returned in next Capture()
|
| + // callback. MockScreenCapturer will return a white frame, with black in the
|
| + // dirty_region_. Each Capture() function call with return_frame_ as true will
|
| + // consume dirty_region_.
|
| + DesktopRegion* dirty_region() { return &dirty_region_; }
|
| +
|
| + // The result which will be returned in next Capture() callback.
|
| + Result* result() { return &result_; }
|
| +
|
| + // Decides whether MockScreenCapturer returns a frame in next Capture()
|
| + // callback. If return_frame_ is true, MockScreenCapturer will create a frame
|
| + // according to both size_ and dirty_region_.
|
| + bool* return_frame() { return &return_frame_; }
|
| +
|
| + // Decides whether MockScreenCapturer returns a frame with dirty regions.
|
| + // MockScreenCapturer will keep DesktopFrame::dirty_region() empty if this
|
| + // field is false.
|
| + bool* provide_dirty_region_hints() { return &provide_dirty_region_hints_; }
|
| +
|
| + // Decides whether MockScreenCapturer randomly enlarges dirty regions in the
|
| + // DesktopFrame. Set this field to true to simulate an inaccurate dirty
|
| + // regions' return from OS APIs.
|
| + bool* enlarge_dirty_region() { return &enlarge_dirty_region_; }
|
| +
|
| + // The range to enlarge a dirty region if |enlarge_dirty_region_| is true.
|
| + // This field cannot be less than or equal to zero.
|
| + int* enlarge_range() { return &enlarge_range_; }
|
| +
|
| + // Decides whether MockScreenCapturer randomly add some dirty regions in the
|
| + // DesktopFrame. Set this field to true to simulate an
|
| + // inaccurate dirty regions' return from OS APIs.
|
| + bool* random_dirty_region() { return &random_dirty_region_; }
|
|
|
| private:
|
| + Callback* callback_;
|
| + std::unique_ptr<SharedMemoryFactory> shared_memory_factory_;
|
| + DesktopSize size_;
|
| + DesktopRegion dirty_region_;
|
| + Result result_;
|
| + bool return_frame_;
|
| + bool provide_dirty_region_hints_;
|
| + bool enlarge_dirty_region_;
|
| + int enlarge_range_;
|
| + bool random_dirty_region_;
|
| +
|
| RTC_DISALLOW_COPY_AND_ASSIGN(MockScreenCapturer);
|
| };
|
|
|
|
|