// 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. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/40285824): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #include "media/gpu/hrd_buffer.h" #include "testing/gtest/include/gtest/gtest.h" namespace media { namespace { constexpr int kCommonFps = …; constexpr base::TimeDelta kCommonBufferDelay = …; constexpr uint32_t kCommonAvgBitrate = …; // bits per second constexpr uint32_t kCommonPeakBitrate = …; // bits per second // Test HRDBufferTest runs the test frame size sequence in various // scenarios and check whether the component behaves as expected. class HRDBufferTest : public testing::Test { … }; // Test Cases // Running a simple sequence of frames and taking a snapshot of the parameters // after the last frame is added. The parameters must strictly satisfy the // predefined state. TEST_F(HRDBufferTest, RunBasicBufferTest) { … } // The test runs the predefined test sequence three times using different buffer // parameters. A snapshot of the buffer state is taken after each sequence // run. The snapshot must strictly satisfy the predefined state. TEST_F(HRDBufferTest, CheckBufferParameterChange) { … } // The test uses extended HRD buffer constructor which initiates the buffer // internal state with the provided parameters. After running the first test // sequence, a new buffer is created with predefined state and another sequence // is run after that. A snapshot of the buffer state is checked stirictly // against predefined values after each sequence run. TEST_F(HRDBufferTest, CheckSettingBufferState) { … } // Checks the last frame timestamp parameter after a frame is added to the // buffer. TEST_F(HRDBufferTest, CheckBufferLastFrameTimestamp) { … } // Checks the buffer fullness parameter when the size of the buffer is being // reduced. The size should follow strictly the predefined buffer size values. TEST_F(HRDBufferTest, CheckBufferShrinking) { … } // Checks the buffer overshoot condition. After running the test frame sequence // the buffer should overshoot at the predefined frame index. TEST_F(HRDBufferTest, CheckBufferOvershoot) { … } } // namespace } // namespace media