| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/desktop_capture_device_aura.h" | 5 #include "content/browser/media/capture/desktop_capture_device_aura.h" |
| 6 | 6 |
| 7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
| 9 #include "content/public/browser/desktop_media_id.h" | 9 #include "content/public/browser/desktop_media_id.h" |
| 10 #include "media/video/capture/video_capture_types.h" | 10 #include "media/video/capture/video_capture_types.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Test harness that sets up a minimal environment with necessary stubs. | 55 // Test harness that sets up a minimal environment with necessary stubs. |
| 56 class DesktopCaptureDeviceAuraTest : public testing::Test { | 56 class DesktopCaptureDeviceAuraTest : public testing::Test { |
| 57 public: | 57 public: |
| 58 DesktopCaptureDeviceAuraTest() | 58 DesktopCaptureDeviceAuraTest() |
| 59 : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} | 59 : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} |
| 60 virtual ~DesktopCaptureDeviceAuraTest() {} | 60 virtual ~DesktopCaptureDeviceAuraTest() {} |
| 61 | 61 |
| 62 protected: | 62 protected: |
| 63 virtual void SetUp() OVERRIDE { | 63 virtual void SetUp() override { |
| 64 // The ContextFactory must exist before any Compositors are created. | 64 // The ContextFactory must exist before any Compositors are created. |
| 65 bool enable_pixel_output = false; | 65 bool enable_pixel_output = false; |
| 66 ui::ContextFactory* context_factory = | 66 ui::ContextFactory* context_factory = |
| 67 ui::InitializeContextFactoryForTests(enable_pixel_output); | 67 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 68 helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 68 helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
| 69 helper_->SetUp(context_factory); | 69 helper_->SetUp(context_factory); |
| 70 new wm::DefaultActivationClient(helper_->root_window()); | 70 new wm::DefaultActivationClient(helper_->root_window()); |
| 71 | 71 |
| 72 // We need a window to cover desktop area so that DesktopCaptureDeviceAura | 72 // We need a window to cover desktop area so that DesktopCaptureDeviceAura |
| 73 // can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the | 73 // can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the |
| 74 // root window associated with the primary display. | 74 // root window associated with the primary display. |
| 75 gfx::Rect desktop_bounds = root_window()->bounds(); | 75 gfx::Rect desktop_bounds = root_window()->bounds(); |
| 76 window_delegate_.reset(new aura::test::TestWindowDelegate()); | 76 window_delegate_.reset(new aura::test::TestWindowDelegate()); |
| 77 desktop_window_.reset(new aura::Window(window_delegate_.get())); | 77 desktop_window_.reset(new aura::Window(window_delegate_.get())); |
| 78 desktop_window_->Init(aura::WINDOW_LAYER_TEXTURED); | 78 desktop_window_->Init(aura::WINDOW_LAYER_TEXTURED); |
| 79 desktop_window_->SetBounds(desktop_bounds); | 79 desktop_window_->SetBounds(desktop_bounds); |
| 80 aura::client::ParentWindowWithContext( | 80 aura::client::ParentWindowWithContext( |
| 81 desktop_window_.get(), root_window(), desktop_bounds); | 81 desktop_window_.get(), root_window(), desktop_bounds); |
| 82 desktop_window_->Show(); | 82 desktop_window_->Show(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 virtual void TearDown() OVERRIDE { | 85 virtual void TearDown() override { |
| 86 helper_->RunAllPendingInMessageLoop(); | 86 helper_->RunAllPendingInMessageLoop(); |
| 87 root_window()->RemoveChild(desktop_window_.get()); | 87 root_window()->RemoveChild(desktop_window_.get()); |
| 88 desktop_window_.reset(); | 88 desktop_window_.reset(); |
| 89 window_delegate_.reset(); | 89 window_delegate_.reset(); |
| 90 helper_->TearDown(); | 90 helper_->TearDown(); |
| 91 ui::TerminateContextFactoryForTests(); | 91 ui::TerminateContextFactoryForTests(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 aura::Window* root_window() { return helper_->root_window(); } | 94 aura::Window* root_window() { return helper_->root_window(); } |
| 95 | 95 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 115 capture_params.requested_format.frame_size.SetSize(640, 480); | 115 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 116 capture_params.requested_format.frame_rate = kFrameRate; | 116 capture_params.requested_format.frame_rate = kFrameRate; |
| 117 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; | 117 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; |
| 118 capture_device->AllocateAndStart( | 118 capture_device->AllocateAndStart( |
| 119 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); | 119 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); |
| 120 capture_device->StopAndDeAllocate(); | 120 capture_device->StopAndDeAllocate(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace | 123 } // namespace |
| 124 } // namespace content | 124 } // namespace content |
| OLD | NEW |