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

Side by Side Diff: content/browser/compositor/software_browser_compositor_output_surface_unittest.cc

Issue 134623005: Make SingleThreadProxy a SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests; remove weak_ptr_ 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
« no previous file with comments | « cc/trees/thread_proxy.cc ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "cc/output/compositor_frame.h" 6 #include "cc/output/compositor_frame.h"
7 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h" 7 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h"
8 #include "content/browser/compositor/software_browser_compositor_output_surface. h" 8 #include "content/browser/compositor/software_browser_compositor_output_surface. h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/compositor/compositor.h" 10 #include "ui/compositor/compositor.h"
11 #include "ui/compositor/test/context_factories_for_test.h" 11 #include "ui/compositor/test/context_factories_for_test.h"
12 #include "ui/compositor/test/test_compositor_host.h"
12 #include "ui/gfx/vsync_provider.h" 13 #include "ui/gfx/vsync_provider.h"
13 14
14 namespace { 15 namespace {
15 16
16 class FakeVSyncProvider : public gfx::VSyncProvider { 17 class FakeVSyncProvider : public gfx::VSyncProvider {
17 public: 18 public:
18 FakeVSyncProvider() : call_count_(0) {} 19 FakeVSyncProvider() : call_count_(0) {}
19 virtual ~FakeVSyncProvider() {} 20 virtual ~FakeVSyncProvider() {}
20 21
21 virtual void GetVSyncParameters(const UpdateVSyncCallback& callback) 22 virtual void GetVSyncParameters(const UpdateVSyncCallback& callback)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 virtual void SetUp() OVERRIDE; 64 virtual void SetUp() OVERRIDE;
64 virtual void TearDown() OVERRIDE; 65 virtual void TearDown() OVERRIDE;
65 66
66 scoped_ptr<content::BrowserCompositorOutputSurface> CreateSurface( 67 scoped_ptr<content::BrowserCompositorOutputSurface> CreateSurface(
67 scoped_ptr<cc::SoftwareOutputDevice> device); 68 scoped_ptr<cc::SoftwareOutputDevice> device);
68 69
69 protected: 70 protected:
70 scoped_ptr<content::BrowserCompositorOutputSurface> output_surface_; 71 scoped_ptr<content::BrowserCompositorOutputSurface> output_surface_;
71 72
72 scoped_ptr<base::MessageLoop> message_loop_; 73 scoped_ptr<base::MessageLoop> message_loop_;
73 scoped_ptr<ui::Compositor> compositor_;
74 74
75 IDMap<content::BrowserCompositorOutputSurface> surface_map_; 75 IDMap<content::BrowserCompositorOutputSurface> surface_map_;
76 scoped_refptr<content::BrowserCompositorOutputSurfaceProxy> surface_proxy_; 76 scoped_refptr<content::BrowserCompositorOutputSurfaceProxy> surface_proxy_;
77 77
78 scoped_ptr<ui::TestCompositorHost> window_;
danakj 2014/02/21 19:36:21 s/window_/compositor_host_/
enne (OOO) 2014/02/21 19:41:32 Done. PS https://code.google.com/p/chromium/codes
79
78 DISALLOW_COPY_AND_ASSIGN(SoftwareBrowserCompositorOutputSurfaceTest); 80 DISALLOW_COPY_AND_ASSIGN(SoftwareBrowserCompositorOutputSurfaceTest);
79 }; 81 };
80 82
81 SoftwareBrowserCompositorOutputSurfaceTest:: 83 SoftwareBrowserCompositorOutputSurfaceTest::
82 SoftwareBrowserCompositorOutputSurfaceTest() { 84 SoftwareBrowserCompositorOutputSurfaceTest() {
83 // |message_loop_| is not used, but the main thread still has to exist for the 85 // |message_loop_| is not used, but the main thread still has to exist for the
84 // compositor to use. 86 // compositor to use.
85 message_loop_.reset(new base::MessageLoopForUI); 87 message_loop_.reset(new base::MessageLoopForUI);
86 } 88 }
87 89
88 SoftwareBrowserCompositorOutputSurfaceTest:: 90 SoftwareBrowserCompositorOutputSurfaceTest::
89 ~SoftwareBrowserCompositorOutputSurfaceTest() {} 91 ~SoftwareBrowserCompositorOutputSurfaceTest() {}
90 92
91 void SoftwareBrowserCompositorOutputSurfaceTest::SetUp() { 93 void SoftwareBrowserCompositorOutputSurfaceTest::SetUp() {
92 bool enable_pixel_output = false; 94 bool enable_pixel_output = false;
93 ui::InitializeContextFactoryForTests(enable_pixel_output); 95 ui::InitializeContextFactoryForTests(enable_pixel_output);
94 ui::Compositor::Initialize(); 96 ui::Compositor::Initialize();
95 97
96 compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget)); 98 const gfx::Rect host_bounds(10, 10, 500, 500);
99 window_.reset(ui::TestCompositorHost::Create(host_bounds));
100 window_->Show();
101
97 surface_proxy_ = 102 surface_proxy_ =
98 new content::BrowserCompositorOutputSurfaceProxy(&surface_map_); 103 new content::BrowserCompositorOutputSurfaceProxy(&surface_map_);
99 } 104 }
100 105
101 void SoftwareBrowserCompositorOutputSurfaceTest::TearDown() { 106 void SoftwareBrowserCompositorOutputSurfaceTest::TearDown() {
102 output_surface_.reset(); 107 output_surface_.reset();
103 compositor_.reset(); 108 window_.reset();
104 109
105 EXPECT_TRUE(surface_map_.IsEmpty()); 110 EXPECT_TRUE(surface_map_.IsEmpty());
106 111
107 surface_map_.Clear(); 112 surface_map_.Clear();
108 ui::TerminateContextFactoryForTests(); 113 ui::TerminateContextFactoryForTests();
109 ui::Compositor::Terminate(); 114 ui::Compositor::Terminate();
110 } 115 }
111 116
112 scoped_ptr<content::BrowserCompositorOutputSurface> 117 scoped_ptr<content::BrowserCompositorOutputSurface>
113 SoftwareBrowserCompositorOutputSurfaceTest::CreateSurface( 118 SoftwareBrowserCompositorOutputSurfaceTest::CreateSurface(
114 scoped_ptr<cc::SoftwareOutputDevice> device) { 119 scoped_ptr<cc::SoftwareOutputDevice> device) {
115 return scoped_ptr<content::BrowserCompositorOutputSurface>( 120 return scoped_ptr<content::BrowserCompositorOutputSurface>(
116 new content::SoftwareBrowserCompositorOutputSurface( 121 new content::SoftwareBrowserCompositorOutputSurface(
117 surface_proxy_, 122 surface_proxy_,
118 device.Pass(), 123 device.Pass(),
119 1, 124 1,
120 &surface_map_, 125 &surface_map_,
121 compositor_->vsync_manager())); 126 window_->GetCompositor()->vsync_manager()));
122 } 127 }
123 128
124 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, NoVSyncProvider) { 129 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, NoVSyncProvider) {
125 scoped_ptr<cc::SoftwareOutputDevice> software_device( 130 scoped_ptr<cc::SoftwareOutputDevice> software_device(
126 new cc::SoftwareOutputDevice()); 131 new cc::SoftwareOutputDevice());
127 output_surface_ = CreateSurface(software_device.Pass()); 132 output_surface_ = CreateSurface(software_device.Pass());
128 133
129 cc::CompositorFrame frame; 134 cc::CompositorFrame frame;
130 output_surface_->SwapBuffers(&frame); 135 output_surface_->SwapBuffers(&frame);
131 136
132 EXPECT_EQ(NULL, output_surface_->software_device()->GetVSyncProvider()); 137 EXPECT_EQ(NULL, output_surface_->software_device()->GetVSyncProvider());
133 } 138 }
134 139
135 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, VSyncProviderUpdates) { 140 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, VSyncProviderUpdates) {
136 scoped_ptr<cc::SoftwareOutputDevice> software_device( 141 scoped_ptr<cc::SoftwareOutputDevice> software_device(
137 new FakeSoftwareOutputDevice()); 142 new FakeSoftwareOutputDevice());
138 output_surface_ = CreateSurface(software_device.Pass()); 143 output_surface_ = CreateSurface(software_device.Pass());
139 144
140 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( 145 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>(
141 output_surface_->software_device()->GetVSyncProvider()); 146 output_surface_->software_device()->GetVSyncProvider());
142 EXPECT_EQ(0, vsync_provider->call_count()); 147 EXPECT_EQ(0, vsync_provider->call_count());
143 148
144 cc::CompositorFrame frame; 149 cc::CompositorFrame frame;
145 output_surface_->SwapBuffers(&frame); 150 output_surface_->SwapBuffers(&frame);
146 151
147 EXPECT_EQ(1, vsync_provider->call_count()); 152 EXPECT_EQ(1, vsync_provider->call_count());
148 } 153 }
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.cc ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698