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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 14772021: cc::OutputSurfaceClient::InitializeForGL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile by including ContextProvider from output_surface_client.h Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/single_thread_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/single_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698