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

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

Issue 2757373002: Fixing flakiness of TextureLayerChangeInvisibleMailboxTest (Closed)
Patch Set: c Created 3 years, 8 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 | « cc/test/test_hooks.h ('k') | cc/trees/proxy_impl.h » ('j') | 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 7501 matching lines...) Expand 10 before | Expand all | Expand 10 after
7512 DCHECK_EQ(hud->clip_tree_index(), root_layer->clip_tree_index()); 7512 DCHECK_EQ(hud->clip_tree_index(), root_layer->clip_tree_index());
7513 DCHECK_EQ(hud->effect_tree_index(), root_layer->effect_tree_index()); 7513 DCHECK_EQ(hud->effect_tree_index(), root_layer->effect_tree_index());
7514 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index()); 7514 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index());
7515 } 7515 }
7516 7516
7517 void AfterTest() override {} 7517 void AfterTest() override {}
7518 }; 7518 };
7519 7519
7520 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists); 7520 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists);
7521 7521
7522 // Verifies that LayerTreeHostClient does not receive frame acks from a released
7523 // CompositorFrameSink.
7524 class LayerTreeHostTestDiscardAckAfterRelease : public LayerTreeHostTest {
7525 protected:
7526 void SetupTree() override {
7527 scoped_refptr<Layer> root = Layer::Create();
7528 root->SetBounds(gfx::Size(10, 10));
7529 layer_tree_host()->SetRootLayer(std::move(root));
7530 LayerTreeHostTest::SetupTree();
7531 }
7532
7533 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
7534
7535 void WillReceiveCompositorFrameAckOnThread(
7536 LayerTreeHostImpl* host_impl) override {
7537 // This method is called before ack is posted to main thread. This ensures
7538 // that WillReceiveCompositorFrameAck which we PostTask below will be called
7539 // before DidReceiveCompositorFrameAck.
7540 MainThreadTaskRunner()->PostTask(
7541 FROM_HERE, base::Bind(&LayerTreeHostTestDiscardAckAfterRelease::
7542 WillReceiveCompositorFrameAck,
7543 base::Unretained(this)));
7544 }
7545
7546 void WillReceiveCompositorFrameAck() {
7547 switch (layer_tree_host()->SourceFrameNumber()) {
7548 case 1:
7549 // For the first commit, don't release the CompositorFrameSink. We must
7550 // receive the ack later on.
7551 break;
7552 case 2:
7553 // Release the CompositorFrameSink for the second commit. We'll later
7554 // check that the ack is discarded.
7555 layer_tree_host()->SetVisible(false);
7556 layer_tree_host()->ReleaseCompositorFrameSink();
7557 break;
7558 default:
7559 NOTREACHED();
7560 }
7561 }
7562
7563 void DidReceiveCompositorFrameAckOnThread(
7564 LayerTreeHostImpl* host_impl) override {
7565 // Since this method is called after ack is posted to main thread, we can be
7566 // sure that if the ack is not discarded, it will be definitely received
7567 // before we are in CheckFrameAck.
7568 MainThreadTaskRunner()->PostTask(
7569 FROM_HERE,
7570 base::Bind(&LayerTreeHostTestDiscardAckAfterRelease::CheckFrameAck,
7571 base::Unretained(this)));
7572 }
7573
7574 void DidReceiveCompositorFrameAck() override { received_ack_ = true; }
7575
7576 void CheckFrameAck() {
7577 switch (layer_tree_host()->SourceFrameNumber()) {
7578 case 1:
7579 // CompositorFrameSink was not released. We must receive the ack.
7580 EXPECT_TRUE(received_ack_);
7581 // Cause damage so that we draw and swap.
7582 layer_tree_host()->root_layer()->SetBackgroundColor(SK_ColorGREEN);
7583 break;
7584 case 2:
7585 // CompositorFrameSink was released. The ack must be discarded.
7586 EXPECT_FALSE(received_ack_);
7587 EndTest();
7588 break;
7589 default:
7590 NOTREACHED();
7591 }
7592 received_ack_ = false;
7593 }
7594
7595 void AfterTest() override {}
7596
7597 private:
7598 bool received_ack_ = false;
7599 };
7600
7601 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease);
7602
7522 } // namespace 7603 } // namespace
7523 } // namespace cc 7604 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_hooks.h ('k') | cc/trees/proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698