OLD | NEW |
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/media/capture/web_contents_video_capture_device.h" | 5 #include "content/browser/media/capture/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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 // Test harness that sets up a minimal environment with necessary stubs. | 503 // Test harness that sets up a minimal environment with necessary stubs. |
504 class WebContentsVideoCaptureDeviceTest : public testing::Test { | 504 class WebContentsVideoCaptureDeviceTest : public testing::Test { |
505 public: | 505 public: |
506 // This is public because C++ method pointer scoping rules are silly and make | 506 // This is public because C++ method pointer scoping rules are silly and make |
507 // this hard to use with Bind(). | 507 // this hard to use with Bind(). |
508 void ResetWebContents() { | 508 void ResetWebContents() { |
509 web_contents_.reset(); | 509 web_contents_.reset(); |
510 } | 510 } |
511 | 511 |
512 protected: | 512 protected: |
513 virtual void SetUp() { | 513 void SetUp() override { |
514 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, &fake_screen_); | 514 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, &fake_screen_); |
515 ASSERT_EQ(&fake_screen_, gfx::Screen::GetNativeScreen()); | 515 ASSERT_EQ(&fake_screen_, gfx::Screen::GetNativeScreen()); |
516 | 516 |
517 // TODO(nick): Sadness and woe! Much "mock-the-world" boilerplate could be | 517 // TODO(nick): Sadness and woe! Much "mock-the-world" boilerplate could be |
518 // eliminated here, if only we could use RenderViewHostTestHarness. The | 518 // eliminated here, if only we could use RenderViewHostTestHarness. The |
519 // catch is that we need our TestRenderViewHost to support a | 519 // catch is that we need our TestRenderViewHost to support a |
520 // CopyFromBackingStore operation that we control. To accomplish that, | 520 // CopyFromBackingStore operation that we control. To accomplish that, |
521 // either RenderViewHostTestHarness would have to support installing a | 521 // either RenderViewHostTestHarness would have to support installing a |
522 // custom RenderViewHostFactory, or else we implant some kind of delegated | 522 // custom RenderViewHostFactory, or else we implant some kind of delegated |
523 // CopyFromBackingStore functionality into TestRenderViewHost itself. | 523 // CopyFromBackingStore functionality into TestRenderViewHost itself. |
(...skipping 14 matching lines...) Expand all Loading... |
538 TestWebContents::Create(browser_context_.get(), site_instance.get())); | 538 TestWebContents::Create(browser_context_.get(), site_instance.get())); |
539 RenderFrameHost* const main_frame = web_contents_->GetMainFrame(); | 539 RenderFrameHost* const main_frame = web_contents_->GetMainFrame(); |
540 device_.reset(WebContentsVideoCaptureDevice::Create( | 540 device_.reset(WebContentsVideoCaptureDevice::Create( |
541 base::StringPrintf("web-contents-media-stream://%d:%d", | 541 base::StringPrintf("web-contents-media-stream://%d:%d", |
542 main_frame->GetProcess()->GetID(), | 542 main_frame->GetProcess()->GetID(), |
543 main_frame->GetRoutingID()))); | 543 main_frame->GetRoutingID()))); |
544 | 544 |
545 base::RunLoop().RunUntilIdle(); | 545 base::RunLoop().RunUntilIdle(); |
546 } | 546 } |
547 | 547 |
548 virtual void TearDown() { | 548 void TearDown() override { |
549 // Tear down in opposite order of set-up. | 549 // Tear down in opposite order of set-up. |
550 | 550 |
551 // The device is destroyed asynchronously, and will notify the | 551 // The device is destroyed asynchronously, and will notify the |
552 // CaptureTestSourceController when it finishes destruction. | 552 // CaptureTestSourceController when it finishes destruction. |
553 // Trigger this, and wait. | 553 // Trigger this, and wait. |
554 if (device_) { | 554 if (device_) { |
555 device_->StopAndDeAllocate(); | 555 device_->StopAndDeAllocate(); |
556 device_.reset(); | 556 device_.reset(); |
557 } | 557 } |
558 | 558 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 source()->SetSolidColor(SK_ColorGREEN); | 843 source()->SetSolidColor(SK_ColorGREEN); |
844 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 844 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
845 source()->SetSolidColor(SK_ColorRED); | 845 source()->SetSolidColor(SK_ColorRED); |
846 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); | 846 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); |
847 | 847 |
848 device()->StopAndDeAllocate(); | 848 device()->StopAndDeAllocate(); |
849 } | 849 } |
850 | 850 |
851 } // namespace | 851 } // namespace |
852 } // namespace content | 852 } // namespace content |
OLD | NEW |