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

Side by Side Diff: cc/gl_renderer_unittest.cc

Issue 11361223: cc: Remove cc::settings, move them to LayerTreeSettings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-unittests Created 8 years, 1 month 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/gl_renderer.cc ('k') | cc/layer.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/gl_renderer.h" 5 #include "cc/gl_renderer.h"
6 6
7 #include "cc/draw_quad.h" 7 #include "cc/draw_quad.h"
8 #include "cc/prioritized_resource_manager.h" 8 #include "cc/prioritized_resource_manager.h"
9 #include "cc/resource_provider.h" 9 #include "cc/resource_provider.h"
10 #include "cc/settings.h"
11 #include "cc/test/fake_web_compositor_output_surface.h" 10 #include "cc/test/fake_web_compositor_output_surface.h"
12 #include "cc/test/fake_web_graphics_context_3d.h" 11 #include "cc/test/fake_web_graphics_context_3d.h"
13 #include "cc/test/test_common.h"
14 #include "cc/test/render_pass_test_common.h" 12 #include "cc/test/render_pass_test_common.h"
15 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/khronos/GLES2/gl2.h" 15 #include "third_party/khronos/GLES2/gl2.h"
18 #include <public/WebTransformationMatrix.h> 16 #include <public/WebTransformationMatrix.h>
19 17
20 using namespace WebKit; 18 using namespace WebKit;
21 using namespace WebKitTests; 19 using namespace WebKitTests;
22 20
23 namespace cc { 21 namespace cc {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 129
132 FrameCountingMemoryAllocationSettingContext* context() { return static_cast< FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); } 130 FrameCountingMemoryAllocationSettingContext* context() { return static_cast< FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); }
133 131
134 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; 132 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes;
135 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; 133 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo;
136 134
137 scoped_ptr<GraphicsContext> m_context; 135 scoped_ptr<GraphicsContext> m_context;
138 FakeRendererClient m_mockClient; 136 FakeRendererClient m_mockClient;
139 scoped_ptr<ResourceProvider> m_resourceProvider; 137 scoped_ptr<ResourceProvider> m_resourceProvider;
140 FakeRendererGL m_renderer; 138 FakeRendererGL m_renderer;
141 ScopedSettings m_scopedSettings;
142 }; 139 };
143 140
144 // Test GLRenderer discardFramebuffer functionality: 141 // Test GLRenderer discardFramebuffer functionality:
145 // Suggest recreating framebuffer when one already exists. 142 // Suggest recreating framebuffer when one already exists.
146 // Expected: it does nothing. 143 // Expected: it does nothing.
147 TEST_F(GLRendererTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) 144 TEST_F(GLRendererTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing)
148 { 145 {
149 context()->setMemoryAllocation(m_suggestHaveBackbufferYes); 146 context()->setMemoryAllocation(m_suggestHaveBackbufferYes);
150 EXPECT_EQ(0, m_mockClient.setFullRootLayerDamageCount()); 147 EXPECT_EQ(0, m_mockClient.setFullRootLayerDamageCount());
151 EXPECT_FALSE(m_renderer.isFramebufferDiscarded()); 148 EXPECT_FALSE(m_renderer.isFramebufferDiscarded());
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 virtual void getUniformiv(WebGLId program, WGC3Dint location, WGC3Dint* valu e) { ADD_FAILURE(); } 285 virtual void getUniformiv(WebGLId program, WGC3Dint location, WGC3Dint* valu e) { ADD_FAILURE(); }
289 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name) { ADD_FAILURE(); return 0; } 286 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name) { ADD_FAILURE(); return 0; }
290 virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE(); } 287 virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE(); }
291 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* v alue) { ADD_FAILURE(); } 288 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* v alue) { ADD_FAILURE(); }
292 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname ) { ADD_FAILURE(); return 0; } 289 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname ) { ADD_FAILURE(); return 0; }
293 }; 290 };
294 291
295 // This test isn't using the same fixture as GLRendererTest, and you can't mix T EST() and TEST_F() with the same name, hence LRC2. 292 // This test isn't using the same fixture as GLRendererTest, and you can't mix T EST() and TEST_F() with the same name, hence LRC2.
296 TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls) 293 TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls)
297 { 294 {
298 ScopedSettings scopedSettings;
299 FakeRendererClient mockClient; 295 FakeRendererClient mockClient;
300 scoped_ptr<GraphicsContext> context(FakeWebCompositorOutputSurface::create(s coped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext))); 296 scoped_ptr<GraphicsContext> context(FakeWebCompositorOutputSurface::create(s coped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext)));
301 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get())); 297 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
302 FakeRendererGL renderer(&mockClient, resourceProvider.get()); 298 FakeRendererGL renderer(&mockClient, resourceProvider.get());
303 299
304 EXPECT_TRUE(renderer.initialize()); 300 EXPECT_TRUE(renderer.initialize());
305 } 301 }
306 302
307 class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D { 303 class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D {
308 public: 304 public:
(...skipping 23 matching lines...) Expand all
332 { 328 {
333 return m_contextLost ? 1 : 0; 329 return m_contextLost ? 1 : 0;
334 } 330 }
335 331
336 private: 332 private:
337 bool m_contextLost; 333 bool m_contextLost;
338 }; 334 };
339 335
340 TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert) 336 TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert)
341 { 337 {
342 ScopedSettings scopedSettings;
343 FakeRendererClient mockClient; 338 FakeRendererClient mockClient;
344 scoped_ptr<GraphicsContext> context(FakeWebCompositorOutputSurface::create(s coped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext))); 339 scoped_ptr<GraphicsContext> context(FakeWebCompositorOutputSurface::create(s coped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext)));
345 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get())); 340 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
346 FakeRendererGL renderer(&mockClient, resourceProvider.get()); 341 FakeRendererGL renderer(&mockClient, resourceProvider.get());
347 342
348 renderer.initialize(); 343 renderer.initialize();
349 } 344 }
350 345
351 class ContextThatDoesNotSupportMemoryManagmentExtensions : public FakeWebGraphic sContext3D { 346 class ContextThatDoesNotSupportMemoryManagmentExtensions : public FakeWebGraphic sContext3D {
352 public: 347 public:
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 540
546 for (cc::QuadList::backToFrontIterator it = pass->quadList().backToFrontBegi n(); 541 for (cc::QuadList::backToFrontIterator it = pass->quadList().backToFrontBegi n();
547 it != pass->quadList().backToFrontEnd(); ++it) { 542 it != pass->quadList().backToFrontEnd(); ++it) {
548 renderer.drawQuad(drawingFrame, *it); 543 renderer.drawQuad(drawingFrame, *it);
549 } 544 }
550 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); 545 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0);
551 } 546 }
552 547
553 } // namespace 548 } // namespace
554 } // namespace cc 549 } // namespace cc
OLDNEW
« no previous file with comments | « cc/gl_renderer.cc ('k') | cc/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698