Chromium Code Reviews| Index: cc/trees/layer_tree_host_unittest.cc |
| diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc |
| index 65b8e2454a8254e9a14021b3cb72d6d40016c70f..bbaff393d90df2127cad8faa12853d4e49eaa34f 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -25,6 +25,8 @@ |
| #include "cc/test/fake_content_layer_client.h" |
| #include "cc/test/fake_layer_tree_host_client.h" |
| #include "cc/test/fake_output_surface.h" |
| +#include "cc/test/fake_picture_layer.h" |
| +#include "cc/test/fake_picture_layer_impl.h" |
| #include "cc/test/fake_proxy.h" |
| #include "cc/test/fake_scrollbar_layer.h" |
| #include "cc/test/geometry_test_utils.h" |
| @@ -2878,5 +2880,70 @@ TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { |
| RunTest(true, false, true); |
| } |
| +class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest { |
| + public: |
| + virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| + // PictureLayer can only be used with impl side painting enabled. |
| + settings->impl_side_painting = true; |
| + } |
| + |
| + virtual void SetupTree() OVERRIDE { |
| + layer_ = FakePictureLayer::Create(&client_); |
| + layer_tree_host()->SetRootLayer(layer_); |
| + LayerTreeHostTest::SetupTree(); |
| + } |
| + |
| + virtual void BeginTest() OVERRIDE { |
| + initialized_gl_ = false; |
| + PostSetNeedsCommitToMainThread(); |
| + } |
| + |
| + virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { |
| + return FakeOutputSurface::CreateDeferredGL( |
| + scoped_ptr<WebKit::WebGraphicsContext3D>( |
| + TestWebGraphicsContext3D::Create()), |
| + scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) |
| + .PassAs<OutputSurface>(); |
| + } |
| + |
| + virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| + ASSERT_TRUE(host_impl->RootLayer()); |
| + FakePictureLayerImpl* layer_impl = |
| + static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); |
| + if (!initialized_gl_) { |
| + EXPECT_EQ(1u, layer_impl->append_quads_count()); |
| + EXPECT_TRUE( |
| + host_impl->DeferredInitialize(scoped_refptr<ContextProvider>())); |
| + initialized_gl_ = true; |
| + |
| + // Force redraw again. |
| + host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1)); |
|
danakj
2013/06/06 14:49:31
Why do you need this if you are causing a second c
boliu
2013/06/06 17:39:25
Removed PostSetNeedsCommitToMainThread below, and
|
| + } else { |
| + EXPECT_EQ(2u, layer_impl->append_quads_count()); |
| + } |
| + } |
| + |
| + virtual void DidCommitAndDrawFrame() OVERRIDE { |
| + if (layer_->update_count() == 1) { |
| + // Commit and draw again in hardware. |
| + PostSetNeedsCommitToMainThread(); |
| + } else { |
| + EndTest(); |
| + } |
| + } |
| + |
| + virtual void AfterTest() OVERRIDE { |
| + EXPECT_TRUE(initialized_gl_); |
| + EXPECT_EQ(2u, layer_->update_count()); |
| + } |
| + |
| + private: |
| + FakeContentLayerClient client_; |
| + scoped_refptr<FakePictureLayer> layer_; |
| + bool initialized_gl_; |
| +}; |
| + |
| +MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
| + |
| } // namespace |
| } // namespace cc |