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..b2a617128078e542b86f1214169bc0ef627d5e76 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,67 @@ 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()); |
+ EndTest(); |
+ } |
+ } |
+ |
+ 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)); |
boliu
2013/06/06 19:27:14
And of course, test did not pass when enabled, so
danakj
2013/06/06 19:36:13
Note you could also SetNeedsDisplay() on the main
boliu
2013/06/06 20:18:13
Yep you are right. I misunderstood next_frame_is_n
|
+ // PostSetNeedsCommitToMainThread(); |
boliu
2013/06/06 19:27:14
Arg...going to remove this in next PS.
|
+ } |
+ |
+ virtual void AfterTest() OVERRIDE {} |
danakj
2013/06/06 19:36:13
It'd be nice to test initialized_gl_ = true here s
boliu
2013/06/06 20:18:13
Done.
|
+ |
+ private: |
+ FakeContentLayerClient client_; |
+ scoped_refptr<FakePictureLayer> layer_; |
+ bool initialized_gl_; |
+}; |
+ |
+MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
+ |
} // namespace |
} // namespace cc |