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

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

Issue 24133002: Make VideoCaptureController single-threaded and not ref counted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git pull Created 7 years, 3 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 | Annotate | Revision Log
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/web_contents_video_capture_device. h" 5 #include "content/browser/renderer_host/media/web_contents_video_capture_device. h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/debug/debugger.h" 8 #include "base/debug/debugger.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 base::RunLoop().RunUntilIdle(); 487 base::RunLoop().RunUntilIdle();
488 488
489 SiteInstanceImpl::set_render_process_host_factory(NULL); 489 SiteInstanceImpl::set_render_process_host_factory(NULL);
490 render_view_host_factory_.reset(); 490 render_view_host_factory_.reset();
491 render_process_host_factory_.reset(); 491 render_process_host_factory_.reset();
492 } 492 }
493 493
494 // Accessors. 494 // Accessors.
495 CaptureTestSourceController* source() { return &controller_; } 495 CaptureTestSourceController* source() { return &controller_; }
496 media::VideoCaptureDevice* device() { return device_.get(); } 496 media::VideoCaptureDevice1* device() { return device_.get(); }
497 StubConsumer* consumer() { return &consumer_; } 497 StubConsumer* consumer() { return &consumer_; }
498 498
499 void SimulateDrawEvent() { 499 void SimulateDrawEvent() {
500 if (source()->CanUseFrameSubscriber()) { 500 if (source()->CanUseFrameSubscriber()) {
501 // Print 501 // Print
502 CaptureTestView* test_view = static_cast<CaptureTestView*>( 502 CaptureTestView* test_view = static_cast<CaptureTestView*>(
503 web_contents_->GetRenderViewHost()->GetView()); 503 web_contents_->GetRenderViewHost()->GetView());
504 test_view->SimulateUpdate(); 504 test_view->SimulateUpdate();
505 } else { 505 } else {
506 // Simulate a non-accelerated paint. 506 // Simulate a non-accelerated paint.
(...skipping 18 matching lines...) Expand all
525 525
526 // Creates capture-capable RenderViewHosts whose pixel content production is 526 // Creates capture-capable RenderViewHosts whose pixel content production is
527 // under the control of |controller_|. 527 // under the control of |controller_|.
528 scoped_ptr<CaptureTestRenderViewHostFactory> render_view_host_factory_; 528 scoped_ptr<CaptureTestRenderViewHostFactory> render_view_host_factory_;
529 529
530 // A mocked-out browser and tab. 530 // A mocked-out browser and tab.
531 scoped_ptr<TestBrowserContext> browser_context_; 531 scoped_ptr<TestBrowserContext> browser_context_;
532 scoped_ptr<WebContents> web_contents_; 532 scoped_ptr<WebContents> web_contents_;
533 533
534 // Finally, the WebContentsVideoCaptureDevice under test. 534 // Finally, the WebContentsVideoCaptureDevice under test.
535 scoped_ptr<media::VideoCaptureDevice> device_; 535 scoped_ptr<media::VideoCaptureDevice1> device_;
536 536
537 TestBrowserThreadBundle thread_bundle_; 537 TestBrowserThreadBundle thread_bundle_;
538 }; 538 };
539 539
540 TEST_F(WebContentsVideoCaptureDeviceTest, InvalidInitialWebContentsError) { 540 TEST_F(WebContentsVideoCaptureDeviceTest, InvalidInitialWebContentsError) {
541 // Before the installs itself on the UI thread up to start capturing, we'll 541 // Before the installs itself on the UI thread up to start capturing, we'll
542 // delete the web contents. This should trigger an error which can happen in 542 // delete the web contents. This should trigger an error which can happen in
543 // practice; we should be able to recover gracefully. 543 // practice; we should be able to recover gracefully.
544 ResetWebContents(); 544 ResetWebContents();
545 545
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 media::VideoCaptureCapability capture_format( 746 media::VideoCaptureCapability capture_format(
747 1280, 747 1280,
748 720, 748 720,
749 -2, 749 -2,
750 media::PIXEL_FORMAT_I420, 750 media::PIXEL_FORMAT_I420,
751 0, 751 0,
752 false, 752 false,
753 media::ConstantResolutionVideoCaptureDevice); 753 media::ConstantResolutionVideoCaptureDevice);
754 BrowserThread::PostTask(BrowserThread::UI, 754 BrowserThread::PostTask(BrowserThread::UI,
755 FROM_HERE, 755 FROM_HERE,
756 base::Bind(&media::VideoCaptureDevice::Allocate, 756 base::Bind(&media::VideoCaptureDevice1::Allocate,
757 base::Unretained(device()), 757 base::Unretained(device()),
758 capture_format, 758 capture_format,
759 consumer())); 759 consumer()));
760 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForError()); 760 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForError());
761 } 761 }
762 762
763 TEST_F(WebContentsVideoCaptureDeviceTest, BadFramesGoodFrames) { 763 TEST_F(WebContentsVideoCaptureDeviceTest, BadFramesGoodFrames) {
764 media::VideoCaptureCapability capture_format( 764 media::VideoCaptureCapability capture_format(
765 kTestWidth, 765 kTestWidth,
766 kTestHeight, 766 kTestHeight,
(...skipping 23 matching lines...) Expand all
790 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForNextColor(SK_ColorGREEN)); 790 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForNextColor(SK_ColorGREEN));
791 source()->SetSolidColor(SK_ColorRED); 791 source()->SetSolidColor(SK_ColorRED);
792 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForNextColor(SK_ColorRED)); 792 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForNextColor(SK_ColorRED));
793 793
794 device()->Stop(); 794 device()->Stop();
795 device()->DeAllocate(); 795 device()->DeAllocate();
796 } 796 }
797 797
798 } // namespace 798 } // namespace
799 } // namespace content 799 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698