// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "cc/metrics/average_lag_tracker.h" #include <memory> #include "base/test/metrics/histogram_tester.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" Bucket; ElementsAre; namespace cc { namespace { class AverageLagTrackerTest : public testing::Test { … }; base::TimeTicks MillisecondsToTimeTicks(float t_ms) { … } // Simulate a simple situation that events at every 10ms and start at t=15ms, // frame swaps at every 10ms too and start at t=20ms and test we record one // UMA for ScrollUpdate in one second. TEST_F(AverageLagTrackerTest, OneSecondInterval) { … } // Test the case that event's frame swap time is later than next event's // creation time. (i.e, event at t=10ms will be dispatch at t=30ms, while next // event is at t=20ms). TEST_F(AverageLagTrackerTest, LargerLatency) { … } // Test that multiple latency being flush in the same frame swap. TEST_F(AverageLagTrackerTest, TwoLatencyInfoInSameFrame) { … } // Test the case that switching direction causes lag at current frame // time and previous frame time are in different direction. TEST_F(AverageLagTrackerTest, ChangeDirectionInFrame) { … } // A simple case without scroll prediction to compare with the two with // prediction cases below. TEST_F(AverageLagTrackerTest, NoScrollPrediction) { … } // Test AverageLag with perfect scroll prediction. TEST_F(AverageLagTrackerTest, ScrollPrediction) { … } // Test AverageLag with imperfect scroll prediction. TEST_F(AverageLagTrackerTest, ImperfectScrollPrediction) { … } TEST_F(AverageLagTrackerTest, NegativePredictionEffect) { … } TEST_F(AverageLagTrackerTest, NoPredictionEffect) { … } // Tests that when an event arrives out-of-order, the average lag tracker // properly ignores it. TEST_F(AverageLagTrackerTest, EventOutOfOrder) { … } } // namespace } // namespace cc