| 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..5a92d0b58b3fd80264f5572af1164fc8bde976d2 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,71 @@ 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 {
|
| + scoped_ptr<TestWebGraphicsContext3D> context3d(
|
| + TestWebGraphicsContext3D::Create());
|
| + context3d->set_support_swapbuffers_complete_callback(false);
|
| +
|
| + return FakeOutputSurface::CreateDeferredGL(
|
| + context3d.PassAs<WebKit::WebGraphicsContext3D>(),
|
| + 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));
|
| + }
|
| +
|
| + virtual void AfterTest() OVERRIDE {
|
| + EXPECT_TRUE(initialized_gl_);
|
| + }
|
| +
|
| + private:
|
| + FakeContentLayerClient client_;
|
| + scoped_refptr<FakePictureLayer> layer_;
|
| + bool initialized_gl_;
|
| +};
|
| +
|
| +MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|