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

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

Issue 1090273006: Revert of VideoCapture: add support for GpuMemoryBuffer allocation and lifetime mgmt in VideoCaptureBufferPool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 using ::testing::_; 58 using ::testing::_;
59 using ::testing::SaveArg; 59 using ::testing::SaveArg;
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,
68 scoped_refptr<Buffer>(media::VideoPixelFormat format,
69 const gfx::Size& dimensions));
67 MOCK_METHOD9(OnIncomingCapturedYuvData, 70 MOCK_METHOD9(OnIncomingCapturedYuvData,
68 void(const uint8* y_data, 71 void (const uint8* y_data,
69 const uint8* u_data, 72 const uint8* u_data,
70 const uint8* v_data, 73 const uint8* v_data,
71 size_t y_stride, 74 size_t y_stride,
72 size_t u_stride, 75 size_t u_stride,
73 size_t v_stride, 76 size_t v_stride,
74 const VideoCaptureFormat& frame_format, 77 const VideoCaptureFormat& frame_format,
75 int clockwise_rotation, 78 int clockwise_rotation,
79 const base::TimeTicks& timestamp));
80 MOCK_METHOD3(OnIncomingCapturedVideoFrame,
81 void(const scoped_refptr<Buffer>& buffer,
82 const scoped_refptr<VideoFrame>& frame,
76 const base::TimeTicks& timestamp)); 83 const base::TimeTicks& timestamp));
77 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
78 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
79 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
80 MOCK_METHOD1(OnError, void(const std::string& reason)); 84 MOCK_METHOD1(OnError, void(const std::string& reason));
81 85
82 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) 86 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb)
83 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {} 87 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {}
84 88
85 void OnIncomingCapturedData(const uint8* data, 89 void OnIncomingCapturedData(const uint8* data,
86 int length, 90 int length,
87 const VideoCaptureFormat& format, 91 const VideoCaptureFormat& format,
88 int rotation, 92 int rotation,
89 const base::TimeTicks& timestamp) override { 93 const base::TimeTicks& timestamp) override {
90 ASSERT_GT(length, 0); 94 ASSERT_GT(length, 0);
91 ASSERT_TRUE(data != NULL); 95 ASSERT_TRUE(data != NULL);
92 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); 96 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format));
93 } 97 }
94 98
95 // Trampoline methods to workaround GMOCK problems with scoped_ptr<>.
96 scoped_ptr<Buffer> ReserveOutputBuffer(VideoPixelFormat format,
97 const gfx::Size& dimensions) override {
98 DoReserveOutputBuffer();
99 return scoped_ptr<Buffer>();
100 }
101 void OnIncomingCapturedBuffer(scoped_ptr<Buffer> buffer,
102 const VideoCaptureFormat& frame_format,
103 const base::TimeTicks& timestamp) override {
104 DoOnIncomingCapturedBuffer();
105 }
106 void OnIncomingCapturedVideoFrame(scoped_ptr<Buffer> buffer,
107 const scoped_refptr<VideoFrame>& frame,
108 const base::TimeTicks& timestamp) override {
109 DoOnIncomingCapturedVideoFrame();
110 }
111
112 private: 99 private:
113 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; 100 scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
114 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; 101 base::Callback<void(const VideoCaptureFormat&)> frame_cb_;
115 }; 102 };
116 103
117 class DeviceEnumerationListener : 104 class DeviceEnumerationListener :
118 public base::RefCounted<DeviceEnumerationListener> { 105 public base::RefCounted<DeviceEnumerationListener> {
119 public: 106 public:
120 MOCK_METHOD1(OnEnumeratedDevicesCallbackPtr, 107 MOCK_METHOD1(OnEnumeratedDevicesCallbackPtr,
121 void(VideoCaptureDevice::Names* names)); 108 void(VideoCaptureDevice::Names* names));
(...skipping 23 matching lines...) Expand all
145 device_enumeration_listener_ = new DeviceEnumerationListener(); 132 device_enumeration_listener_ = new DeviceEnumerationListener();
146 } 133 }
147 134
148 void SetUp() override { 135 void SetUp() override {
149 #if defined(OS_ANDROID) 136 #if defined(OS_ANDROID)
150 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice( 137 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice(
151 base::android::AttachCurrentThread()); 138 base::android::AttachCurrentThread());
152 #endif 139 #endif
153 EXPECT_CALL(*client_, OnIncomingCapturedYuvData(_,_,_,_,_,_,_,_,_)) 140 EXPECT_CALL(*client_, OnIncomingCapturedYuvData(_,_,_,_,_,_,_,_,_))
154 .Times(0); 141 .Times(0);
155 EXPECT_CALL(*client_, DoReserveOutputBuffer()).Times(0); 142 EXPECT_CALL(*client_, ReserveOutputBuffer(_,_)).Times(0);
156 EXPECT_CALL(*client_, DoOnIncomingCapturedBuffer()).Times(0); 143 EXPECT_CALL(*client_, OnIncomingCapturedVideoFrame(_,_,_)).Times(0);
157 EXPECT_CALL(*client_, DoOnIncomingCapturedVideoFrame()).Times(0);
158 } 144 }
159 145
160 void ResetWithNewClient() { 146 void ResetWithNewClient() {
161 client_.reset(new MockClient(base::Bind( 147 client_.reset(new MockClient(base::Bind(
162 &VideoCaptureDeviceTest::OnFrameCaptured, base::Unretained(this)))); 148 &VideoCaptureDeviceTest::OnFrameCaptured, base::Unretained(this))));
163 } 149 }
164 150
165 void OnFrameCaptured(const VideoCaptureFormat& format) { 151 void OnFrameCaptured(const VideoCaptureFormat& format) {
166 last_format_ = format; 152 last_format_ = format;
167 run_loop_->QuitClosure().Run(); 153 run_loop_->QuitClosure().Run();
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // Use PIXEL_FORMAT_MAX to iterate all device names for testing 441 // Use PIXEL_FORMAT_MAX to iterate all device names for testing
456 // GetDeviceSupportedFormats(). 442 // GetDeviceSupportedFormats().
457 scoped_ptr<VideoCaptureDevice::Name> name = 443 scoped_ptr<VideoCaptureDevice::Name> name =
458 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); 444 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX);
459 // 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
460 // since we cannot forecast the hardware capabilities. 446 // since we cannot forecast the hardware capabilities.
461 ASSERT_FALSE(name); 447 ASSERT_FALSE(name);
462 } 448 }
463 449
464 }; // 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