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

Unified 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: address chfremer's comments 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 side-by-side diff with in-line comments
Download patch
Index: media/capture/video/chromeos/mock_video_capture_client.h
diff --git a/media/capture/video/chromeos/mock_video_capture_client.h b/media/capture/video/chromeos/mock_video_capture_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..dfccb5cc3d326e04feb3195dbefb1476b24696d6
--- /dev/null
+++ b/media/capture/video/chromeos/mock_video_capture_client.h
@@ -0,0 +1,106 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_CAPTURE_VIDEO_CHROMEOS_MOCK_VIDEO_CAPTURE_CLIENT_H_
+#define MEDIA_CAPTURE_VIDEO_CHROMEOS_MOCK_VIDEO_CAPTURE_CLIENT_H_
+
+#include "media/capture/video/video_capture_device.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+using testing::_;
+using testing::Invoke;
+
+namespace media {
+namespace unittest_internal {
+
+class MockVideoCaptureClient : public VideoCaptureDevice::Client {
+ public:
+ MOCK_METHOD0(DoReserveOutputBuffer, void(void));
+ MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
+ MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
+ MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void));
+ MOCK_METHOD2(OnError,
+ void(const tracked_objects::Location& from_here,
+ const std::string& reason));
+ MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void));
+ MOCK_METHOD0(OnStarted, void(void));
+
+ explicit MockVideoCaptureClient() {
+ ON_CALL(*this, OnError(_, _))
+ .WillByDefault(Invoke(this, &MockVideoCaptureClient::DumpError));
+ }
+
+ ~MockVideoCaptureClient() {
+ if (quit_cb_) {
+ std::move(quit_cb_).Run();
+ }
+ }
+
+ void SetFrameCb(base::OnceClosure frame_cb) {
+ frame_cb_ = std::move(frame_cb);
+ }
+
+ void SetQuitCb(base::OnceClosure quit_cb) { quit_cb_ = std::move(quit_cb); }
+
+ void DumpError(const tracked_objects::Location& location,
+ const std::string& message) {
+ DPLOG(ERROR) << location.ToString() << " " << message;
+ }
+
+ void OnIncomingCapturedData(const uint8_t* data,
+ int length,
+ const VideoCaptureFormat& format,
+ int rotation,
+ base::TimeTicks reference_time,
+ base::TimeDelta timestamp,
+ int frame_feedback_id) override {
+ ASSERT_GT(length, 0);
+ ASSERT_TRUE(data);
+ if (frame_cb_) {
+ std::move(frame_cb_).Run();
+ }
+ }
+
+ // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>.
+ Buffer ReserveOutputBuffer(const gfx::Size& dimensions,
+ media::VideoPixelFormat format,
+ media::VideoPixelStorage storage,
+ int frame_feedback_id) override {
+ DoReserveOutputBuffer();
+ NOTREACHED() << "This should never be called";
+ return Buffer();
+ }
+ void OnIncomingCapturedBuffer(Buffer buffer,
+ const VideoCaptureFormat& format,
+ base::TimeTicks reference_time,
+ base::TimeDelta timestamp) override {
+ DoOnIncomingCapturedBuffer();
+ }
+ void OnIncomingCapturedBufferExt(
+ Buffer buffer,
+ const VideoCaptureFormat& format,
+ base::TimeTicks reference_time,
+ base::TimeDelta timestamp,
+ gfx::Rect visible_rect,
+ const VideoFrameMetadata& additional_metadata) override {
+ DoOnIncomingCapturedVideoFrame();
+ }
+ Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions,
+ media::VideoPixelFormat format,
+ media::VideoPixelStorage storage,
+ int frame_feedback_id) {
+ DoResurrectLastOutputBuffer();
+ NOTREACHED() << "This should never be called";
+ return Buffer();
+ }
+
+ private:
+ base::OnceClosure frame_cb_;
+ base::OnceClosure quit_cb_;
+};
+
+} // namespace unittest_internal
+} // namespace media
+
+#endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_MOCK_VIDEO_CAPTURE_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698