Chromium Code Reviews| Index: ui/compositor/layer_unittest.cc |
| diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc |
| index 9150bf55b9216013fb32ccb81e726127801c3e4c..c997119b79bc70958171d282b937d485600f42ff 100644 |
| --- a/ui/compositor/layer_unittest.cc |
| +++ b/ui/compositor/layer_unittest.cc |
| @@ -2228,6 +2228,50 @@ TEST_F(LayerWithRealCompositorTest, CompositorAnimationObserverTest) { |
| EXPECT_TRUE(animation_observer.shutdown()); |
| } |
| +// A simple AnimationMetricsReporter class that remembers smoothness metric |
| +// when animation completes. |
| +class TestMetricsReporter : public ui::AnimationMetricsReporter { |
| + public: |
| + TestMetricsReporter() {} |
| + ~TestMetricsReporter() override {} |
| + |
| + bool report_called() { return report_called_; } |
| + int value() const { return value_; } |
| + |
| + protected: |
| + void Report(int value) override { |
| + value_ = value; |
| + report_called_ = true; |
| + } |
| + |
| + private: |
| + bool report_called_ = false; |
| + int value_ = -1; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestMetricsReporter); |
| +}; |
| + |
| +// Starts an animation and tests that incrementing compositor frame count can |
| +// be used to report animation smoothness metrics. |
| +TEST_F(LayerWithRealCompositorTest, ReportMetrics) { |
| + std::unique_ptr<Layer> root( |
| + CreateColorLayer(SK_ColorGREEN, gfx::Rect(20, 20, 50, 50))); |
| + GetCompositor()->SetRootLayer(root.get()); |
| + LayerAnimator* animator = root->GetAnimator(); |
| + std::unique_ptr<ui::LayerAnimationElement> animation_element = |
| + ui::LayerAnimationElement::CreateColorElement( |
| + SK_ColorRED, base::TimeDelta::FromMilliseconds(100)); |
| + ui::LayerAnimationSequence* animation_sequence = |
| + new ui::LayerAnimationSequence(std::move(animation_element)); |
| + TestMetricsReporter reporter; |
| + animation_sequence->SetAnimationMetricsReporter(&reporter); |
| + animator->StartAnimation(animation_sequence); |
| + while (!reporter.report_called()) |
| + WaitForSwap(); |
| + ResetCompositor(); |
| + EXPECT_GT(reporter.value(), 90); |
|
ajuma
2017/01/20 21:24:07
Just to make sure I understand, since the animatio
varkha
2017/01/20 22:05:24
Yes, you got me here. I saw a value of 100% and th
|
| +} |
| + |
| TEST(LayerDebugInfoTest, LayerNameDoesNotClobber) { |
| Layer layer(LAYER_NOT_DRAWN); |
| layer.set_name("foo"); |