Chromium Code Reviews| Index: chromeos/audio/cras_audio_handler.cc |
| diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc |
| index 96f3a452322e46cef18c7b019b0881830d07b90d..2d3f69db9eaf35e9614f2e0df5358163b5332e82 100644 |
| --- a/chromeos/audio/cras_audio_handler.cc |
| +++ b/chromeos/audio/cras_audio_handler.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/bind_helpers.h" |
| #include "base/logging.h" |
| #include "chromeos/audio/audio_pref_handler.h" |
| +#include "chromeos/audio/mock_cras_audio_handler.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| using std::max; |
| @@ -63,6 +64,12 @@ void CrasAudioHandler::Initialize( |
| } |
| // static |
| +void CrasAudioHandler::InitializeForTesting() { |
| + CHECK(!g_cras_audio_handler); |
| + g_cras_audio_handler = new MockCrasAudioHandler(); |
| +} |
| + |
| +// static |
| void CrasAudioHandler::Shutdown() { |
| CHECK(g_cras_audio_handler); |
| delete g_cras_audio_handler; |
| @@ -191,6 +198,10 @@ CrasAudioHandler::CrasAudioHandler( |
| has_alternative_output_(false), |
| output_mute_locked_(false), |
| input_mute_locked_(false) { |
| + // If the DBusThreadManager isn't initialized, there isn't anything we can |
| + // do. This usually happens when running in a test. |
| + if (!chromeos::DBusThreadManager::IsInitialized()) |
| + return; |
| chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->AddObserver(this); |
| DCHECK(audio_pref_handler_.get()); |
| audio_pref_handler_->AddAudioPrefObserver(this); |
| @@ -204,6 +215,20 @@ CrasAudioHandler::~CrasAudioHandler() { |
| audio_pref_handler_ = NULL; |
| } |
| +CrasAudioHandler::CrasAudioHandler() |
|
James Cook
2013/04/30 20:55:05
Do you really need this extra constructor, or coul
rkc
2013/04/30 23:04:57
Done.
|
| + : audio_pref_handler_(NULL), |
| + weak_ptr_factory_(this), |
| + output_mute_on_(false), |
| + input_mute_on_(false), |
| + output_volume_(0), |
| + active_output_node_id_(0), |
| + active_input_node_id_(0), |
| + has_alternative_input_(false), |
| + has_alternative_output_(false), |
| + output_mute_locked_(false), |
| + input_mute_locked_(false) { |
| +} |
| + |
| void CrasAudioHandler::AudioClientRestarted() { |
| SetupInitialAudioState(); |
| } |