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

Side by Side Diff: media/capture/video/chromeos/mock_video_capture_client.h

Issue 2837273004: media: add video capture device for ARC++ camera HAL v3 (Closed)
Patch Set: restore patch set 24 Created 3 years, 6 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CAPTURE_VIDEO_CHROMEOS_MOCK_VIDEO_CAPTURE_CLIENT_H_
6 #define MEDIA_CAPTURE_VIDEO_CHROMEOS_MOCK_VIDEO_CAPTURE_CLIENT_H_
7
8 #include "media/capture/video/video_capture_device.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10
11 using testing::_;
12 using testing::Invoke;
13
14 namespace media {
15 namespace unittest_internal {
16
17 class MockVideoCaptureClient : public VideoCaptureDevice::Client {
18 public:
19 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
20 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
21 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
22 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void));
23 MOCK_METHOD2(OnError,
24 void(const tracked_objects::Location& from_here,
25 const std::string& reason));
26 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void));
27 MOCK_METHOD0(OnStarted, void(void));
28
29 explicit MockVideoCaptureClient() {
30 ON_CALL(*this, OnError(_, _))
31 .WillByDefault(Invoke(this, &MockVideoCaptureClient::DumpError));
32 }
33
34 ~MockVideoCaptureClient() {
35 if (quit_cb_) {
36 std::move(quit_cb_).Run();
37 }
38 }
39
40 void SetFrameCb(base::OnceClosure frame_cb) {
41 frame_cb_ = std::move(frame_cb);
42 }
43
44 void SetQuitCb(base::OnceClosure quit_cb) { quit_cb_ = std::move(quit_cb); }
45
46 void DumpError(const tracked_objects::Location& location,
47 const std::string& message) {
48 DPLOG(ERROR) << location.ToString() << " " << message;
49 }
50
51 void OnIncomingCapturedData(const uint8_t* data,
52 int length,
53 const VideoCaptureFormat& format,
54 int rotation,
55 base::TimeTicks reference_time,
56 base::TimeDelta timestamp,
57 int frame_feedback_id) override {
58 ASSERT_GT(length, 0);
59 ASSERT_TRUE(data);
60 if (frame_cb_) {
61 std::move(frame_cb_).Run();
62 }
63 }
64
65 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>.
66 Buffer ReserveOutputBuffer(const gfx::Size& dimensions,
67 media::VideoPixelFormat format,
68 media::VideoPixelStorage storage,
69 int frame_feedback_id) override {
70 DoReserveOutputBuffer();
71 NOTREACHED() << "This should never be called";
72 return Buffer();
73 }
74 void OnIncomingCapturedBuffer(Buffer buffer,
75 const VideoCaptureFormat& format,
76 base::TimeTicks reference_time,
77 base::TimeDelta timestamp) override {
78 DoOnIncomingCapturedBuffer();
79 }
80 void OnIncomingCapturedBufferExt(
81 Buffer buffer,
82 const VideoCaptureFormat& format,
83 base::TimeTicks reference_time,
84 base::TimeDelta timestamp,
85 gfx::Rect visible_rect,
86 const VideoFrameMetadata& additional_metadata) override {
87 DoOnIncomingCapturedVideoFrame();
88 }
89 Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions,
90 media::VideoPixelFormat format,
91 media::VideoPixelStorage storage,
92 int frame_feedback_id) {
93 DoResurrectLastOutputBuffer();
94 NOTREACHED() << "This should never be called";
95 return Buffer();
96 }
97
98 private:
99 base::OnceClosure frame_cb_;
100 base::OnceClosure quit_cb_;
101 };
102
103 } // namespace unittest_internal
104 } // namespace media
105
106 #endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_MOCK_VIDEO_CAPTURE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698