chromium/services/audio/output_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/output_stream.h"

#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "base/unguessable_token.h"
#include "media/audio/audio_io.h"
#include "media/audio/mock_audio_manager.h"
#include "media/audio/test_audio_thread.h"
#include "media/base/audio_power_monitor.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/system/functions.h"
#include "services/audio/stream_factory.h"
#include "services/audio/test/mock_log.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

AtMost;
DeleteArg;
Mock;
NiceMock;
NotNull;
Return;
SaveArg;
StrictMock;
_;

namespace audio {

namespace {

constexpr char kDeviceId1[] =;
constexpr char kDeviceId2[] =;

// Aliases for use with MockCreatedCallback::Created().
const bool successfully_ =;
const bool unsuccessfully_ =;

class MockStream : public media::AudioOutputStream {};

const uint32_t kPlatformErrorDisconnectReason =;
const uint32_t kTerminatedByClientDisconnectReason =;

class MockObserver : public media::mojom::AudioOutputStreamObserver {};

class MockCreatedCallback {};

class MockStreamFactory {};

}  // namespace

// Instantiates various classes that we're going to want in most test cases.
class TestEnvironment {};

TEST(AudioServiceOutputStreamTest, ConstructDestruct) {}

TEST(AudioServiceOutputStreamTest, ConstructDestructNullptrObserver) {}

TEST(AudioServiceOutputStreamTest, ConstructDestructNullptrLog) {}

TEST(AudioServiceOutputStreamTest,
     ConstructStreamAndDestructObserver_DestructsStream) {}

TEST(AudioServiceOutputStreamTest,
     ConstructStreamAndReleaseStreamPtr_DestructsStream) {}

TEST(AudioServiceOutputStreamTest, Play_Plays) {}

TEST(AudioServiceOutputStreamTest, PlayAndPause_PlaysAndStops) {}

TEST(AudioServiceOutputStreamTest, SetVolume_SetsVolume) {}

TEST(AudioServiceOutputStreamTest, SetNegativeVolume_BadMessage) {}

TEST(AudioServiceOutputStreamTest, SetVolumeGreaterThanOne_BadMessage) {}

TEST(AudioServiceOutputStreamTest,
     ConstructWithStreamCreationFailure_SignalsError) {}

TEST(AudioServiceOutputStreamTest,
     ConstructWithStreamCreationFailureAndDestructBeforeErrorFires_NoCrash) {}

TEST(AudioServiceOutputStreamTest, BindMuters) {}

TEST(AudioServiceOutputStreamTest, CreateSwitchableStreamAndPlay) {}

TEST(AudioServiceOutputStreamTest,
     CreateSwitchableStreamPlayPauseSwitchDeviceId) {}

TEST(AudioServiceOutputStreamTest, CreateSwitchableStreamPlaySwitchDeviceId) {}

class OutputStreamAudibilityHelperTest : public ::testing::Test {};

TEST_F(OutputStreamAudibilityHelperTest, StartsSilent) {}

TEST_F(OutputStreamAudibilityHelperTest, StartStop) {}

TEST_F(OutputStreamAudibilityHelperTest, StartStopStop) {}

TEST_F(OutputStreamAudibilityHelperTest, Stop) {}

TEST_F(OutputStreamAudibilityHelperTest, Poll_Stop_StopsCallbacks) {}

TEST_F(OutputStreamAudibilityHelperTest, Poll_NeverAudible_NoStateChange) {}

TEST_F(OutputStreamAudibilityHelperTest, Poll_Audible_StateChanges) {}

// Makes sure that starting and stopping multiple time behaves as expected:
// - The helper should be silent on stops and re-starts
// - The first aubible audio should trigger the audibility change.
TEST_F(OutputStreamAudibilityHelperTest, Poll_StartStopTwice_StateChanges) {}

TEST_F(OutputStreamAudibilityHelperTest, Poll_AlternatingAudible_StateChanges) {}

TEST_F(OutputStreamAudibilityHelperTest, Poll_SmallGlitches_StaysAudible) {}

}  // namespace audio