Commit c67de28b authored by danakj's avatar danakj Committed by Commit bot

cc: Fix flakiness in LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest

This test was expecting the main thread copy request to happen before a
new draw happens on the compositor thread which is racey. Instead do
this comparison on the main thread by posting and trying to end the test
after the draw happens but checking for the copy request result there
on the main thread instead of on the impl thread before posting.

R=vmpstr, weiliangc
BUG=439649

Review URL: https://codereview.chromium.org/888663003

Cr-Commit-Position: refs/heads/master@{#313797}
parent fd162787
...@@ -573,11 +573,6 @@ void LayerTreeTest::PostCompositeImmediatelyToMainThread() { ...@@ -573,11 +573,6 @@ void LayerTreeTest::PostCompositeImmediatelyToMainThread() {
main_thread_weak_ptr_)); main_thread_weak_ptr_));
} }
void LayerTreeTest::PostEndTestToMainThread() {
main_task_runner_->PostTask(
FROM_HERE, base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_));
}
void LayerTreeTest::WillBeginTest() { void LayerTreeTest::WillBeginTest() {
layer_tree_host_->SetLayerTreeHostClientReady(); layer_tree_host_->SetLayerTreeHostClientReady();
} }
......
...@@ -144,7 +144,6 @@ class LayerTreeTest : public testing::Test, public TestHooks { ...@@ -144,7 +144,6 @@ class LayerTreeTest : public testing::Test, public TestHooks {
void PostSetVisibleToMainThread(bool visible); void PostSetVisibleToMainThread(bool visible);
void PostSetNextCommitForcesRedrawToMainThread(); void PostSetNextCommitForcesRedrawToMainThread();
void PostCompositeImmediatelyToMainThread(); void PostCompositeImmediatelyToMainThread();
void PostEndTestToMainThread();
void DoBeginTest(); void DoBeginTest();
void Timeout(); void Timeout();
......
...@@ -967,7 +967,7 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy ...@@ -967,7 +967,7 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy
SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostCopyRequestTestShutdownBeforeCopy); LayerTreeHostCopyRequestTestShutdownBeforeCopy);
class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
: public LayerTreeHostCopyRequestTest { : public LayerTreeHostCopyRequestTest {
protected: protected:
void SetupTree() override { void SetupTree() override {
...@@ -986,6 +986,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest ...@@ -986,6 +986,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
void BeginTest() override { void BeginTest() override {
num_draws_ = 0; num_draws_ = 0;
copy_happened_ = false; copy_happened_ = false;
draw_happened_ = false;
PostSetNeedsCommitToMainThread(); PostSetNeedsCommitToMainThread();
} }
...@@ -994,7 +995,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest ...@@ -994,7 +995,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
if (layer_tree_host()->source_frame_number() == 1) { if (layer_tree_host()->source_frame_number() == 1) {
child_->RequestCopyOfOutput( child_->RequestCopyOfOutput(
CopyOutputRequest::CreateBitmapRequest(base::Bind( CopyOutputRequest::CreateBitmapRequest(base::Bind(
&LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest:: &LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest::
CopyOutputCallback, CopyOutputCallback,
base::Unretained(this)))); base::Unretained(this))));
} }
...@@ -1047,8 +1048,13 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest ...@@ -1047,8 +1048,13 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
// End the test! Don't race with copy request callbacks, so post the end // End the test! Don't race with copy request callbacks, so post the end
// to the main thread. // to the main thread.
EXPECT_TRUE(copy_happened_); draw_happened_ = true;
PostEndTestToMainThread(); MainThreadTaskRunner()->PostTask(
FROM_HERE,
base::Bind(
&LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest::
TryEndTest,
base::Unretained(this)));
break; break;
} }
return draw_result; return draw_result;
...@@ -1057,6 +1063,12 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest ...@@ -1057,6 +1063,12 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
EXPECT_FALSE(TestEnded()); EXPECT_FALSE(TestEnded());
copy_happened_ = true; copy_happened_ = true;
TryEndTest();
}
void TryEndTest() {
if (draw_happened_ && copy_happened_)
EndTest();
} }
void AfterTest() override {} void AfterTest() override {}
...@@ -1065,10 +1077,11 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest ...@@ -1065,10 +1077,11 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
FakeContentLayerClient client_; FakeContentLayerClient client_;
int num_draws_; int num_draws_;
bool copy_happened_; bool copy_happened_;
bool draw_happened_;
}; };
SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest); LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest);
} // namespace } // namespace
} // namespace cc } // namespace cc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment