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

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

Issue 23694031: Fix race conditions in window snapshot code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added screenshot sync test to telemetry unittests, updated cc unittest Created 7 years, 2 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 | Annotate | Revision Log
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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 if (sfn == kReadbackReplacementSourceFrameNumber) 630 if (sfn == kReadbackReplacementSourceFrameNumber)
631 EndTest(); 631 EndTest();
632 } 632 }
633 633
634 virtual void AfterTest() OVERRIDE {} 634 virtual void AfterTest() OVERRIDE {}
635 }; 635 };
636 636
637 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackAfterForcedDraw); 637 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackAfterForcedDraw);
638 638
639 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
640 public:
bajones 2013/09/27 20:50:11 @enne: Is this what you had in mind?
641 LayerTreeHostTestSetNextCommitForcesRedraw()
642 : num_draws_(0),
643 bounds_(50, 50),
644 root_layer_(ContentLayer::Create(&client_)) {
645 }
646
647 virtual void BeginTest() OVERRIDE {
648 root_layer_->SetIsDrawable(true);
649 root_layer_->SetBounds(bounds_);
650 layer_tree_host()->SetRootLayer(root_layer_);
651 layer_tree_host()->SetViewportSize(bounds_);
652 PostSetNeedsCommitToMainThread();
653 }
654
655 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
656 LayerTreeHostImpl::FrameData* frame_data,
657 bool result) OVERRIDE {
658 EXPECT_TRUE(result);
659
660 gfx::RectF root_damage_rect;
661 if (!frame_data->render_passes.empty())
662 root_damage_rect = frame_data->render_passes.back()->damage_rect;
663
664 if (num_draws_ == 0 || num_draws_ == 3)
665 // First and last draw should expect full frame damage
666 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect);
667 else
668 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect);
669
670 return result;
671 }
672
673 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
674 switch (num_draws_) {
675 case 0:
676 case 1:
677 // Cycle through a couple of empty commits to ensure we're observing the
enne (OOO) 2013/10/01 19:15:30 Hrm. I was hoping you could add a commit -> draw
678 // right behavior
679 PostSetNeedsCommitToMainThread();
680 break;
681 case 2:
682 // Should force full frame damage on the next commit
683 PostSetNextCommitForcesRedrawToMainThread();
684 PostSetNeedsCommitToMainThread();
685 break;
686 default:
687 EndTest();
688 break;
689 }
690 num_draws_++;
691 }
692
693 virtual void AfterTest() OVERRIDE {
694 EXPECT_EQ(4, num_draws_);
695 }
696
697 private:
698 int num_draws_;
699 const gfx::Size bounds_;
700 FakeContentLayerClient client_;
701 scoped_refptr<ContentLayer> root_layer_;
702 };
703
704 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw);
705
639 // If the layerTreeHost says it can't draw, Then we should not try to draw. 706 // If the layerTreeHost says it can't draw, Then we should not try to draw.
640 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { 707 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest {
641 public: 708 public:
642 LayerTreeHostTestCanDrawBlocksDrawing() : num_commits_(0), done_(false) {} 709 LayerTreeHostTestCanDrawBlocksDrawing() : num_commits_(0), done_(false) {}
643 710
644 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 711 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
645 712
646 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 713 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
647 if (done_) 714 if (done_)
648 return; 715 return;
(...skipping 4126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4775 4842
4776 private: 4843 private:
4777 int num_commits_; 4844 int num_commits_;
4778 }; 4845 };
4779 4846
4780 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestMemoryLimits); 4847 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestMemoryLimits);
4781 4848
4782 } // namespace 4849 } // namespace
4783 4850
4784 } // namespace cc 4851 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698