Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: ui/compositor/layer_unittest.cc

Issue 2631333002: [animations] Adds metrics for jank on selected layer animations (Closed)
Patch Set: Adds UMA reporting for ripples and overview mode (query refresh rate) Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/compositor/scoped_layer_animation_settings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_unittest.cc
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index 9150bf55b9216013fb32ccb81e726127801c3e4c..dce618331d5ad48edc48736b9cfcb23fe7ba4ea1 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -2228,6 +2228,52 @@ 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(CreateLayer(LAYER_SOLID_COLOR));
+ 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();
+ // Even though most of the time 100% smooth animations are expected, on the
+ // test bots this cannot be guaranteed. Therefore simply check that some
+ // value was reported.
+ EXPECT_GT(reporter.value(), 0);
+}
+
TEST(LayerDebugInfoTest, LayerNameDoesNotClobber) {
Layer layer(LAYER_NOT_DRAWN);
layer.set_name("foo");
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/compositor/scoped_layer_animation_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698