chromium/media/base/audio_bus_unittest.cc

// Copyright 2012 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/base/audio_bus.h"

#include <stddef.h>
#include <stdint.h>

#include <limits>
#include <memory>

#include "base/memory/aligned_memory.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/base/audio_parameters.h"
#include "media/base/audio_sample_types.h"
#include "media/base/channel_layout.h"
#include "media/base/fake_audio_render_callback.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace media {

static const int kChannels =;
static constexpr ChannelLayout kChannelLayout =;
// Use a buffer size which is intentionally not a multiple of kChannelAlignment.
static const int kFrameCount =;
static const int kSampleRate =;

class AudioBusTest : public testing::Test {};

// Verify basic Create(...) method works as advertised.
TEST_F(AudioBusTest, Create) {}

// Verify Create(...) using AudioParameters works as advertised.
TEST_F(AudioBusTest, CreateUsingAudioParameters) {}

// Verify an AudioBus created via CreateWrapper(...) works as advertised.
TEST_F(AudioBusTest, CreateWrapper) {}

// Verify an AudioBus created via wrapping a vector works as advertised.
TEST_F(AudioBusTest, WrapVector) {}

// Verify an AudioBus created via wrapping a memory block works as advertised.
TEST_F(AudioBusTest, WrapMemory) {}

// Simulate a shared memory transfer and verify results.
TEST_F(AudioBusTest, CopyTo) {}

// Verify Zero() and ZeroFrames(...) utility methods work as advertised.
TEST_F(AudioBusTest, Zero) {}

// Each test vector represents two channels of data in the following arbitrary
// layout: <min, zero, max, min, max / 2, min / 2, zero, max, zero, zero>.
static const int kTestVectorSize =;
static const uint8_t kTestVectorUint8[kTestVectorSize] =;
static const int16_t kTestVectorInt16[kTestVectorSize] =;
static const int32_t kTestVectorInt32[kTestVectorSize] =;
static const float kTestVectorFloat32[kTestVectorSize] =;

// This is based on kTestVectorFloat32, but has some of the values outside of
// sanity.
static const float kTestVectorFloat32Invalid[kTestVectorSize] =;

static const float kTestVectorFloat32Sanitized[kTestVectorSize] =;

// Expected results.
static const int kTestVectorFrameCount =;
static const float kTestVectorResult[][kTestVectorFrameCount] =;
static const int kTestVectorChannelCount =;

// Verify FromInterleaved() deinterleaves audio in supported formats correctly.
TEST_F(AudioBusTest, FromInterleaved) {}

// Verify FromInterleavedPartial() deinterleaves audio correctly.
TEST_F(AudioBusTest, FromInterleavedPartial) {}

// Verify ToInterleaved() interleaves audio in supported formats correctly.
TEST_F(AudioBusTest, ToInterleaved) {}

TEST_F(AudioBusTest, ToInterleavedSanitized) {}

TEST_F(AudioBusTest, CopyAndClipTo) {}

// Verify ToInterleavedPartial() interleaves audio correctly.
TEST_F(AudioBusTest, ToInterleavedPartial) {}

struct ZeroingOutTestData {};

TEST_F(AudioBusTest, FromInterleavedZerosOutUntouchedFrames) {}

TEST_F(AudioBusTest, FromInterleavedPartialDoesNotZeroOutUntouchedFrames) {}

TEST_F(AudioBusTest, Scale) {}

TEST_F(AudioBusTest, Bitstream) {}

}  // namespace media