| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "content/test/test_web_contents.h" | 35 #include "content/test/test_web_contents.h" |
| 36 #include "media/base/video_capture_types.h" | 36 #include "media/base/video_capture_types.h" |
| 37 #include "media/base/video_frame.h" | 37 #include "media/base/video_frame.h" |
| 38 #include "media/base/video_util.h" | 38 #include "media/base/video_util.h" |
| 39 #include "media/base/yuv_convert.h" | 39 #include "media/base/yuv_convert.h" |
| 40 #include "skia/ext/platform_canvas.h" | 40 #include "skia/ext/platform_canvas.h" |
| 41 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
| 42 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
| 43 #include "third_party/skia/include/core/SkColor.h" | 43 #include "third_party/skia/include/core/SkColor.h" |
| 44 #include "ui/base/layout.h" | 44 #include "ui/base/layout.h" |
| 45 #include "ui/gfx/display.h" | 45 #include "ui/display/display.h" |
| 46 #include "ui/display/screen.h" |
| 46 #include "ui/gfx/geometry/dip_util.h" | 47 #include "ui/gfx/geometry/dip_util.h" |
| 47 #include "ui/gfx/geometry/size_conversions.h" | 48 #include "ui/gfx/geometry/size_conversions.h" |
| 48 #include "ui/gfx/screen.h" | |
| 49 #include "ui/gfx/test/test_screen.h" | 49 #include "ui/gfx/test/test_screen.h" |
| 50 | 50 |
| 51 namespace content { | 51 namespace content { |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 const int kTestWidth = 320; | 54 const int kTestWidth = 320; |
| 55 const int kTestHeight = 240; | 55 const int kTestHeight = 240; |
| 56 const int kTestFramesPerSecond = 20; | 56 const int kTestFramesPerSecond = 20; |
| 57 const float kTestDeviceScaleFactor = 2.0f; | 57 const float kTestDeviceScaleFactor = 2.0f; |
| 58 const SkColor kNothingYet = 0xdeadbeef; | 58 const SkColor kNothingYet = 0xdeadbeef; |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 void ResetWebContents() { | 593 void ResetWebContents() { |
| 594 web_contents_.reset(); | 594 web_contents_.reset(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 protected: | 597 protected: |
| 598 void SetUp() override { | 598 void SetUp() override { |
| 599 test_screen_.display()->set_id(0x1337); | 599 test_screen_.display()->set_id(0x1337); |
| 600 test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); | 600 test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); |
| 601 test_screen_.display()->set_device_scale_factor(kTestDeviceScaleFactor); | 601 test_screen_.display()->set_device_scale_factor(kTestDeviceScaleFactor); |
| 602 | 602 |
| 603 gfx::Screen::SetScreenInstance(&test_screen_); | 603 display::Screen::SetScreenInstance(&test_screen_); |
| 604 ASSERT_EQ(&test_screen_, gfx::Screen::GetScreen()); | 604 ASSERT_EQ(&test_screen_, display::Screen::GetScreen()); |
| 605 | 605 |
| 606 // TODO(nick): Sadness and woe! Much "mock-the-world" boilerplate could be | 606 // TODO(nick): Sadness and woe! Much "mock-the-world" boilerplate could be |
| 607 // eliminated here, if only we could use RenderViewHostTestHarness. The | 607 // eliminated here, if only we could use RenderViewHostTestHarness. The |
| 608 // catch is that we need our TestRenderViewHost to support a | 608 // catch is that we need our TestRenderViewHost to support a |
| 609 // CopyFromBackingStore operation that we control. To accomplish that, | 609 // CopyFromBackingStore operation that we control. To accomplish that, |
| 610 // either RenderViewHostTestHarness would have to support installing a | 610 // either RenderViewHostTestHarness would have to support installing a |
| 611 // custom RenderViewHostFactory, or else we implant some kind of delegated | 611 // custom RenderViewHostFactory, or else we implant some kind of delegated |
| 612 // CopyFromBackingStore functionality into TestRenderViewHost itself. | 612 // CopyFromBackingStore functionality into TestRenderViewHost itself. |
| 613 | 613 |
| 614 render_process_host_factory_.reset(new MockRenderProcessHostFactory()); | 614 render_process_host_factory_.reset(new MockRenderProcessHostFactory()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 web_contents_.reset(); | 652 web_contents_.reset(); |
| 653 browser_context_.reset(); | 653 browser_context_.reset(); |
| 654 | 654 |
| 655 base::RunLoop().RunUntilIdle(); | 655 base::RunLoop().RunUntilIdle(); |
| 656 | 656 |
| 657 SiteInstanceImpl::set_render_process_host_factory(NULL); | 657 SiteInstanceImpl::set_render_process_host_factory(NULL); |
| 658 render_frame_host_factory_.reset(); | 658 render_frame_host_factory_.reset(); |
| 659 render_view_host_factory_.reset(); | 659 render_view_host_factory_.reset(); |
| 660 render_process_host_factory_.reset(); | 660 render_process_host_factory_.reset(); |
| 661 | 661 |
| 662 gfx::Screen::SetScreenInstance(nullptr); | 662 display::Screen::SetScreenInstance(nullptr); |
| 663 } | 663 } |
| 664 | 664 |
| 665 // Accessors. | 665 // Accessors. |
| 666 CaptureTestSourceController* source() { return &controller_; } | 666 CaptureTestSourceController* source() { return &controller_; } |
| 667 WebContents* web_contents() const { return web_contents_.get(); } | 667 WebContents* web_contents() const { return web_contents_.get(); } |
| 668 media::VideoCaptureDevice* device() { return device_.get(); } | 668 media::VideoCaptureDevice* device() { return device_.get(); } |
| 669 | 669 |
| 670 // Returns the device scale factor of the capture target's native view. This | 670 // Returns the device scale factor of the capture target's native view. This |
| 671 // is necessary because, architecturally, the TestScreen implementation is | 671 // is necessary because, architecturally, the TestScreen implementation is |
| 672 // ignored on Mac platforms (when determining the device scale factor for a | 672 // ignored on Mac platforms (when determining the device scale factor for a |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 for (int i = 0; i < 3; ++i) { | 1218 for (int i = 0; i < 3; ++i) { |
| 1219 SimulateRefreshFrameRequest(); | 1219 SimulateRefreshFrameRequest(); |
| 1220 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 1220 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 device()->StopAndDeAllocate(); | 1223 device()->StopAndDeAllocate(); |
| 1224 } | 1224 } |
| 1225 | 1225 |
| 1226 } // namespace | 1226 } // namespace |
| 1227 } // namespace content | 1227 } // namespace content |
| OLD | NEW |