| 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 eb81d5b8e8a200dfb9e353a878cca21e998877a2..53208487e2ec62927bc244570a8adb7d9afed91e 100644
|
| --- a/cc/trees/layer_tree_host_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_unittest.cc
|
| @@ -3015,9 +3015,6 @@ class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest {
|
|
|
| virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
|
| OVERRIDE {
|
| - scoped_ptr<TestWebGraphicsContext3D> context3d(
|
| - TestWebGraphicsContext3D::Create());
|
| -
|
| return FakeOutputSurface::CreateDeferredGL(
|
| scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice));
|
| }
|
| @@ -3093,6 +3090,98 @@ class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest {
|
|
|
| MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
|
|
|
| +class LayerTreeHostTestAbortFrameOnStaleRendererCapabilities
|
| + : public LayerTreeHostTest {
|
| + public:
|
| + virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
|
| + settings->impl_side_painting = true;
|
| + }
|
| +
|
| + virtual void SetupTree() OVERRIDE {
|
| + layer_ = FakePictureLayer::Create(&client_);
|
| + // Make sure commits are not aborted due to no update.
|
| + layer_->set_always_update_resources(true);
|
| + layer_tree_host()->SetRootLayer(layer_);
|
| + LayerTreeHostTest::SetupTree();
|
| + }
|
| +
|
| + virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
|
| + OVERRIDE {
|
| + return FakeOutputSurface::CreateDeferredGL(
|
| + scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice));
|
| + }
|
| +
|
| + virtual void BeginTest() OVERRIDE {
|
| + aborted_frames_ = 0;
|
| + main_frame_attempts_ = 0;
|
| + PostSetNeedsCommitToMainThread();
|
| + }
|
| +
|
| + virtual void WillBeginMainFrame() OVERRIDE {
|
| + int frame_number = layer_tree_host()->source_frame_number();
|
| + EXPECT_EQ(0, frame_number); // Only one frame.
|
| + main_frame_attempts_++;
|
| + // Main frame should only be aborted once.
|
| + EXPECT_LE(main_frame_attempts_, 2);
|
| +
|
| + if (main_frame_attempts_ == 1) {
|
| + // Capabilities updated once on first renderer init.
|
| + EXPECT_EQ(1u, layer_->renderer_capabilities_changed_count());
|
| + layer_->reset_renderer_capabilities_changed_count();
|
| +
|
| + // Make sure first main frame attempt gets aborted due to stale renderer
|
| + // capabilities by synchronously updating renderer capabilities on impl
|
| + // thread.
|
| + CompletionEvent completion;
|
| + ImplThreadTaskRunner()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&LayerTreeHostTestAbortFrameOnStaleRendererCapabilities::
|
| + UpdateRendererCapabilities,
|
| + base::Unretained(this),
|
| + &completion));
|
| + completion.Wait();
|
| + } else {
|
| + // Capabilities updated again before second attempt of first frame.
|
| + EXPECT_EQ(1u, layer_->renderer_capabilities_changed_count());
|
| + layer_->reset_renderer_capabilities_changed_count();
|
| + }
|
| + }
|
| +
|
| + void UpdateRendererCapabilities(CompletionEvent* completion) {
|
| + // Change renderer capabilities by switching renderers.
|
| + scoped_refptr<TestContextProvider> context_provider =
|
| + TestContextProvider::Create();
|
| + EXPECT_TRUE(
|
| + output_surface()->InitializeAndSetContext3d(context_provider, NULL));
|
| + completion->Signal();
|
| + }
|
| +
|
| + virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
|
| + bool did_handle) OVERRIDE {
|
| + EXPECT_TRUE(did_handle);
|
| + aborted_frames_ += 1;
|
| + }
|
| +
|
| + virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
|
| + EndTest();
|
| + }
|
| +
|
| + virtual void AfterTest() OVERRIDE {
|
| + // First main frame should have been attempted twice.
|
| + EXPECT_EQ(2, main_frame_attempts_);
|
| + // First attempt should have been aborted.
|
| + EXPECT_EQ(1, aborted_frames_);
|
| + }
|
| +
|
| + private:
|
| + FakeContentLayerClient client_;
|
| + scoped_refptr<FakePictureLayer> layer_;
|
| + int main_frame_attempts_;
|
| + int aborted_frames_;
|
| +};
|
| +
|
| +MULTI_THREAD_TEST_F(LayerTreeHostTestAbortFrameOnStaleRendererCapabilities);
|
| +
|
| // Test for UI Resource management.
|
| class LayerTreeHostTestUIResource : public LayerTreeHostTest {
|
| public:
|
|
|