// Copyright 2021 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/351564777): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #include <array> #include <limits> #include "services/audio/mixing_graph.h" #include "testing/gtest/include/gtest/gtest.h" namespace audio { // Test fixture to verify the functionality of the mixing graph inputs. class MixingGraphInputTest : public ::testing::Test { … }; // Simple audio source callback where a sample value is the value of the // previous sample plus |increment|. When using stereo the values of the right // channel will be the values of the left channel plus |increment|. class SampleCounter : public media::AudioOutputStream::AudioSourceCallback { … }; // Simple audio source callback where all samples are set to the same value. // The value is incremented by |increment| for each callback. class CallbackCounter : public media::AudioOutputStream::AudioSourceCallback { … }; // Simple audio source callback where all samples are set to a specified value. class ConstantInput : public media::AudioOutputStream::AudioSourceCallback { … }; class GlitchInfoCounter : public media::AudioOutputStream::AudioSourceCallback { … }; // Verifies that the mixing graph outputs zeros when no inputs have been added. TEST_F(MixingGraphInputTest, NoInputs) { … } // Verifies the output of a single input with the same parameters as the mixing // graph. TEST_F(MixingGraphInputTest, SingleInput) { … } // Verifies the output of the mixing graph when adding multiple inputs. TEST_F(MixingGraphInputTest, MultipleInputs) { … } // Verifies the mixing graph output when adding an input in need of channel // mixing. TEST_F(MixingGraphInputTest, ChannelMixing) { … } // Verifies the mixing graph output when adding an input in need of resampling. TEST_F(MixingGraphInputTest, Resampling) { … } // Verifies the use of FIFO when an input produces less data per call than // requested by the mixing graph. TEST_F(MixingGraphInputTest, Buffering1) { … } // Verifies the use of FIFO when an input produces more data per call than // requested by the mixing graph. TEST_F(MixingGraphInputTest, Buffering2) { … } // Verifies that no left-over samples from the FIFO are pulled after stopping // and restarting the input. TEST_F(MixingGraphInputTest, BufferClearedAtRestart) { … } // Verifies the output of the mixing graph when adding and removing inputs on // the fly. TEST_F(MixingGraphInputTest, AddingAndRemovingInputs) { … } // Verifies that the volume is applied correctly. TEST_F(MixingGraphInputTest, SetVolume) { … } // Verifies that out-of-range output values are sanitized. TEST_F(MixingGraphInputTest, OutOfRange) { … } // Verifies that invalid input is sanitized. TEST_F(MixingGraphInputTest, InvalidInput) { … } // Verifies that the graph propagates glitch info to all inputs. TEST_F(MixingGraphInputTest, PropagatesGlitchInfo) { … } } // namespace audio