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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 1247033007: cc: Abort frame when becoming invisible and waiting for ready to draw. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove race from test Created 5 years, 5 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.cc ('k') | cc/trees/single_thread_proxy.cc » ('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 470a63b1b3ae3651e581e45e3b81796ba712c75e..e64d28df7bee0343fc7d0c2fa5869b899c749eed 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -272,6 +272,79 @@ class LayerTreeHostTestReadyToDrawNonEmpty
// single threaded mode.
SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty);
+// This tests if we get the READY_TO_DRAW signal and draw if we become invisible
+// and then become visible again.
+class LayerTreeHostTestReadyToDrawVisibility : public LayerTreeHostTest {
+ public:
+ LayerTreeHostTestReadyToDrawVisibility()
+ : LayerTreeHostTest(),
+ toggled_visibility_(false),
+ did_notify_ready_to_draw_(false),
+ did_draw_(false) {}
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void SetupTree() override {
+ client_.set_fill_with_nonsolid_color(true);
+ scoped_refptr<FakePictureLayer> root_layer =
+ FakePictureLayer::Create(layer_settings(), &client_);
+ root_layer->SetBounds(gfx::Size(1024, 1024));
+ root_layer->SetIsDrawable(true);
+
+ layer_tree_host()->SetRootLayer(root_layer);
+ LayerTreeHostTest::SetupTree();
+ }
+
+ void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
+ if (!toggled_visibility_) {
+ {
+ DebugScopedSetMainThread main(proxy());
+ layer_tree_host()->SetVisible(false);
+ }
+ toggled_visibility_ = true;
+ EXPECT_FALSE(host_impl->visible());
+ }
+ }
+
+ void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) override {
+ // Sometimes the worker thread posts NotifyReadyToDraw in the extremely
+ // short duration of time between PrepareTiles and SetVisible(false) so we
+ // might get two NotifyReadyToDraw signals for this test.
+ did_notify_ready_to_draw_ = true;
+ }
+
+ void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
+ EXPECT_FALSE(did_draw_);
+ did_draw_ = true;
+ EndTest();
+ }
+
+ void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override {
+ if (!host_impl->visible()) {
+ {
+ DebugScopedSetMainThread main(proxy());
+ layer_tree_host()->SetVisible(true);
+ }
+ EXPECT_TRUE(host_impl->visible());
+ }
+ }
+
+ void AfterTest() override {
+ EXPECT_TRUE(did_notify_ready_to_draw_);
+ EXPECT_TRUE(did_draw_);
+ }
+
+ private:
+ FakeContentLayerClient client_;
+ bool toggled_visibility_;
+ bool did_notify_ready_to_draw_;
+ bool did_draw_;
+};
+
+// Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in
+// single threaded mode.
+SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility);
+
class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
public:
scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/single_thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698