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

Side by Side Diff: webrtc/modules/desktop_capture/screen_capturer_mock_objects.h

Issue 2202443002: [WebRTC] Add ScreenCapturerDifferWrapper to share Differ across ScreenCapturers (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_ 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_ 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_
13 13
14 #include "webrtc/modules/desktop_capture/screen_capturer.h"
15
16 #include <memory>
17
14 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
15 #include "webrtc/base/constructormagic.h" 19 #include "webrtc/base/constructormagic.h"
16 #include "webrtc/modules/desktop_capture/screen_capturer.h" 20 #include "webrtc/modules/desktop_capture/desktop_geometry.h"
21 #include "webrtc/modules/desktop_capture/desktop_region.h"
22 #include "webrtc/modules/desktop_capture/shared_memory.h"
17 23
18 namespace webrtc { 24 namespace webrtc {
19 25
20 class MockScreenCapturer : public ScreenCapturer { 26 class MockScreenCapturer : public ScreenCapturer {
Sergey Ulanov 2016/08/03 23:19:12 This class is not used anywhere right now. I sugge
Hzj_jie 2016/08/04 02:28:07 Yes, I have found fake_desktop_capturer in remotin
Sergey Ulanov 2016/08/12 05:25:50 Canonical way to use gmock is to have a virtual in
Hzj_jie 2016/08/15 00:38:06 Then I would rather choose the second one, as the
21 public: 27 public:
22 MockScreenCapturer() {} 28 MockScreenCapturer();
23 virtual ~MockScreenCapturer() {} 29 // TODO(zijiehe): Use override instead of virtual for overrided functions,
30 // once http://crbug.com/428099 has been addressed.
31 virtual ~MockScreenCapturer();
24 32
25 MOCK_METHOD1(Start, void(Callback* callback)); 33 MOCK_METHOD1(Start, void(Callback*));
26 MOCK_METHOD1(Capture, void(const DesktopRegion& region)); 34 MOCK_METHOD1(Capture, void(const DesktopRegion&));
27 MOCK_METHOD1(GetScreenList, bool(ScreenList* screens)); 35 MOCK_METHOD1(GetScreenList, bool(ScreenList*));
28 MOCK_METHOD1(SelectScreen, bool(ScreenId id)); 36 MOCK_METHOD1(SelectScreen, bool(ScreenId));
37
38 // MOCK_METHOD* cannot accept std::unique_ptr as parameter.
39 virtual void SetSharedMemoryFactory(
40 std::unique_ptr<SharedMemoryFactory> shared_memory_factory);
41
42 // The size of the frame which will be returned in next Capture() callback.
43 DesktopSize* size() {
44 return &size_;
45 }
46
47 // The dirty region of the frame which will be returned in next Capture()
48 // callback. MockScreenCapturer will return a white frame, with black in the
49 // dirty_region_. Each Capture() function call with return_frame_ as true will
50 // consume dirty_region_.
51 DesktopRegion* dirty_region() {
Sergey Ulanov 2016/08/12 05:25:50 call it updated_region or next_updated_region for
52 return &dirty_region_;
53 }
54
55 // The result which will be returned in next Capture() callback.
56 Result* result() {
57 return &result_;
58 }
59
60 // Decides whether MockScreenCapturer returns a frame in next Capture()
61 // callback. If return_frame_ is true, MockScreenCapturer will create a frame
62 // according to both size_ and dirty_region_.
63 bool* return_frame() {
Sergey Ulanov 2016/08/03 23:19:12 why do you need return bool pointer?
Hzj_jie 2016/08/04 02:28:07 1. According to the coding style, we cannot return
Sergey Ulanov 2016/08/12 05:25:50 What's wrong with [set_]dirty_region()? You could
64 return &return_frame_;
65 }
66
67 // Decides whether MockScreenCapturer returns a frame with dirty_region.
68 // MockScreenCapturer will keep DesktopFrame::dirty_region() empty if this
69 // field is false.
70 bool* provide_dirty_region_hints() {
71 return &provide_dirty_region_hints_;
72 }
73
74 // Decides whether MockScreenCapturer randomly enlarges dirty_region in the
75 // DesktopFrame. Setting this field to true to simulate an inaccurate dirty
76 // region from OS APIs.
77 bool* enlarge_dirty_region() {
78 return &enlarge_dirty_region_;
79 }
29 80
30 private: 81 private:
82 Callback* callback_;
83 std::unique_ptr<SharedMemoryFactory> shared_memory_factory_;
84 DesktopSize size_;
85 DesktopRegion dirty_region_;
86 Result result_;
87 bool return_frame_;
88 bool provide_dirty_region_hints_;
89 bool enlarge_dirty_region_;
90
31 RTC_DISALLOW_COPY_AND_ASSIGN(MockScreenCapturer); 91 RTC_DISALLOW_COPY_AND_ASSIGN(MockScreenCapturer);
32 }; 92 };
33 93
34 class MockScreenCapturerCallback : public ScreenCapturer::Callback { 94 class MockScreenCapturerCallback : public ScreenCapturer::Callback {
35 public: 95 public:
36 MockScreenCapturerCallback() {} 96 MockScreenCapturerCallback() {}
37 virtual ~MockScreenCapturerCallback() {} 97 virtual ~MockScreenCapturerCallback() {}
38 98
39 MOCK_METHOD2(OnCaptureResultPtr, 99 MOCK_METHOD2(OnCaptureResultPtr,
40 void(DesktopCapturer::Result result, 100 void(DesktopCapturer::Result result,
41 std::unique_ptr<DesktopFrame>* frame)); 101 std::unique_ptr<DesktopFrame>* frame));
42 void OnCaptureResult(DesktopCapturer::Result result, 102 void OnCaptureResult(DesktopCapturer::Result result,
43 std::unique_ptr<DesktopFrame> frame) override { 103 std::unique_ptr<DesktopFrame> frame) override {
44 OnCaptureResultPtr(result, &frame); 104 OnCaptureResultPtr(result, &frame);
45 } 105 }
46 106
47 private: 107 private:
48 RTC_DISALLOW_COPY_AND_ASSIGN(MockScreenCapturerCallback); 108 RTC_DISALLOW_COPY_AND_ASSIGN(MockScreenCapturerCallback);
49 }; 109 };
50 110
51 } // namespace webrtc 111 } // namespace webrtc
52 112
53 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_ 113 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698