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() {
main_thread_weak_ptr_));
}
void LayerTreeTest::PostEndTestToMainThread() {
main_task_runner_->PostTask(
FROM_HERE, base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_));
}
void LayerTreeTest::WillBeginTest() {
layer_tree_host_->SetLayerTreeHostClientReady();
}
......
......@@ -144,7 +144,6 @@ class LayerTreeTest : public testing::Test, public TestHooks {
void PostSetVisibleToMainThread(bool visible);
void PostSetNextCommitForcesRedrawToMainThread();
void PostCompositeImmediatelyToMainThread();
void PostEndTestToMainThread();
void DoBeginTest();
void Timeout();
......
......@@ -967,7 +967,7 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy
SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostCopyRequestTestShutdownBeforeCopy);
class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
: public LayerTreeHostCopyRequestTest {
protected:
void SetupTree() override {
......@@ -986,6 +986,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
void BeginTest() override {
num_draws_ = 0;
copy_happened_ = false;
draw_happened_ = false;
PostSetNeedsCommitToMainThread();
}
......@@ -994,7 +995,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
if (layer_tree_host()->source_frame_number() == 1) {
child_->RequestCopyOfOutput(
CopyOutputRequest::CreateBitmapRequest(base::Bind(
&LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest::
&LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest::
CopyOutputCallback,
base::Unretained(this))));
}
......@@ -1047,8 +1048,13 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
// End the test! Don't race with copy request callbacks, so post the end
// to the main thread.
EXPECT_TRUE(copy_happened_);
PostEndTestToMainThread();
draw_happened_ = true;
MainThreadTaskRunner()->PostTask(
FROM_HERE,
base::Bind(
&LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest::
TryEndTest,
base::Unretained(this)));
break;
}
return draw_result;
......@@ -1057,6 +1063,12 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
EXPECT_FALSE(TestEnded());
copy_happened_ = true;
TryEndTest();
}
void TryEndTest() {
if (draw_happened_ && copy_happened_)
EndTest();
}
void AfterTest() override {}
......@@ -1065,10 +1077,11 @@ class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
FakeContentLayerClient client_;
int num_draws_;
bool copy_happened_;
bool draw_happened_;
};
SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest);
SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest);
} // namespace
} // 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