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

Side by Side Diff: media/video/capture/video_capture_device_unittest.cc

Issue 967793002: Linux Video Capture: Add V4L2VideoCaptureDelegate{Single,Multi}Plane. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: magjed@ comments Created 5 years, 9 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
« no previous file with comments | « media/video/capture/video_capture_device.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 namespace media { 61 namespace media {
62 62
63 namespace { 63 namespace {
64 64
65 class MockClient : public VideoCaptureDevice::Client { 65 class MockClient : public VideoCaptureDevice::Client {
66 public: 66 public:
67 MOCK_METHOD2(ReserveOutputBuffer, 67 MOCK_METHOD2(ReserveOutputBuffer,
68 scoped_refptr<Buffer>(VideoFrame::Format format, 68 scoped_refptr<Buffer>(VideoFrame::Format format,
69 const gfx::Size& dimensions)); 69 const gfx::Size& dimensions));
70 MOCK_METHOD9(OnIncomingCapturedYuvData,
71 void (const uint8* y_data,
72 const uint8* u_data,
73 const uint8* v_data,
74 size_t y_stride,
75 size_t u_stride,
76 size_t v_stride,
77 const VideoCaptureFormat& frame_format,
78 int clockwise_rotation,
79 const base::TimeTicks& timestamp));
70 MOCK_METHOD3(OnIncomingCapturedVideoFrame, 80 MOCK_METHOD3(OnIncomingCapturedVideoFrame,
71 void(const scoped_refptr<Buffer>& buffer, 81 void(const scoped_refptr<Buffer>& buffer,
72 const scoped_refptr<VideoFrame>& frame, 82 const scoped_refptr<VideoFrame>& frame,
73 const base::TimeTicks& timestamp)); 83 const base::TimeTicks& timestamp));
74 MOCK_METHOD1(OnError, void(const std::string& reason)); 84 MOCK_METHOD1(OnError, void(const std::string& reason));
75 85
76 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) 86 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb)
77 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {} 87 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {}
78 88
79 void OnIncomingCapturedData(const uint8* data, 89 void OnIncomingCapturedData(const uint8* data,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 video_capture_device_factory_(VideoCaptureDeviceFactory::CreateFactory( 130 video_capture_device_factory_(VideoCaptureDeviceFactory::CreateFactory(
121 base::MessageLoopProxy::current())) { 131 base::MessageLoopProxy::current())) {
122 device_enumeration_listener_ = new DeviceEnumerationListener(); 132 device_enumeration_listener_ = new DeviceEnumerationListener();
123 } 133 }
124 134
125 void SetUp() override { 135 void SetUp() override {
126 #if defined(OS_ANDROID) 136 #if defined(OS_ANDROID)
127 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice( 137 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice(
128 base::android::AttachCurrentThread()); 138 base::android::AttachCurrentThread());
129 #endif 139 #endif
140 EXPECT_CALL(*client_, OnIncomingCapturedYuvData(_,_,_,_,_,_,_,_,_))
141 .Times(0);
130 EXPECT_CALL(*client_, ReserveOutputBuffer(_,_)).Times(0); 142 EXPECT_CALL(*client_, ReserveOutputBuffer(_,_)).Times(0);
131 EXPECT_CALL(*client_, OnIncomingCapturedVideoFrame(_,_,_)).Times(0); 143 EXPECT_CALL(*client_, OnIncomingCapturedVideoFrame(_,_,_)).Times(0);
132 } 144 }
133 145
134 void ResetWithNewClient() { 146 void ResetWithNewClient() {
135 client_.reset(new MockClient(base::Bind( 147 client_.reset(new MockClient(base::Bind(
136 &VideoCaptureDeviceTest::OnFrameCaptured, base::Unretained(this)))); 148 &VideoCaptureDeviceTest::OnFrameCaptured, base::Unretained(this))));
137 } 149 }
138 150
139 void OnFrameCaptured(const VideoCaptureFormat& format) { 151 void OnFrameCaptured(const VideoCaptureFormat& format) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 video_capture_device_factory_->GetDeviceSupportedFormats( 184 video_capture_device_factory_->GetDeviceSupportedFormats(
173 names_iterator, 185 names_iterator,
174 &supported_formats); 186 &supported_formats);
175 for (const auto& formats_iterator : supported_formats) { 187 for (const auto& formats_iterator : supported_formats) {
176 if (formats_iterator.pixel_format == pixel_format) { 188 if (formats_iterator.pixel_format == pixel_format) {
177 return scoped_ptr<VideoCaptureDevice::Name>( 189 return scoped_ptr<VideoCaptureDevice::Name>(
178 new VideoCaptureDevice::Name(names_iterator)); 190 new VideoCaptureDevice::Name(names_iterator));
179 } 191 }
180 } 192 }
181 } 193 }
182 DVLOG(1) << "No camera can capture the format: " << pixel_format; 194 DVLOG_IF(1, pixel_format != PIXEL_FORMAT_MAX) << "No camera can capture the"
195 << " format: " << VideoCaptureFormat::PixelFormatToString(pixel_format);
183 return scoped_ptr<VideoCaptureDevice::Name>(); 196 return scoped_ptr<VideoCaptureDevice::Name>();
184 } 197 }
185 198
186 #if defined(OS_WIN) 199 #if defined(OS_WIN)
187 base::win::ScopedCOMInitializer initialize_com_; 200 base::win::ScopedCOMInitializer initialize_com_;
188 #endif 201 #endif
189 scoped_ptr<VideoCaptureDevice::Names> names_; 202 scoped_ptr<VideoCaptureDevice::Names> names_;
190 scoped_ptr<base::MessageLoop> loop_; 203 scoped_ptr<base::MessageLoop> loop_;
191 scoped_ptr<base::RunLoop> run_loop_; 204 scoped_ptr<base::RunLoop> run_loop_;
192 scoped_ptr<MockClient> client_; 205 scoped_ptr<MockClient> client_;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // Use PIXEL_FORMAT_MAX to iterate all device names for testing 441 // Use PIXEL_FORMAT_MAX to iterate all device names for testing
429 // GetDeviceSupportedFormats(). 442 // GetDeviceSupportedFormats().
430 scoped_ptr<VideoCaptureDevice::Name> name = 443 scoped_ptr<VideoCaptureDevice::Name> name =
431 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); 444 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX);
432 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here 445 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here
433 // since we cannot forecast the hardware capabilities. 446 // since we cannot forecast the hardware capabilities.
434 ASSERT_FALSE(name); 447 ASSERT_FALSE(name);
435 } 448 }
436 449
437 }; // namespace media 450 }; // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/video_capture_device.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698