chromium/services/audio/loopback_stream_unittest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/audio/loopback_stream.h"

#include <cmath>
#include <cstdint>
#include <memory>

#include "base/containers/unique_ptr_adapters.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/ranges/algorithm.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "media/base/audio_parameters.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/channel_layout.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/audio/loopback_coordinator.h"
#include "services/audio/loopback_group_member.h"
#include "services/audio/test/fake_consumer.h"
#include "services/audio/test/fake_loopback_group_member.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
Mock;
NiceMock;
StrictMock;

namespace audio {
namespace {

// Volume settings for the FakeLoopbackGroupMember (source) and LoopbackStream.
constexpr double kSnoopVolume =;
constexpr double kLoopbackVolume =;

// Piano key frequencies.
constexpr double kMiddleAFreq =;
constexpr double kMiddleCFreq =;

// Audio buffer duration.
constexpr base::TimeDelta kBufferDuration =;

// Local audio output delay.
constexpr base::TimeDelta kDelayUntilOutput =;

// The amount of audio signal to record each time PumpAudioAndTakeNewRecording()
// is called.
constexpr base::TimeDelta kTestRecordingDuration =;

const media::AudioParameters& GetLoopbackStreamParams() {}

class MockClientAndObserver : public media::mojom::AudioInputStreamClient,
                              public media::mojom::AudioInputStreamObserver {};

// Subclass of FakeConsumer that adapts the SyncWriter interface to allow the
// tests to record and analyze the audio data from the LoopbackStream.
class FakeSyncWriter : public FakeConsumer, public InputController::SyncWriter {};

class LoopbackStreamTest : public testing::Test {};

TEST_F(LoopbackStreamTest, ShutsDownStreamWhenInterfacePtrIsClosed) {}

TEST_F(LoopbackStreamTest, ShutsDownStreamWhenClientBindingIsClosed) {}

TEST_F(LoopbackStreamTest, ShutsDownStreamWhenObserverBindingIsClosed) {}

TEST_F(LoopbackStreamTest, ProducesSilenceWhenNoMembersArePresent) {}

// Syntatic sugar to confirm a tone exists and its amplitude matches
// expectations.
#define EXPECT_TONE(ch, frequency, expected_amplitude)

TEST_F(LoopbackStreamTest, ProducesAudioFromASingleSource) {}

TEST_F(LoopbackStreamTest, ProducesAudioFromTwoSources) {}

TEST_F(LoopbackStreamTest, AudioChangesVolume) {}

}  // namespace
}  // namespace audio