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 89faf4938b1d6c28b3408eae9b6d96d82549eda6..399548872d02ba7d5b33fdd1864432d2ca2399dd 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" |
@@ -2841,5 +2843,73 @@ 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()); |
+ ImplThread()->PostTask(base::Bind( |
+ &LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw, |
+ base::Unretained(this), |
+ base::Unretained(host_impl))); |
+ } else { |
+ EXPECT_EQ(2u, layer_impl->append_quads_count()); |
+ } |
+ } |
+ |
+ void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { |
+ EXPECT_TRUE( |
+ host_impl->DeferredInitialize(scoped_refptr<ContextProvider>())); |
+ initialized_gl_ = true; |
+ |
+ // Force redraw again. |
+ host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1)); |
+ } |
+ |
+ virtual void DidCommitAndDrawFrame() OVERRIDE { |
+ if (layer_->update_count() == 2) |
+ 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); |
danakj
2013/06/06 17:53:39
Test looks good, but commented out?
|
+ |
} // namespace |
} // namespace cc |