Commit 72367c7a authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Chromium LUCI CQ

Fix frame generation timing

Bug: 1150492

Change-Id: Ifd8e735f5682ffc6f09ebcddc22f43cbcd5300ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2562158Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832534}
parent 41177519
......@@ -27,13 +27,13 @@ TEST_F(AnimationThroughputReporterTest, ImplicitAnimation) {
layer.SetOpacity(0.5f);
root_layer()->Add(&layer);
base::RunLoop run_loop;
bool reported = false;
{
LayerAnimator* animator = layer.GetAnimator();
AnimationThroughputReporter reporter(
animator, base::BindLambdaForTesting(
[&](const cc::FrameSequenceMetrics::CustomReportData&) {
run_loop.Quit();
reported = true;
}));
ScopedLayerAnimationSettings settings(animator);
......@@ -42,7 +42,7 @@ TEST_F(AnimationThroughputReporterTest, ImplicitAnimation) {
}
// The animation starts in next frame (16ms) and ends 48 ms later.
Advance(base::TimeDelta::FromMilliseconds(64));
run_loop.Run();
EXPECT_TRUE(reported);
}
// Tests animation throughput collection with implicit animation setup before
......@@ -51,13 +51,13 @@ TEST_F(AnimationThroughputReporterTest, ImplicitAnimationLateAttach) {
Layer layer;
layer.SetOpacity(0.5f);
base::RunLoop run_loop;
bool reported = false;
{
LayerAnimator* animator = layer.GetAnimator();
AnimationThroughputReporter reporter(
animator, base::BindLambdaForTesting(
[&](const cc::FrameSequenceMetrics::CustomReportData&) {
run_loop.Quit();
reported = true;
}));
ScopedLayerAnimationSettings settings(animator);
......@@ -68,7 +68,7 @@ TEST_F(AnimationThroughputReporterTest, ImplicitAnimationLateAttach) {
// Attach to root after animation setup.
root_layer()->Add(&layer);
Advance(base::TimeDelta::FromMilliseconds(64));
run_loop.Run();
EXPECT_TRUE(reported);
}
// Tests animation throughput collection with explicitly created animation
......@@ -78,13 +78,13 @@ TEST_F(AnimationThroughputReporterTest, ExplicitAnimation) {
layer.SetOpacity(0.5f);
root_layer()->Add(&layer);
base::RunLoop run_loop;
bool reported = false;
{
LayerAnimator* animator = layer.GetAnimator();
AnimationThroughputReporter reporter(
animator, base::BindLambdaForTesting(
[&](const cc::FrameSequenceMetrics::CustomReportData&) {
run_loop.Quit();
reported = true;
}));
animator->ScheduleAnimation(
......@@ -92,7 +92,7 @@ TEST_F(AnimationThroughputReporterTest, ExplicitAnimation) {
1.0f, base::TimeDelta::FromMilliseconds(48))));
}
Advance(base::TimeDelta::FromMilliseconds(64));
run_loop.Run();
EXPECT_TRUE(reported);
}
// Tests animation throughput collection for a persisted animator of a Layer.
......@@ -106,24 +106,24 @@ TEST_F(AnimationThroughputReporterTest, PersistedAnimation) {
new LayerAnimator(base::TimeDelta::FromMilliseconds(48));
layer->SetAnimator(animator);
std::unique_ptr<base::RunLoop> run_loop = std::make_unique<base::RunLoop>();
bool reported = false;
// |reporter| keeps reporting as long as it is alive.
AnimationThroughputReporter reporter(
animator, base::BindLambdaForTesting(
[&](const cc::FrameSequenceMetrics::CustomReportData&) {
run_loop->Quit();
reported = true;
}));
// Report data for animation of opacity goes to 1.
layer->SetOpacity(1.0f);
Advance(base::TimeDelta::FromMilliseconds(64));
run_loop->Run();
EXPECT_TRUE(reported);
// Report data for animation of opacity goes to 0.5.
run_loop = std::make_unique<base::RunLoop>();
reported = false;
layer->SetOpacity(0.5f);
Advance(base::TimeDelta::FromMilliseconds(64));
run_loop->Run();
EXPECT_TRUE(reported);
}
// Tests animation throughput not reported when animation is aborted.
......@@ -205,6 +205,7 @@ TEST_F(AnimationThroughputReporterTest, EndDetachedNoReportNoLeak) {
// Wait a bit to ensure that report does not happen.
Advance(base::TimeDelta::FromMilliseconds(100));
EXPECT_FALSE(animator->is_animating());
// AnimationTracker in |reporter| should not leak in asan.
}
......@@ -234,12 +235,12 @@ TEST_F(AnimationThroughputReporterTest, ReportForAnimateToNewTarget) {
}
// Animate to new target. Report should happen.
base::RunLoop run_loop;
bool reported = false;
{
AnimationThroughputReporter reporter(
animator, base::BindLambdaForTesting(
[&](const cc::FrameSequenceMetrics::CustomReportData&) {
run_loop.Quit();
reported = true;
}));
ScopedLayerAnimationSettings settings(animator);
......@@ -250,7 +251,7 @@ TEST_F(AnimationThroughputReporterTest, ReportForAnimateToNewTarget) {
layer->SetBounds(gfx::Rect(0, 0, 5, 6));
}
Advance(base::TimeDelta::FromMilliseconds(64));
run_loop.Run();
EXPECT_TRUE(reported);
}
} // namespace ui
......@@ -22,7 +22,7 @@ AnimationThroughputReporterTestBase::~AnimationThroughputReporterTestBase() =
void AnimationThroughputReporterTestBase::SetUp() {
context_factories_ = std::make_unique<TestContextFactories>(false);
const gfx::Rect bounds(100, 100);
const gfx::Rect bounds(300, 300);
host_.reset(TestCompositorHost::Create(
bounds, context_factories_->GetContextFactory()));
host_->Show();
......@@ -30,7 +30,7 @@ void AnimationThroughputReporterTestBase::SetUp() {
compositor()->SetRootLayer(&root_);
frame_generation_timer_.Start(
FROM_HERE, base::TimeDelta::FromMilliseconds(50), this,
FROM_HERE, base::TimeDelta::FromMilliseconds(16), this,
&AnimationThroughputReporterTestBase::GenerateOneFrame);
}
......
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