#include "services/media_session/audio_focus_manager.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/containers/adapters.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/test/power_monitor_test.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/media_session/audio_focus_request.h"
#include "services/media_session/media_session_service_impl.h"
#include "services/media_session/public/cpp/test/audio_focus_test_util.h"
#include "services/media_session/public/cpp/test/mock_media_session.h"
#include "services/media_session/public/mojom/audio_focus.mojom.h"
#include "services/media_session/public/mojom/media_session.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media_session {
namespace {
const char kExampleSourceName[] = …;
const char kExampleSourceName2[] = …;
}
class AudioFocusManagerTest
: public testing::TestWithParam<mojom::EnforcementMode> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(AudioFocusManagerTest, RequestAudioFocusGain_ReplaceFocusedEntry) { … }
TEST_P(AudioFocusManagerTest, RequestAudioFocusGain_Duplicate) { … }
TEST_P(AudioFocusManagerTest, RequestAudioFocusGain_FromTransient) { … }
TEST_P(AudioFocusManagerTest, RequestAudioFocusGain_FromTransientMayDuck) { … }
TEST_P(AudioFocusManagerTest, RequestAudioFocusTransient_FromGain) { … }
TEST_P(AudioFocusManagerTest, RequestAudioFocusTransientMayDuck_FromGain) { … }
TEST_P(AudioFocusManagerTest, RequestAudioFocusTransient_FromGainWhileDucking) { … }
TEST_P(AudioFocusManagerTest,
RequestAudioFocusTransientMayDuck_FromGainWhileDucking) { … }
TEST_P(AudioFocusManagerTest, AbandonAudioFocus_RemovesFocusedEntry) { … }
TEST_P(AudioFocusManagerTest, AbandonAudioFocus_MultipleCalls) { … }
TEST_P(AudioFocusManagerTest, AbandonAudioFocus_RemovesTransientMayDuckEntry) { … }
TEST_P(AudioFocusManagerTest, AbandonAudioFocus_RemovesTransientEntry) { … }
TEST_P(AudioFocusManagerTest, AbandonAudioFocus_WhileDuckingThenResume) { … }
TEST_P(AudioFocusManagerTest, AbandonAudioFocus_StopsDucking) { … }
TEST_P(AudioFocusManagerTest, AbandonAudioFocus_ResumesPlayback) { … }
TEST_P(AudioFocusManagerTest, DuckWhilePlaying) { … }
TEST_P(AudioFocusManagerTest, GainSuspendsTransient) { … }
TEST_P(AudioFocusManagerTest, GainSuspendsTransientMayDuck) { … }
TEST_P(AudioFocusManagerTest, DuckWithMultipleTransientMayDucks) { … }
TEST_P(AudioFocusManagerTest, MediaSessionDestroyed_ReleasesFocus) { … }
TEST_P(AudioFocusManagerTest, MediaSessionDestroyed_ReleasesTransient) { … }
TEST_P(AudioFocusManagerTest, MediaSessionDestroyed_ReleasesTransientMayDucks) { … }
TEST_P(AudioFocusManagerTest, GainDucksForceDuck) { … }
TEST_P(AudioFocusManagerTest, ForceDuckSessionShouldAlwaysBeDuckedFromGain) { … }
TEST_P(AudioFocusManagerTest,
ForceDuckSessionShouldAlwaysBeDuckedFromTransient) { … }
TEST_P(AudioFocusManagerTest, AudioFocusObserver_RequestNoop) { … }
TEST_P(AudioFocusManagerTest, AudioFocusObserver_TransientMayDuck) { … }
TEST_P(AudioFocusManagerTest, GetDebugInfo) { … }
TEST_P(AudioFocusManagerTest, GetDebugInfo_BadRequestId) { … }
TEST_P(AudioFocusManagerTest,
RequestAudioFocusTransient_FromGainWhileSuspended) { … }
TEST_P(AudioFocusManagerTest,
RequestAudioFocusTransientMayDuck_FromGainWhileSuspended) { … }
TEST_P(AudioFocusManagerTest, Source_AssociatedWithBinding) { … }
TEST_P(AudioFocusManagerTest, Source_Empty) { … }
TEST_P(AudioFocusManagerTest, Source_Updated) { … }
TEST_P(AudioFocusManagerTest,
AbandonAudioFocus_ObserverFocusGain_NoTopSession) { … }
TEST_P(AudioFocusManagerTest,
AbandonAudioFocus_ObserverFocusGain_NewTopSession) { … }
TEST_P(AudioFocusManagerTest, AudioFocusGrouping_LayeredFocus) { … }
TEST_P(AudioFocusManagerTest, AudioFocusGrouping_TransientResume) { … }
TEST_P(AudioFocusManagerTest, AudioFocusGrouping_DoNotSuspendSameGroup) { … }
TEST_P(AudioFocusManagerTest, AudioFocusGrouping_DuckSameGroup) { … }
TEST_P(AudioFocusManagerTest, AudioFocusGrouping_TransientSameGroup) { … }
TEST_P(AudioFocusManagerTest, RequestAudioFocus_PreferStop_LossToGain) { … }
TEST_P(AudioFocusManagerTest,
RequestAudioFocus_PreferStop_LossToGainTransient) { … }
TEST_P(AudioFocusManagerTest, GainFocusTypeHasEffectEvenIfSuspended) { … }
TEST_P(AudioFocusManagerTest, TransientFocusTypeHasNoEffectIfSuspended) { … }
TEST_P(AudioFocusManagerTest, TransientDuckFocusTypeHasNoEffectIfSuspended) { … }
TEST_P(AudioFocusManagerTest, AmbientFocusHasNoEffect) { … }
TEST_P(AudioFocusManagerTest, AudioFocusObserver_NotTopMost) { … }
TEST_P(AudioFocusManagerTest, SuspendAllSessionOnPowerSuspend) { … }
TEST_P(AudioFocusManagerTest, TransientPauseShouldDelayControllerPause) { … }
TEST_P(AudioFocusManagerTest, TransientPauseShouldDelayControllerStop) { … }
TEST_P(AudioFocusManagerTest, TransientPauseShouldDelayControllerResume) { … }
TEST_P(AudioFocusManagerTest, TransientPauseShouldDelayLastActionOnly) { … }
TEST_P(AudioFocusManagerTest, RequestIdValidation) { … }
TEST_P(AudioFocusManagerTest, SourceObservers) { … }
TEST_P(AudioFocusManagerTest, GetSourceFocusRequests) { … }
}