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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 478703002: Remove cc::LayerTreeHostImpl::IsContextLost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ctx4
Patch Set: Include all changes. Prev patchset was second stage only Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 is_animating, 2121 is_animating,
2122 host_impl_->resource_provider())); 2122 host_impl_->resource_provider()));
2123 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2123 host_impl_->active_tree()->SetRequiresHighResToDraw();
2124 LayerTreeHostImpl::FrameData frame; 2124 LayerTreeHostImpl::FrameData frame;
2125 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2125 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2126 host_impl_->PrepareToDraw(&frame)); 2126 host_impl_->PrepareToDraw(&frame));
2127 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2127 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2128 host_impl_->DidDrawAllLayers(frame); 2128 host_impl_->DidDrawAllLayers(frame);
2129 } 2129 }
2130 2130
2131 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenSurfaceLost) {
2132 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
2133 host_impl_->DidLoseOutputSurface();
2134 LayerTreeHostImpl::FrameData frame;
2135 EXPECT_EQ(DRAW_ABORTED_CONTEXT_LOST, host_impl_->PrepareToDraw(&frame));
2136 }
2137
2131 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 2138 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
2132 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2139 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2133 root->SetScrollClipLayer(Layer::INVALID_ID); 2140 root->SetScrollClipLayer(Layer::INVALID_ID);
2134 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2141 host_impl_->active_tree()->SetRootLayer(root.Pass());
2135 DrawFrame(); 2142 DrawFrame();
2136 2143
2137 // Scroll event is ignored because layer is not scrollable. 2144 // Scroll event is ignored because layer is not scrollable.
2138 EXPECT_EQ(InputHandler::ScrollIgnored, 2145 EXPECT_EQ(InputHandler::ScrollIgnored,
2139 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); 2146 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
2140 EXPECT_FALSE(did_request_redraw_); 2147 EXPECT_FALSE(did_request_redraw_);
(...skipping 4862 matching lines...) Expand 10 before | Expand all | Expand 10 after
7003 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} 7010 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {}
7004 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE { 7011 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {
7005 num_lost_surfaces_++; 7012 num_lost_surfaces_++;
7006 } 7013 }
7007 7014
7008 protected: 7015 protected:
7009 int num_lost_surfaces_; 7016 int num_lost_surfaces_;
7010 }; 7017 };
7011 7018
7012 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { 7019 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) {
7013 // The medium term, we plan to remove LayerTreeHostImpl::IsContextLost().
7014 // Until then, we need the state variable
7015 // LayerTreeHostImpl::have_valid_output_surface_ and we can
7016 // enforce the following behaviour, where calling DidLoseOutputSurface
7017 // twice in a row only causes one subsequent
7018 // call to LayerTreeHostImplClient::DidLoseOutputSurfaceOnImplThread().
7019 // Really we just need at least one client notification each time 7020 // Really we just need at least one client notification each time
7020 // we go from having a valid output surface to not having a valid output 7021 // we go from having a valid output surface to not having a valid output
7021 // surface. 7022 // surface.
7022 EXPECT_EQ(0, num_lost_surfaces_); 7023 EXPECT_EQ(0, num_lost_surfaces_);
7023 EXPECT_FALSE(host_impl_->IsContextLost());
7024 host_impl_->DidLoseOutputSurface(); 7024 host_impl_->DidLoseOutputSurface();
7025 EXPECT_TRUE(host_impl_->IsContextLost());
7026 EXPECT_EQ(1, num_lost_surfaces_); 7025 EXPECT_EQ(1, num_lost_surfaces_);
7027 host_impl_->DidLoseOutputSurface(); 7026 host_impl_->DidLoseOutputSurface();
7028 EXPECT_TRUE(host_impl_->IsContextLost());
7029 EXPECT_EQ(1, num_lost_surfaces_); 7027 EXPECT_EQ(1, num_lost_surfaces_);
7030 } 7028 }
7031 7029
7032 } // namespace 7030 } // namespace
7033 } // namespace cc 7031 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698