diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/sounds/sounds_manager.cc | 15 | ||||
-rw-r--r-- | media/audio/sounds/sounds_manager.h | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/media/audio/sounds/sounds_manager.cc b/media/audio/sounds/sounds_manager.cc index df18a95..bc86c96 100644 --- a/media/audio/sounds/sounds_manager.cc +++ b/media/audio/sounds/sounds_manager.cc @@ -19,6 +19,7 @@ namespace media { namespace { SoundsManager* g_instance = NULL; +bool g_initialized_for_testing = false; // SoundsManagerImpl --------------------------------------------------- @@ -123,7 +124,11 @@ SoundsManager::~SoundsManager() { DCHECK(CalledOnValidThread()); } // static void SoundsManager::Create() { - CHECK(!g_instance) << "SoundsManager::Create() is called twice"; + CHECK(!g_instance || g_initialized_for_testing) + << "SoundsManager::Create() is called twice"; + if (g_initialized_for_testing) + return; + const bool enabled = !CommandLine::ForCurrentProcess()->HasSwitch( ::switches::kDisableSystemSoundsManager); if (enabled) @@ -146,4 +151,12 @@ SoundsManager* SoundsManager::Get() { return g_instance; } +// static +void SoundsManager::InitializeForTesting(SoundsManager* manager) { + CHECK(!g_instance) << "SoundsManager is already initialized."; + CHECK(manager); + g_instance = manager; + g_initialized_for_testing = true; +} + } // namespace media diff --git a/media/audio/sounds/sounds_manager.h b/media/audio/sounds/sounds_manager.h index 7ff6aaf..71184da 100644 --- a/media/audio/sounds/sounds_manager.h +++ b/media/audio/sounds/sounds_manager.h @@ -29,6 +29,10 @@ class MEDIA_EXPORT SoundsManager : public base::NonThreadSafe { // Returns a pointer to a singleton instance of the SoundsManager. static SoundsManager* Get(); + // Initializes sounds manager for testing. The |manager| will be owned + // by the internal pointer and will be deleted by Shutdown(). + static void InitializeForTesting(SoundsManager* manager); + // Initializes SoundsManager with the wav data for the system // sounds. Returns true if SoundsManager was successfully // initialized. |