Skip to content

Commit

Permalink
Fix more cc_unittests with surface sync enabled
Browse files Browse the repository at this point in the history
This CL fixes four remaining cc_unittests that were failing when
|enable_surface_synchronization| was enabled in LayerTreeSettings. These
tests all required some structural changes as allocating a
LocalSurfaceId changes the order of events that occur.

Bug: 985009
Change-Id: I6ab67176b80f4e6d649f13b759a6d5fafa8149fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841880
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703309}
  • Loading branch information
kylechar authored and Commit Bot committed Oct 7, 2019
1 parent 1e48e23 commit e0d243a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 32 deletions.
20 changes: 13 additions & 7 deletions cc/trees/layer_tree_host_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1776,22 +1776,28 @@ SINGLE_THREAD_TEST_F(LayerTreeHostTestAnimationOpacityMutatedUsingLayerLists);
class LayerTreeHostTestAnimationTransformMutatedNotUsingLayerLists
: public LayerTreeHostTest {
protected:
void InitializeSettings(LayerTreeSettings* settings) override {
// TODO(crbug.com/985009): Fix test with surface sync enabled.
settings->enable_surface_synchronization = false;
void SetupTree() override {
root_ = Layer::Create();
child_ = Layer::Create();
root_->AddChild(child_);
layer_tree_host()->SetRootLayer(root_);
LayerTreeHostTest::SetupTree();
}

void BeginTest() override {
Layer* root = layer_tree_host()->root_layer();
EXPECT_EQ(gfx::Transform(), root->transform());
EXPECT_EQ(gfx::Transform(), child_->transform());
gfx::Transform expected_transform;
expected_transform.Translate(42, 42);
layer_tree_host()->SetElementTransformMutated(
root->element_id(), ElementListType::ACTIVE, expected_transform);
child_->element_id(), ElementListType::ACTIVE, expected_transform);
// When not using layer lists, transform is stored on the layer.
EXPECT_EQ(expected_transform, root->transform());
EXPECT_EQ(expected_transform, child_->transform());
EndTest();
}

private:
scoped_refptr<Layer> root_;
scoped_refptr<Layer> child_;
};

SINGLE_THREAD_TEST_F(
Expand Down
65 changes: 40 additions & 25 deletions cc/trees/layer_tree_host_unittest_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ class LayerTreeHostProxyTestSetNeedsAnimate : public LayerTreeHostProxyTest {
LayerTreeHostProxyTestSetNeedsAnimate& operator=(
const LayerTreeHostProxyTestSetNeedsAnimate&) = delete;

void InitializeSettings(LayerTreeSettings* settings) override {
// TODO(crbug.com/985009): Fix test with surface sync enabled.
settings->enable_surface_synchronization = false;
}

void BeginTest() override {
EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE,
GetProxyMain()->max_requested_pipeline_stage());
Expand All @@ -103,10 +98,6 @@ class LayerTreeHostProxyTestSetNeedsAnimate : public LayerTreeHostProxyTest {
GetProxyMain()->max_requested_pipeline_stage());
EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE,
GetProxyMain()->current_pipeline_stage());
}

void DidCommit() override {
EXPECT_EQ(0, update_check_layer()->update_count());
EndTest();
}
};
Expand Down Expand Up @@ -161,14 +152,12 @@ class LayerTreeHostProxyTestSetNeedsUpdateLayersWhileAnimating
LayerTreeHostProxyTestSetNeedsUpdateLayersWhileAnimating& operator=(
const LayerTreeHostProxyTestSetNeedsUpdateLayersWhileAnimating&) = delete;

void InitializeSettings(LayerTreeSettings* settings) override {
// TODO(crbug.com/985009): Fix test with surface sync enabled.
settings->enable_surface_synchronization = false;
}

void BeginTest() override { proxy()->SetNeedsAnimate(); }
void BeginTest() override {}

void WillBeginMainFrame() override {
if (layer_tree_host()->SourceFrameNumber() != 1)
return;

EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE,
GetProxyMain()->max_requested_pipeline_stage());
EXPECT_EQ(ProxyMain::ANIMATE_PIPELINE_STAGE,
Expand All @@ -185,15 +174,29 @@ class LayerTreeHostProxyTestSetNeedsUpdateLayersWhileAnimating
}

void DidBeginMainFrame() override {
if (layer_tree_host()->SourceFrameNumber() != 2)
return;

EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE,
GetProxyMain()->max_requested_pipeline_stage());
EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE,
GetProxyMain()->current_pipeline_stage());
}

void DidCommit() override {
EXPECT_EQ(1, update_check_layer()->update_count());
EndTest();
switch (layer_tree_host()->SourceFrameNumber()) {
case 1:
EXPECT_EQ(1, update_check_layer()->update_count());

// Wait until the first frame is committed and we enter the desired
// state to start the test.
proxy()->SetNeedsAnimate();
break;
case 2:
EXPECT_EQ(2, update_check_layer()->update_count());
EndTest();
break;
}
}
};

Expand All @@ -210,14 +213,12 @@ class LayerTreeHostProxyTestSetNeedsCommitWhileAnimating
LayerTreeHostProxyTestSetNeedsCommitWhileAnimating& operator=(
const LayerTreeHostProxyTestSetNeedsCommitWhileAnimating&) = delete;

void InitializeSettings(LayerTreeSettings* settings) override {
// TODO(crbug.com/985009): Fix test with surface sync enabled.
settings->enable_surface_synchronization = false;
}

void BeginTest() override { proxy()->SetNeedsAnimate(); }
void BeginTest() override {}

void WillBeginMainFrame() override {
if (layer_tree_host()->SourceFrameNumber() != 1)
return;

EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE,
GetProxyMain()->max_requested_pipeline_stage());
EXPECT_EQ(ProxyMain::ANIMATE_PIPELINE_STAGE,
Expand All @@ -234,15 +235,29 @@ class LayerTreeHostProxyTestSetNeedsCommitWhileAnimating
}

void DidBeginMainFrame() override {
if (layer_tree_host()->SourceFrameNumber() != 2)
return;

EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE,
GetProxyMain()->max_requested_pipeline_stage());
EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE,
GetProxyMain()->current_pipeline_stage());
}

void DidCommit() override {
EXPECT_EQ(1, update_check_layer()->update_count());
EndTest();
switch (layer_tree_host()->SourceFrameNumber()) {
case 1:
EXPECT_EQ(1, update_check_layer()->update_count());

// Wait until the first frame is committed and we enter the desired
// state to start the test.
proxy()->SetNeedsAnimate();
break;
case 2:
EXPECT_EQ(2, update_check_layer()->update_count());
EndTest();
break;
}
}
};

Expand Down

0 comments on commit e0d243a

Please sign in to comment.