chromium/cc/metrics/scroll_jank_dropped_frame_tracker_unittest.cc

// Copyright 2023 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/scroll_jank_dropped_frame_tracker.h"

#include <memory>
#include <string>
#include <vector>

#include "base/strings/strcat.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/simple_test_tick_clock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {

namespace {

constexpr base::TimeDelta kVsyncInterval =;

struct FrameTimestamps {};

constexpr int kHistogramEmitFrequency =;
constexpr int kFirstWindowSize =;
constexpr const char* kDelayedFramesWindowHistogram =;
constexpr const char* kMissedVsyncsWindowHistogram =;
constexpr const char* kDelayedFramesPerScrollHistogram =;
constexpr const char* kMissedVsyncsPerScrollHistogram =;
constexpr const char* kMissedVsyncsSumInWindowHistogram =;
constexpr const char* kMissedVsyncsSumInVsyncWindowHistogram =;
constexpr const char* kMissedVsyncsMaxInWindowHistogram =;
constexpr const char* kMissedVsyncsMaxInVsyncWindowHistogram =;
constexpr const char* kMissedVsyncsSumPerScrollHistogram =;
constexpr const char* kMissedVsyncsMaxPerScrollHistogram =;
constexpr const char* kMissedVsyncsPerFrameHistogram =;
}  // namespace

class ScrollJankDroppedFrameTrackerTest : public testing::Test {};

TEST_F(ScrollJankDroppedFrameTrackerTest, EmitsHistograms) {}

/*
Test that regular frame production doesn't cause missed frames.
vsync                   v0      v1
                        |       |
input   I0  I1  I2  I3
        |   |   |   |
F1:     |---------------| {I0, I1}
F2:             |---------------| {I2, I3}
 */
TEST_F(ScrollJankDroppedFrameTrackerTest, FrameProducedEveryVsync) {}

/*
Test that sporadic input timing doesn't cause missed frames when no
frame is expected.
vsync                       v0              v1
                    |       |       |       |
input   I0  I1        I2  I3
        |   |         |   |
F1:     |-------------------| {I0, I1}
F2:                   |---------------------| {I2, I3}
 */
TEST_F(ScrollJankDroppedFrameTrackerTest, NoFrameProducedForMissingInput) {}

/*
Test that when a frame took too long to be produced shows up in the metric.
vsync                   v0              v1        v2
                        |    |    |     |    |    |
input   I0  I1  I2  I3  I4  I5
        |   |   |   |   |   |
F1:     |---------------| {I0, I1}
F2:             |-----------------------| {I2, I3}
F3:                     |-------------------------| {I4, I5}
 */
TEST_F(ScrollJankDroppedFrameTrackerTest, MissedVsyncWhenInputWasPresent) {}

TEST_F(ScrollJankDroppedFrameTrackerTest, MissedVsyncsPerVsyncWindow) {}

struct ScrollTestCase {};

class PerScrollTests : public ScrollJankDroppedFrameTrackerTest,
                       public testing::WithParamInterface<ScrollTestCase> {};

/*
Test that bucketed histograms for scrolls are emitted.
vsync                   v0              v1        v2
                        |    |    |     |    |    |
input   I0  I1  I2  I3  I4  I5
        |   |   |   |   |   |
F1:     |---------------| {I0, I1}
F2:             |-----------------------| {I2, I3}
F3:                     |-------------------------| {I4, I5}
*/
TEST_P(PerScrollTests, MetricsEmittedPerScroll) {}

TEST_P(PerScrollTests, VsyncMetricsEmittedPerScroll) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace cc