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

Side by Side Diff: content/browser/renderer_host/media/video_capture_host_unittest.cc

Issue 2392113004: Removing DUMP_VIDEO and TEST_REAL_CAPTURE_DEVICE from VideoCaptureHostTest (Closed)
Patch Set: Removing DUMP_VIDEO and TEST_REAL_CAPTURE_DEVICE from VideoCaptureHostTest Created 4 years, 2 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 | « no previous file | 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 "content/browser/renderer_host/media/video_capture_host.h" 5 #include "content/browser/renderer_host/media/video_capture_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 using ::testing::Return; 54 using ::testing::Return;
55 using ::testing::SaveArg; 55 using ::testing::SaveArg;
56 using ::testing::StrictMock; 56 using ::testing::StrictMock;
57 57
58 namespace content { 58 namespace content {
59 59
60 // Id used to identify the capture session between renderer and 60 // Id used to identify the capture session between renderer and
61 // video_capture_host. This is an arbitrary value. 61 // video_capture_host. This is an arbitrary value.
62 static const int kDeviceId = 555; 62 static const int kDeviceId = 555;
63 63
64 // Define to enable test where video is dumped to file.
65 // #define DUMP_VIDEO
66
67 // Define to use a real video capture device.
68 // #define TEST_REAL_CAPTURE_DEVICE
69
70 // Simple class used for dumping video to a file. This can be used for 64 // Simple class used for dumping video to a file. This can be used for
71 // verifying the output. 65 // verifying the output.
72 class DumpVideo { 66 class DumpVideo {
73 public: 67 public:
74 DumpVideo() {} 68 DumpVideo() {}
75 const gfx::Size& coded_size() const { return coded_size_; } 69 const gfx::Size& coded_size() const { return coded_size_; }
76 void StartDump(const gfx::Size& coded_size) { 70 void StartDump(const gfx::Size& coded_size) {
77 base::FilePath file_name = base::FilePath(base::StringPrintf( 71 base::FilePath file_name = base::FilePath(base::StringPrintf(
78 FILE_PATH_LITERAL("dump_w%d_h%d.yuv"), 72 FILE_PATH_LITERAL("dump_w%d_h%d.yuv"),
79 coded_size.width(), 73 coded_size.width(),
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 259
266 void SetUp() override { 260 void SetUp() override {
267 SetBrowserClientForTesting(&browser_client_); 261 SetBrowserClientForTesting(&browser_client_);
268 262
269 #if defined(OS_CHROMEOS) 263 #if defined(OS_CHROMEOS)
270 chromeos::CrasAudioHandler::InitializeForTesting(); 264 chromeos::CrasAudioHandler::InitializeForTesting();
271 #endif 265 #endif
272 266
273 // Create our own MediaStreamManager. 267 // Create our own MediaStreamManager.
274 audio_manager_ = media::AudioManager::CreateForTesting(task_runner_); 268 audio_manager_ = media::AudioManager::CreateForTesting(task_runner_);
275 #ifndef TEST_REAL_CAPTURE_DEVICE 269
276 base::CommandLine::ForCurrentProcess()->AppendSwitch( 270 base::CommandLine::ForCurrentProcess()->AppendSwitch(
277 switches::kUseFakeDeviceForMediaStream); 271 switches::kUseFakeDeviceForMediaStream);
278 #endif 272
279 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 273 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
280 media_stream_manager_->UseFakeUIForTests( 274 media_stream_manager_->UseFakeUIForTests(
281 std::unique_ptr<FakeMediaStreamUIProxy>()); 275 std::unique_ptr<FakeMediaStreamUIProxy>());
282 276
283 // Create a Host and connect it to a simulated IPC channel. 277 // Create a Host and connect it to a simulated IPC channel.
284 host_ = new MockVideoCaptureHost(media_stream_manager_.get()); 278 host_ = new MockVideoCaptureHost(media_stream_manager_.get());
285 host_->OnChannelConnected(base::GetCurrentProcId()); 279 host_->OnChannelConnected(base::GetCurrentProcId());
286 280
287 OpenSession(); 281 OpenSession();
288 } 282 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)); 394 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED));
401 media::VideoCaptureParams params; 395 media::VideoCaptureParams params;
402 params.requested_format = media::VideoCaptureFormat( 396 params.requested_format = media::VideoCaptureFormat(
403 gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420); 397 gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420);
404 host_->OnStartCapture(kDeviceId, opened_session_id_, params); 398 host_->OnStartCapture(kDeviceId, opened_session_id_, params);
405 host_->OnStopCapture(kDeviceId); 399 host_->OnStopCapture(kDeviceId);
406 run_loop.RunUntilIdle(); 400 run_loop.RunUntilIdle();
407 WaitForVideoDeviceThread(); 401 WaitForVideoDeviceThread();
408 } 402 }
409 403
410 #ifdef DUMP_VIDEO
411 void CaptureAndDumpVideo(int width, int height, int frame_rate) {
412 InSequence s;
413 EXPECT_CALL(*host_.get(), OnNewBufferCreated(kDeviceId, _, _, _))
414 .Times(AnyNumber()).WillRepeatedly(Return());
415
416 base::RunLoop run_loop;
417 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _, _, _, _, _, _, _))
418 .Times(AnyNumber())
419 .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure()));
420
421 media::VideoCaptureParams params;
422 params.requested_format =
423 media::VideoCaptureFormat(gfx::Size(width, height), frame_rate);
424 host_->SetDumpVideo(true);
425 host_->OnStartCapture(kDeviceId, opened_session_id_, params);
426 run_loop.Run();
427 }
428 #endif
429
430 void StopCapture() { 404 void StopCapture() {
431 base::RunLoop run_loop; 405 base::RunLoop run_loop;
432 EXPECT_CALL(*host_.get(), 406 EXPECT_CALL(*host_.get(),
433 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)) 407 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED))
434 .WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure())); 408 .WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure()));
435 409
436 host_->OnStopCapture(kDeviceId); 410 host_->OnStopCapture(kDeviceId);
437 host_->SetReturnReceivedDibs(true); 411 host_->SetReturnReceivedDibs(true);
438 host_->ReturnReceivedDibs(kDeviceId); 412 host_->ReturnReceivedDibs(kDeviceId);
439 413
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 500 }
527 501
528 TEST_F(VideoCaptureHostTest, StartCaptureError) { 502 TEST_F(VideoCaptureHostTest, StartCaptureError) {
529 EXPECT_CALL(*host_.get(), 503 EXPECT_CALL(*host_.get(),
530 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)).Times(0); 504 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)).Times(0);
531 StartCapture(); 505 StartCapture();
532 NotifyPacketReady(); 506 NotifyPacketReady();
533 SimulateError(); 507 SimulateError();
534 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(200)); 508 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(200));
535 } 509 }
536
537 #ifdef DUMP_VIDEO
538 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) {
539 CaptureAndDumpVideo(640, 480, 30);
540 }
541 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) {
542 CaptureAndDumpVideo(1280, 720, 30);
543 }
544 #endif
545
546 } // namespace content 510 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698