// Copyright 2020 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_tracking_manager.h" #include <algorithm> #include <memory> #include "base/test/metrics/histogram_tester.h" #include "components/viz/common/frame_timing_details.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace cc { namespace { Bucket; ElementsAre; IsEmpty; // Helper for TimeTicks usage base::TimeTicks MillisecondsToTimeTicks(int t_ms) { … } // Helper function returning a successful `FrameTimingDetails` for use in // `DidPresentCompositorFrame()`. viz::FrameTimingDetails PrepareFrameDetails(base::TimeTicks swap_time, base::TimeTicks presentation_time) { … } // Helper function returning a failed `FrameTimingDetails` for use in // `DidPresentCompositorFrame()`. viz::FrameTimingDetails PrepareFailedFrameDetails() { … } class AverageLagTrackingManagerTest : public testing::Test { … }; // Simulate a simple situation that generates events at every 10ms starting at // t=15ms and swaps frames at every 10ms, too, starting at t=20ms. Then tests // that we record one UMA for ScrollUpdate in one second. Tests usage of // `CollectScrollEventAtFrame()` (1 event per collection). TEST_F(AverageLagTrackingManagerTest, OneSecondInterval) { … } // This test creates 3 frames in order to check the submission of ScrollBegin // and ScrollUpdate events sent using `CollectScrollEventsAtFrame()` (multiple // events per collection) TEST_F(AverageLagTrackingManagerTest, MultipleEventsInSameFrame) { … } // Tests that if failed presentations arrive out-of-order, they don't mark // previous pending frames as failed since they can still end up in a // successful presentation. TEST_F(AverageLagTrackingManagerTest, OutOfOrderPresentationFeedback) { … } } // namespace } // namespace cc