OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <sys/fcntl.h> | 5 #include <sys/fcntl.h> |
6 #include <sys/ioctl.h> | 6 #include <sys/ioctl.h> |
7 | 7 |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 DoOnIncomingCapturedVideoFrame(); | 180 DoOnIncomingCapturedVideoFrame(); |
181 } | 181 } |
182 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); | 182 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); |
183 MOCK_METHOD4( | 183 MOCK_METHOD4( |
184 ResurrectLastOutputBuffer, | 184 ResurrectLastOutputBuffer, |
185 Buffer(const gfx::Size&, VideoPixelFormat, VideoPixelStorage, int)); | 185 Buffer(const gfx::Size&, VideoPixelFormat, VideoPixelStorage, int)); |
186 MOCK_METHOD2(OnError, | 186 MOCK_METHOD2(OnError, |
187 void(const tracked_objects::Location& from_here, | 187 void(const tracked_objects::Location& from_here, |
188 const std::string& reason)); | 188 const std::string& reason)); |
189 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); | 189 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); |
| 190 MOCK_METHOD0(OnStarted, void(void)); |
190 }; | 191 }; |
191 | 192 |
192 class V4L2CaptureDelegateTest : public ::testing::Test { | 193 class V4L2CaptureDelegateTest : public ::testing::Test { |
193 public: | 194 public: |
194 V4L2CaptureDelegateTest() | 195 V4L2CaptureDelegateTest() |
195 : device_descriptor_("Device 0", "/dev/video0"), | 196 : device_descriptor_("Device 0", "/dev/video0"), |
196 delegate_(new V4L2CaptureDelegate(device_descriptor_, | 197 delegate_(new V4L2CaptureDelegate(device_descriptor_, |
197 base::ThreadTaskRunnerHandle::Get(), | 198 base::ThreadTaskRunnerHandle::Get(), |
198 50)) {} | 199 50)) {} |
199 ~V4L2CaptureDelegateTest() override = default; | 200 ~V4L2CaptureDelegateTest() override = default; |
(...skipping 25 matching lines...) Expand all Loading... |
225 | 226 |
226 base::RunLoop().RunUntilIdle(); | 227 base::RunLoop().RunUntilIdle(); |
227 } | 228 } |
228 | 229 |
229 // Start and stop capturing, triggering the resetting of user and camera | 230 // Start and stop capturing, triggering the resetting of user and camera |
230 // control values. | 231 // control values. |
231 { | 232 { |
232 std::unique_ptr<MockVideoCaptureDeviceClient> client( | 233 std::unique_ptr<MockVideoCaptureDeviceClient> client( |
233 new MockVideoCaptureDeviceClient()); | 234 new MockVideoCaptureDeviceClient()); |
234 MockVideoCaptureDeviceClient* client_ptr = client.get(); | 235 MockVideoCaptureDeviceClient* client_ptr = client.get(); |
| 236 EXPECT_CALL(*client_ptr, OnStarted()); |
235 delegate_->AllocateAndStart(320 /* width */, 240 /* height */, | 237 delegate_->AllocateAndStart(320 /* width */, 240 /* height */, |
236 10.0 /* frame_rate */, std::move(client)); | 238 10.0 /* frame_rate */, std::move(client)); |
237 | 239 |
238 base::RunLoop run_loop; | 240 base::RunLoop run_loop; |
239 base::Closure quit_closure = run_loop.QuitClosure(); | 241 base::Closure quit_closure = run_loop.QuitClosure(); |
240 EXPECT_CALL(*client_ptr, OnIncomingCapturedData(_, _, _, _, _, _, _)) | 242 EXPECT_CALL(*client_ptr, OnIncomingCapturedData(_, _, _, _, _, _, _)) |
241 .Times(1) | 243 .Times(1) |
242 .WillOnce(RunClosure(quit_closure)); | 244 .WillOnce(RunClosure(quit_closure)); |
243 run_loop.Run(); | 245 run_loop.Run(); |
244 | 246 |
245 delegate_->StopAndDeAllocate(); | 247 delegate_->StopAndDeAllocate(); |
246 base::RunLoop().RunUntilIdle(); | 248 base::RunLoop().RunUntilIdle(); |
247 } | 249 } |
248 | 250 |
249 // Reopen the device and verify all user and camera controls should be back to | 251 // Reopen the device and verify all user and camera controls should be back to |
250 // their |default_value|s. | 252 // their |default_value|s. |
251 { | 253 { |
252 base::ScopedFD device_fd( | 254 base::ScopedFD device_fd( |
253 HANDLE_EINTR(open(device_descriptor_.device_id.c_str(), O_RDWR))); | 255 HANDLE_EINTR(open(device_descriptor_.device_id.c_str(), O_RDWR))); |
254 ASSERT_TRUE(device_fd.is_valid()); | 256 ASSERT_TRUE(device_fd.is_valid()); |
255 VerifyUserControlsAreSetToDefaultValues(device_fd.get()); | 257 VerifyUserControlsAreSetToDefaultValues(device_fd.get()); |
256 } | 258 } |
257 } | 259 } |
258 | 260 |
259 }; // namespace media | 261 }; // namespace media |
OLD | NEW |