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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 12211110: Implement WebKit::WebUnitTestSupport::createLayerTreeViewForTesting() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add enum, fix NON_EXPORTED_BASE Created 7 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/gl_renderer_unittest.cc ('k') | cc/layer_tree_host_unittest.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layer_tree_host_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "cc/quad_sink.h" 21 #include "cc/quad_sink.h"
22 #include "cc/render_pass_draw_quad.h" 22 #include "cc/render_pass_draw_quad.h"
23 #include "cc/scrollbar_geometry_fixed_thumb.h" 23 #include "cc/scrollbar_geometry_fixed_thumb.h"
24 #include "cc/scrollbar_layer_impl.h" 24 #include "cc/scrollbar_layer_impl.h"
25 #include "cc/single_thread_proxy.h" 25 #include "cc/single_thread_proxy.h"
26 #include "cc/solid_color_draw_quad.h" 26 #include "cc/solid_color_draw_quad.h"
27 #include "cc/test/animation_test_common.h" 27 #include "cc/test/animation_test_common.h"
28 #include "cc/test/fake_output_surface.h" 28 #include "cc/test/fake_output_surface.h"
29 #include "cc/test/fake_proxy.h" 29 #include "cc/test/fake_proxy.h"
30 #include "cc/test/fake_video_frame_provider.h" 30 #include "cc/test/fake_video_frame_provider.h"
31 #include "cc/test/fake_web_graphics_context_3d.h"
32 #include "cc/test/fake_web_scrollbar_theme_geometry.h" 31 #include "cc/test/fake_web_scrollbar_theme_geometry.h"
33 #include "cc/test/geometry_test_utils.h" 32 #include "cc/test/geometry_test_utils.h"
34 #include "cc/test/layer_test_common.h" 33 #include "cc/test/layer_test_common.h"
35 #include "cc/test/render_pass_test_common.h" 34 #include "cc/test/render_pass_test_common.h"
35 #include "cc/test/test_web_graphics_context_3d.h"
36 #include "cc/texture_draw_quad.h" 36 #include "cc/texture_draw_quad.h"
37 #include "cc/texture_layer_impl.h" 37 #include "cc/texture_layer_impl.h"
38 #include "cc/tile_draw_quad.h" 38 #include "cc/tile_draw_quad.h"
39 #include "cc/tiled_layer_impl.h" 39 #include "cc/tiled_layer_impl.h"
40 #include "cc/video_layer_impl.h" 40 #include "cc/video_layer_impl.h"
41 #include "media/base/media.h" 41 #include "media/base/media.h"
42 #include "testing/gmock/include/gmock/gmock.h" 42 #include "testing/gmock/include/gmock/gmock.h"
43 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
44 #include "ui/gfx/size_conversions.h" 44 #include "ui/gfx/size_conversions.h"
45 #include "ui/gfx/vector2d_conversions.h" 45 #include "ui/gfx/vector2d_conversions.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 scoped_ptr<LayerTreeHostImpl> m_hostImpl; 226 scoped_ptr<LayerTreeHostImpl> m_hostImpl;
227 bool m_onCanDrawStateChangedCalled; 227 bool m_onCanDrawStateChangedCalled;
228 bool m_hasPendingTree; 228 bool m_hasPendingTree;
229 bool m_didRequestCommit; 229 bool m_didRequestCommit;
230 bool m_didRequestRedraw; 230 bool m_didRequestRedraw;
231 bool m_didUploadVisibleHighResolutionTile; 231 bool m_didUploadVisibleHighResolutionTile;
232 bool m_reduceMemoryResult; 232 bool m_reduceMemoryResult;
233 }; 233 };
234 234
235 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D { 235 class TestWebGraphicsContext3DMakeCurrentFails : public TestWebGraphicsContext3D {
236 public: 236 public:
237 virtual bool makeContextCurrent() { return false; } 237 virtual bool makeContextCurrent() { return false; }
238 }; 238 };
239 239
240 TEST_P(LayerTreeHostImplTest, notifyIfCanDrawChanged) 240 TEST_P(LayerTreeHostImplTest, notifyIfCanDrawChanged)
241 { 241 {
242 // Note: It is not possible to disable the renderer once it has been set, 242 // Note: It is not possible to disable the renderer once it has been set,
243 // so we do not need to test that disabling the renderer notifies us 243 // so we do not need to test that disabling the renderer notifies us
244 // that canDraw changed. 244 // that canDraw changed.
245 EXPECT_FALSE(m_hostImpl->canDraw()); 245 EXPECT_FALSE(m_hostImpl->canDraw());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // We should not crash when trying to scroll an empty layer tree. 380 // We should not crash when trying to scroll an empty layer tree.
381 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 381 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
382 } 382 }
383 383
384 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) 384 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer)
385 { 385 {
386 LayerTreeSettings settings; 386 LayerTreeSettings settings;
387 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); 387 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
388 388
389 // Initialization will fail here. 389 // Initialization will fail here.
390 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit ::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<Ou tputSurface>()); 390 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit ::WebGraphicsContext3D>(new TestWebGraphicsContext3DMakeCurrentFails)).PassAs<Ou tputSurface>());
391 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); 391 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
392 392
393 setupScrollAndContentsLayers(gfx::Size(100, 100)); 393 setupScrollAndContentsLayers(gfx::Size(100, 100));
394 394
395 // We should not crash when trying to scroll after the renderer initializati on fails. 395 // We should not crash when trying to scroll after the renderer initializati on fails.
396 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 396 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
397 } 397 }
398 398
399 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) 399 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling)
400 { 400 {
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 gfx::Vector2d wheelScrollDelta(0, 10); 1710 gfx::Vector2d wheelScrollDelta(0, 10);
1711 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1711 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1712 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); 1712 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta);
1713 m_hostImpl->scrollEnd(); 1713 m_hostImpl->scrollEnd();
1714 1714
1715 // The scale should not have been applied to the scroll delta. 1715 // The scale should not have been applied to the scroll delta.
1716 scrollInfo = m_hostImpl->processScrollDeltas(); 1716 scrollInfo = m_hostImpl->processScrollDeltas();
1717 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); 1717 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta);
1718 } 1718 }
1719 1719
1720 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { 1720 class BlendStateTrackerContext: public TestWebGraphicsContext3D {
1721 public: 1721 public:
1722 BlendStateTrackerContext() : m_blend(false) { } 1722 BlendStateTrackerContext() : m_blend(false) { }
1723 1723
1724 virtual void enable(WebKit::WGC3Denum cap) 1724 virtual void enable(WebKit::WGC3Denum cap)
1725 { 1725 {
1726 if (cap == GL_BLEND) 1726 if (cap == GL_BLEND)
1727 m_blend = true; 1727 m_blend = true;
1728 } 1728 }
1729 1729
1730 virtual void disable(WebKit::WGC3Denum cap) 1730 virtual void disable(WebKit::WGC3Denum cap)
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 EXPECT_EQ(4u, numGutterQuads); 2072 EXPECT_EQ(4u, numGutterQuads);
2073 EXPECT_EQ(5u, frame.renderPasses[0]->quad_list.size()); 2073 EXPECT_EQ(5u, frame.renderPasses[0]->quad_list.size());
2074 2074
2075 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad _list, gfx::Rect(gfx::Point(), viewportSize)); 2075 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad _list, gfx::Rect(gfx::Point(), viewportSize));
2076 m_hostImpl->didDrawAllLayers(frame); 2076 m_hostImpl->didDrawAllLayers(frame);
2077 } 2077 }
2078 2078
2079 } 2079 }
2080 2080
2081 2081
2082 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { 2082 class ReshapeTrackerContext: public TestWebGraphicsContext3D {
2083 public: 2083 public:
2084 ReshapeTrackerContext() : m_reshapeCalled(false) { } 2084 ReshapeTrackerContext() : m_reshapeCalled(false) { }
2085 2085
2086 virtual void reshape(int width, int height) 2086 virtual void reshape(int width, int height)
2087 { 2087 {
2088 m_reshapeCalled = true; 2088 m_reshapeCalled = true;
2089 } 2089 }
2090 2090
2091 bool reshapeCalled() const { return m_reshapeCalled; } 2091 bool reshapeCalled() const { return m_reshapeCalled; }
2092 2092
(...skipping 24 matching lines...) Expand all
2117 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 2117 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
2118 EXPECT_FALSE(reshapeTracker->reshapeCalled()); 2118 EXPECT_FALSE(reshapeTracker->reshapeCalled());
2119 2119
2120 LayerTreeHostImpl::FrameData frame; 2120 LayerTreeHostImpl::FrameData frame;
2121 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2121 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2122 m_hostImpl->drawLayers(frame); 2122 m_hostImpl->drawLayers(frame);
2123 EXPECT_TRUE(reshapeTracker->reshapeCalled()); 2123 EXPECT_TRUE(reshapeTracker->reshapeCalled());
2124 m_hostImpl->didDrawAllLayers(frame); 2124 m_hostImpl->didDrawAllLayers(frame);
2125 } 2125 }
2126 2126
2127 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { 2127 class PartialSwapTrackerContext : public TestWebGraphicsContext3D {
2128 public: 2128 public:
2129 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) 2129 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height)
2130 { 2130 {
2131 m_partialSwapRect = gfx::Rect(x, y, width, height); 2131 m_partialSwapRect = gfx::Rect(x, y, width, height);
2132 } 2132 }
2133 2133
2134 virtual WebKit::WebString getString(WebKit::WGC3Denum name) 2134 virtual WebKit::WebString getString(WebKit::WGC3Denum name)
2135 { 2135 {
2136 if (name == GL_EXTENSIONS) 2136 if (name == GL_EXTENSIONS)
2137 return WebKit::WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_se t_visibility"); 2137 return WebKit::WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_se t_visibility");
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); 2261 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData);
2262 } 2262 }
2263 2263
2264 private: 2264 private:
2265 FakeLayerWithQuads(LayerTreeImpl* treeImpl, int id) 2265 FakeLayerWithQuads(LayerTreeImpl* treeImpl, int id)
2266 : LayerImpl(treeImpl, id) 2266 : LayerImpl(treeImpl, id)
2267 { 2267 {
2268 } 2268 }
2269 }; 2269 };
2270 2270
2271 class MockContext : public FakeWebGraphicsContext3D { 2271 class MockContext : public TestWebGraphicsContext3D {
2272 public: 2272 public:
2273 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); 2273 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program));
2274 MOCK_METHOD5(uniform4f, void(WebKit::WGC3Dint location, WebKit::WGC3Dfloat x , WebKit::WGC3Dfloat y, WebKit::WGC3Dfloat z, WebKit::WGC3Dfloat w)); 2274 MOCK_METHOD5(uniform4f, void(WebKit::WGC3Dint location, WebKit::WGC3Dfloat x , WebKit::WGC3Dfloat y, WebKit::WGC3Dfloat z, WebKit::WGC3Dfloat w));
2275 MOCK_METHOD4(uniformMatrix4fv, void(WebKit::WGC3Dint location, WebKit::WGC3D sizei count, WebKit::WGC3Dboolean transpose, const WebKit::WGC3Dfloat* value)); 2275 MOCK_METHOD4(uniformMatrix4fv, void(WebKit::WGC3Dint location, WebKit::WGC3D sizei count, WebKit::WGC3Dboolean transpose, const WebKit::WGC3Dfloat* value));
2276 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); 2276 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset));
2277 MOCK_METHOD1(getString, WebKit::WebString(WebKit::WGC3Denum name)); 2277 MOCK_METHOD1(getString, WebKit::WebString(WebKit::WGC3Denum name));
2278 MOCK_METHOD0(getRequestableExtensionsCHROMIUM, WebKit::WebString()); 2278 MOCK_METHOD0(getRequestableExtensionsCHROMIUM, WebKit::WebString());
2279 MOCK_METHOD1(enable, void(WebKit::WGC3Denum cap)); 2279 MOCK_METHOD1(enable, void(WebKit::WGC3Denum cap));
2280 MOCK_METHOD1(disable, void(WebKit::WGC3Denum cap)); 2280 MOCK_METHOD1(disable, void(WebKit::WGC3Denum cap));
2281 MOCK_METHOD4(scissor, void(WebKit::WGC3Dint x, WebKit::WGC3Dint y, WebKit::W GC3Dsizei width, WebKit::WGC3Dsizei height)); 2281 MOCK_METHOD4(scissor, void(WebKit::WGC3Dint x, WebKit::WGC3Dint y, WebKit::W GC3Dsizei width, WebKit::WGC3Dsizei height));
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 harness.mustDrawSolidQuad(); 2419 harness.mustDrawSolidQuad();
2420 { 2420 {
2421 LayerTreeHostImpl::FrameData frame; 2421 LayerTreeHostImpl::FrameData frame;
2422 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2422 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2423 m_hostImpl->drawLayers(frame); 2423 m_hostImpl->drawLayers(frame);
2424 m_hostImpl->didDrawAllLayers(frame); 2424 m_hostImpl->didDrawAllLayers(frame);
2425 } 2425 }
2426 Mock::VerifyAndClearExpectations(&mockContext); 2426 Mock::VerifyAndClearExpectations(&mockContext);
2427 } 2427 }
2428 2428
2429 class PartialSwapContext : public FakeWebGraphicsContext3D { 2429 class PartialSwapContext : public TestWebGraphicsContext3D {
2430 public: 2430 public:
2431 virtual WebKit::WebString getString(WebKit::WGC3Denum name) 2431 virtual WebKit::WebString getString(WebKit::WGC3Denum name)
2432 { 2432 {
2433 if (name == GL_EXTENSIONS) 2433 if (name == GL_EXTENSIONS)
2434 return WebKit::WebString("GL_CHROMIUM_post_sub_buffer"); 2434 return WebKit::WebString("GL_CHROMIUM_post_sub_buffer");
2435 return WebKit::WebString(); 2435 return WebKit::WebString();
2436 } 2436 }
2437 2437
2438 virtual WebKit::WebString getRequestableExtensionsCHROMIUM() 2438 virtual WebKit::WebString getRequestableExtensionsCHROMIUM()
2439 { 2439 {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2550 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size()); 2550 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size());
2551 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quad_list[0]->ma terial); 2551 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quad_list[0]->ma terial);
2552 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma terial); 2552 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma terial);
2553 2553
2554 myHostImpl->drawLayers(frame); 2554 myHostImpl->drawLayers(frame);
2555 myHostImpl->didDrawAllLayers(frame); 2555 myHostImpl->didDrawAllLayers(frame);
2556 } 2556 }
2557 } 2557 }
2558 2558
2559 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use. 2559 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use.
2560 class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D { 2560 class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D {
2561 public: 2561 public:
2562 TrackingWebGraphicsContext3D() 2562 TrackingWebGraphicsContext3D()
2563 : FakeWebGraphicsContext3D() 2563 : TestWebGraphicsContext3D()
2564 , m_numTextures(0) 2564 , m_numTextures(0)
2565 { } 2565 { }
2566 2566
2567 virtual WebKit::WebGLId createTexture() OVERRIDE 2567 virtual WebKit::WebGLId createTexture() OVERRIDE
2568 { 2568 {
2569 WebKit::WebGLId id = FakeWebGraphicsContext3D::createTexture(); 2569 WebKit::WebGLId id = TestWebGraphicsContext3D::createTexture();
2570 2570
2571 m_textures[id] = true; 2571 m_textures[id] = true;
2572 ++m_numTextures; 2572 ++m_numTextures;
2573 return id; 2573 return id;
2574 } 2574 }
2575 2575
2576 virtual void deleteTexture(WebKit::WebGLId id) OVERRIDE 2576 virtual void deleteTexture(WebKit::WebGLId id) OVERRIDE
2577 { 2577 {
2578 if (m_textures.find(id) == m_textures.end()) 2578 if (m_textures.find(id) == m_textures.end())
2579 return; 2579 return;
(...skipping 26 matching lines...) Expand all
2606 } 2606 }
2607 2607
2608 static unsigned createTextureId(ResourceProvider* resourceProvider) 2608 static unsigned createTextureId(ResourceProvider* resourceProvider)
2609 { 2609 {
2610 return ResourceProvider::ScopedReadLockGL( 2610 return ResourceProvider::ScopedReadLockGL(
2611 resourceProvider, createResourceId(resourceProvider)).textureId(); 2611 resourceProvider, createResourceId(resourceProvider)).textureId();
2612 } 2612 }
2613 2613
2614 TEST_P(LayerTreeHostImplTest, layersFreeTextures) 2614 TEST_P(LayerTreeHostImplTest, layersFreeTextures)
2615 { 2615 {
2616 scoped_ptr<FakeWebGraphicsContext3D> context = 2616 scoped_ptr<TestWebGraphicsContext3D> context =
2617 FakeWebGraphicsContext3D::Create(); 2617 TestWebGraphicsContext3D::Create();
2618 FakeWebGraphicsContext3D* context3d = context.get(); 2618 TestWebGraphicsContext3D* context3d = context.get();
2619 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d( 2619 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(
2620 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); 2620 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
2621 m_hostImpl->initializeRenderer(outputSurface.Pass()); 2621 m_hostImpl->initializeRenderer(outputSurface.Pass());
2622 2622
2623 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl->activeTree(), 1)); 2623 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl->activeTree(), 1));
2624 rootLayer->setBounds(gfx::Size(10, 10)); 2624 rootLayer->setBounds(gfx::Size(10, 10));
2625 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); 2625 rootLayer->setAnchorPoint(gfx::PointF(0, 0));
2626 2626
2627 scoped_refptr<VideoFrame> softwareFrame(media::VideoFrame::CreateColorFrame( 2627 scoped_refptr<VideoFrame> softwareFrame(media::VideoFrame::CreateColorFrame(
2628 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta())); 2628 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()));
(...skipping 25 matching lines...) Expand all
2654 m_hostImpl->swapBuffers(); 2654 m_hostImpl->swapBuffers();
2655 2655
2656 EXPECT_GT(context3d->NumTextures(), 0u); 2656 EXPECT_GT(context3d->NumTextures(), 0u);
2657 2657
2658 // Kill the layer tree. 2658 // Kill the layer tree.
2659 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::create(m_hostImpl->activeT ree(), 100)); 2659 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::create(m_hostImpl->activeT ree(), 100));
2660 // There should be no textures left in use after. 2660 // There should be no textures left in use after.
2661 EXPECT_EQ(0u, context3d->NumTextures()); 2661 EXPECT_EQ(0u, context3d->NumTextures());
2662 } 2662 }
2663 2663
2664 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { 2664 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D {
2665 public: 2665 public:
2666 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); 2666 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program));
2667 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); 2667 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset));
2668 }; 2668 };
2669 2669
2670 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) 2670 TEST_P(LayerTreeHostImplTest, hasTransparentBackground)
2671 { 2671 {
2672 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs <OutputSurface>(); 2672 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs <OutputSurface>();
2673 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF illScreenContext*>(outputSurface->Context3D()); 2673 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF illScreenContext*>(outputSurface->Context3D());
2674 2674
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
4037 testCaseIndex++; 4037 testCaseIndex++;
4038 } 4038 }
4039 } 4039 }
4040 4040
4041 class LayerTreeHostImplTestWithDelegatingRenderer : public LayerTreeHostImplTest { 4041 class LayerTreeHostImplTestWithDelegatingRenderer : public LayerTreeHostImplTest {
4042 protected: 4042 protected:
4043 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE 4043 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE
4044 { 4044 {
4045 // Creates an output surface with a parent to use a delegating renderer. 4045 // Creates an output surface with a parent to use a delegating renderer.
4046 WebKit::WebGraphicsContext3D::Attributes attrs; 4046 WebKit::WebGraphicsContext3D::Attributes attrs;
4047 return FakeOutputSurface::CreateDelegating3d(FakeWebGraphicsContext3D::C reate(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); 4047 return FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::C reate(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
4048 } 4048 }
4049 4049
4050 void drawFrameAndTestDamage(const gfx::RectF& expectedDamage) { 4050 void drawFrameAndTestDamage(const gfx::RectF& expectedDamage) {
4051 LayerTreeHostImpl::FrameData frame; 4051 LayerTreeHostImpl::FrameData frame;
4052 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 4052 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
4053 ASSERT_EQ(1u, frame.renderPasses.size()); 4053 ASSERT_EQ(1u, frame.renderPasses.size());
4054 4054
4055 // Verify the damage rect for the root render pass. 4055 // Verify the damage rect for the root render pass.
4056 const RenderPass* rootRenderPass = frame.renderPasses.back(); 4056 const RenderPass* rootRenderPass = frame.renderPasses.back();
4057 EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect); 4057 EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
4334 m_hostImpl->didDrawAllLayers(frame); 4334 m_hostImpl->didDrawAllLayers(frame);
4335 } 4335 }
4336 } 4336 }
4337 4337
4338 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4338 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4339 LayerTreeHostImplTest, 4339 LayerTreeHostImplTest,
4340 ::testing::Values(false, true)); 4340 ::testing::Values(false, true));
4341 4341
4342 } // namespace 4342 } // namespace
4343 } // namespace cc 4343 } // namespace cc
OLDNEW
« no previous file with comments | « cc/gl_renderer_unittest.cc ('k') | cc/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698