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

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

Issue 145293007: ui: No more TestCompositor. Use NullDraw contexts in unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: testsnulldraw: Created 6 years, 10 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 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/renderer_host/media/desktop_capture_device_aura.h" 5 #include "content/browser/renderer_host/media/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"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/aura/client/window_tree_client.h" 13 #include "ui/aura/client/window_tree_client.h"
14 #include "ui/aura/test/aura_test_helper.h" 14 #include "ui/aura/test/aura_test_helper.h"
15 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/compositor/test/context_factories_for_test.h"
17 18
18 using ::testing::_; 19 using ::testing::_;
19 using ::testing::AnyNumber; 20 using ::testing::AnyNumber;
20 using ::testing::DoAll; 21 using ::testing::DoAll;
21 using ::testing::Expectation; 22 using ::testing::Expectation;
22 using ::testing::InvokeWithoutArgs; 23 using ::testing::InvokeWithoutArgs;
23 using ::testing::SaveArg; 24 using ::testing::SaveArg;
24 25
25 namespace content { 26 namespace content {
26 namespace { 27 namespace {
(...skipping 22 matching lines...) Expand all
49 50
50 // Test harness that sets up a minimal environment with necessary stubs. 51 // Test harness that sets up a minimal environment with necessary stubs.
51 class DesktopCaptureDeviceAuraTest : public testing::Test { 52 class DesktopCaptureDeviceAuraTest : public testing::Test {
52 public: 53 public:
53 DesktopCaptureDeviceAuraTest() 54 DesktopCaptureDeviceAuraTest()
54 : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} 55 : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {}
55 virtual ~DesktopCaptureDeviceAuraTest() {} 56 virtual ~DesktopCaptureDeviceAuraTest() {}
56 57
57 protected: 58 protected:
58 virtual void SetUp() OVERRIDE { 59 virtual void SetUp() OVERRIDE {
60 // The ContextFactory must exist before any Compositors are created.
61 bool enable_pixel_output = false;
62 ui::InitializeContextFactoryForTests(enable_pixel_output);
59 helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 63 helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
60 bool allow_test_contexts = true; 64 helper_->SetUp();
61 helper_->SetUp(allow_test_contexts);
62 65
63 // We need a window to cover desktop area so that DesktopCaptureDeviceAura 66 // We need a window to cover desktop area so that DesktopCaptureDeviceAura
64 // can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the 67 // can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the
65 // root window associated with the primary display. 68 // root window associated with the primary display.
66 gfx::Rect desktop_bounds = root_window()->bounds(); 69 gfx::Rect desktop_bounds = root_window()->bounds();
67 window_delegate_.reset(new aura::test::TestWindowDelegate()); 70 window_delegate_.reset(new aura::test::TestWindowDelegate());
68 desktop_window_.reset(new aura::Window(window_delegate_.get())); 71 desktop_window_.reset(new aura::Window(window_delegate_.get()));
69 desktop_window_->Init(aura::WINDOW_LAYER_TEXTURED); 72 desktop_window_->Init(aura::WINDOW_LAYER_TEXTURED);
70 desktop_window_->SetBounds(desktop_bounds); 73 desktop_window_->SetBounds(desktop_bounds);
71 aura::client::ParentWindowWithContext( 74 aura::client::ParentWindowWithContext(
72 desktop_window_.get(), root_window(), desktop_bounds); 75 desktop_window_.get(), root_window(), desktop_bounds);
73 desktop_window_->Show(); 76 desktop_window_->Show();
74 } 77 }
75 78
76 virtual void TearDown() OVERRIDE { 79 virtual void TearDown() OVERRIDE {
77 helper_->RunAllPendingInMessageLoop(); 80 helper_->RunAllPendingInMessageLoop();
78 root_window()->RemoveChild(desktop_window_.get()); 81 root_window()->RemoveChild(desktop_window_.get());
79 desktop_window_.reset(); 82 desktop_window_.reset();
80 window_delegate_.reset(); 83 window_delegate_.reset();
81 helper_->TearDown(); 84 helper_->TearDown();
85 ui::TerminateContextFactoryForTests();
82 } 86 }
83 87
84 aura::Window* root_window() { return helper_->root_window(); } 88 aura::Window* root_window() { return helper_->root_window(); }
85 89
86 private: 90 private:
87 base::MessageLoopForUI message_loop_; 91 base::MessageLoopForUI message_loop_;
88 BrowserThreadImpl browser_thread_for_ui_; 92 BrowserThreadImpl browser_thread_for_ui_;
89 scoped_ptr<aura::test::AuraTestHelper> helper_; 93 scoped_ptr<aura::test::AuraTestHelper> helper_;
90 scoped_ptr<aura::Window> desktop_window_; 94 scoped_ptr<aura::Window> desktop_window_;
91 scoped_ptr<aura::test::TestWindowDelegate> window_delegate_; 95 scoped_ptr<aura::test::TestWindowDelegate> window_delegate_;
(...skipping 14 matching lines...) Expand all
106 capture_params.requested_format.frame_rate = kFrameRate; 110 capture_params.requested_format.frame_rate = kFrameRate;
107 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 111 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
108 capture_params.allow_resolution_change = false; 112 capture_params.allow_resolution_change = false;
109 capture_device->AllocateAndStart( 113 capture_device->AllocateAndStart(
110 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); 114 capture_params, client.PassAs<media::VideoCaptureDevice::Client>());
111 capture_device->StopAndDeAllocate(); 115 capture_device->StopAndDeAllocate();
112 } 116 }
113 117
114 } // namespace 118 } // namespace
115 } // namespace content 119 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698