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

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

Issue 2398283002: Fix flakiness in LayerTreeHostCacheBehaviorOnOutputSurfaceRecreated (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostFreeContextResourcesOnDestroy); 573 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostFreeContextResourcesOnDestroy);
574 574
575 // Test if the LTH successfully frees and stops freeing context resources 575 // Test if the LTH successfully frees and stops freeing context resources
576 // when the OutputSurface is lost and recreated. 576 // when the OutputSurface is lost and recreated.
577 class LayerTreeHostCacheBehaviorOnOutputSurfaceRecreated 577 class LayerTreeHostCacheBehaviorOnOutputSurfaceRecreated
578 : public LayerTreeHostContextCacheTest { 578 : public LayerTreeHostContextCacheTest {
579 public: 579 public:
580 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, 580 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
581 const BeginFrameArgs& args) override { 581 const BeginFrameArgs& args) override {
582 // This code is run once, to trigger recreation of our OutputSurface. 582 // This code is run once, to trigger recreation of our OutputSurface.
583 if (has_recreated_) 583 if (test_state_ != TestState::INIT)
584 return; 584 return;
585 585
586 // Ensure that our initialization expectations have completed. 586 // Ensure that our initialization expectations have completed.
587 Mock::VerifyAndClearExpectations(mock_main_context_support_); 587 Mock::VerifyAndClearExpectations(mock_main_context_support_);
588 Mock::VerifyAndClearExpectations(mock_worker_context_support_); 588 Mock::VerifyAndClearExpectations(mock_worker_context_support_);
589 589
590 // Output surface lost expectations. 590 // Output surface lost expectations.
danakj 2016/10/06 23:37:38 oops. Output surface -> CompositorFrameSink
ericrk 2016/10/07 17:58:31 Done.
591 EXPECT_CALL(*mock_worker_context_support_, 591 EXPECT_CALL(*mock_worker_context_support_,
592 SetAggressivelyFreeResources(true)); 592 SetAggressivelyFreeResources(true));
593 EXPECT_CALL(*mock_main_context_support_, 593 EXPECT_CALL(*mock_main_context_support_,
594 SetAggressivelyFreeResources(true)); 594 SetAggressivelyFreeResources(true));
595 host_impl->DidLoseCompositorFrameSink(); 595 host_impl->DidLoseCompositorFrameSink();
596 has_recreated_ = true; 596 test_state_ = TestState::RECREATED;
597 } 597 }
598 598
599 void DidInitializeCompositorFrameSink() override { 599 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
600 bool success) override {
600 // This is run after we have recreated our OutputSurface. 601 // This is run after we have recreated our OutputSurface.
danakj 2016/10/06 23:37:38 and here
ericrk 2016/10/07 17:58:31 Done.
601 if (!has_recreated_) 602 if (test_state_ != TestState::RECREATED)
602 return; 603 return;
603 604
604 // Ensure that our initialization expectations have completed. 605 // Ensure that our initialization expectations have completed.
605 Mock::VerifyAndClearExpectations(mock_main_context_support_); 606 Mock::VerifyAndClearExpectations(mock_main_context_support_);
606 Mock::VerifyAndClearExpectations(mock_worker_context_support_); 607 Mock::VerifyAndClearExpectations(mock_worker_context_support_);
607 608
608 // Destruction exptectations. 609 // Destruction exptectations.
609 EXPECT_CALL(*mock_worker_context_support_, 610 EXPECT_CALL(*mock_worker_context_support_,
610 SetAggressivelyFreeResources(true)); 611 SetAggressivelyFreeResources(true));
611 EXPECT_CALL(*mock_main_context_support_, 612 EXPECT_CALL(*mock_main_context_support_,
612 SetAggressivelyFreeResources(true)); 613 SetAggressivelyFreeResources(true));
613 EndTest(); 614 EndTest();
615 test_state_ = TestState::DONE;
614 } 616 }
615 617
616 private: 618 private:
617 bool has_recreated_ = false; 619 enum class TestState { INIT, RECREATED, DONE };
620 TestState test_state_ = TestState::INIT;
618 }; 621 };
619 622
620 SINGLE_AND_MULTI_THREAD_TEST_F( 623 SINGLE_AND_MULTI_THREAD_TEST_F(
621 LayerTreeHostCacheBehaviorOnOutputSurfaceRecreated); 624 LayerTreeHostCacheBehaviorOnOutputSurfaceRecreated);
622 625
623 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1 626 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1
624 // draw with frame 0. 627 // draw with frame 0.
625 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest { 628 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest {
626 public: 629 public:
627 LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {} 630 LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {}
(...skipping 6378 matching lines...) Expand 10 before | Expand all | Expand 10 after
7006 EndTest(); 7009 EndTest();
7007 } 7010 }
7008 7011
7009 void AfterTest() override {} 7012 void AfterTest() override {}
7010 }; 7013 };
7011 7014
7012 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); 7015 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources);
7013 7016
7014 } // namespace 7017 } // namespace
7015 } // namespace cc 7018 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698