OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/audio/cras_audio_handler.h" | 5 #include "chromeos/audio/cras_audio_handler.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 test_observer_.reset(); | 248 test_observer_.reset(); |
249 CrasAudioHandler::Shutdown(); | 249 CrasAudioHandler::Shutdown(); |
250 audio_pref_handler_ = NULL; | 250 audio_pref_handler_ = NULL; |
251 DBusThreadManager::Shutdown(); | 251 DBusThreadManager::Shutdown(); |
252 } | 252 } |
253 | 253 |
254 void SetUpCrasAudioHandler(const AudioNodeList& audio_nodes) { | 254 void SetUpCrasAudioHandler(const AudioNodeList& audio_nodes) { |
255 DBusThreadManager::Initialize(); | 255 DBusThreadManager::Initialize(); |
256 cras_audio_client_stub_ = static_cast<CrasAudioClientStubImpl*>( | 256 cras_audio_client_stub_ = static_cast<CrasAudioClientStubImpl*>( |
257 DBusThreadManager::Get()->GetCrasAudioClient()); | 257 DBusThreadManager::Get()->GetCrasAudioClient()); |
258 cras_audio_client_stub_->SetAudioDevices(audio_nodes); | 258 cras_audio_client_stub_->SetAudioNodesForTesting(audio_nodes); |
259 audio_pref_handler_ = new AudioDevicesPrefHandlerStub(); | 259 audio_pref_handler_ = new AudioDevicesPrefHandlerStub(); |
260 CrasAudioHandler::Initialize(audio_pref_handler_); | 260 CrasAudioHandler::Initialize(audio_pref_handler_); |
261 cras_audio_handler_ = CrasAudioHandler::Get(); | 261 cras_audio_handler_ = CrasAudioHandler::Get(); |
262 test_observer_.reset(new TestObserver); | 262 test_observer_.reset(new TestObserver); |
263 cras_audio_handler_->AddAudioObserver(test_observer_.get()); | 263 cras_audio_handler_->AddAudioObserver(test_observer_.get()); |
264 message_loop_.RunUntilIdle(); | 264 message_loop_.RunUntilIdle(); |
265 } | 265 } |
266 | 266 |
267 void ChangeAudioNodes(const AudioNodeList& audio_nodes) { | 267 void ChangeAudioNodes(const AudioNodeList& audio_nodes) { |
268 cras_audio_client_stub_->ChangeAudioNodes(audio_nodes); | 268 cras_audio_client_stub_->SetAudioNodesAndNotifyObserversForTesting( |
| 269 audio_nodes); |
269 message_loop_.RunUntilIdle(); | 270 message_loop_.RunUntilIdle(); |
270 } | 271 } |
271 | 272 |
272 protected: | 273 protected: |
273 base::MessageLoopForUI message_loop_; | 274 base::MessageLoopForUI message_loop_; |
274 CrasAudioHandler* cras_audio_handler_; // Not owned. | 275 CrasAudioHandler* cras_audio_handler_; // Not owned. |
275 CrasAudioClientStubImpl* cras_audio_client_stub_; // Not owned. | 276 CrasAudioClientStubImpl* cras_audio_client_stub_; // Not owned. |
276 scoped_ptr<TestObserver> test_observer_; | 277 scoped_ptr<TestObserver> test_observer_; |
277 scoped_refptr<AudioDevicesPrefHandlerStub> audio_pref_handler_; | 278 scoped_refptr<AudioDevicesPrefHandlerStub> audio_pref_handler_; |
278 | 279 |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 EXPECT_TRUE(cras_audio_handler_->has_alternative_output()); | 1712 EXPECT_TRUE(cras_audio_handler_->has_alternative_output()); |
1712 | 1713 |
1713 // Ensure the internal microphone has been selected as the active input, | 1714 // Ensure the internal microphone has been selected as the active input, |
1714 // and the input device with some random unknown type is handled gracefully. | 1715 // and the input device with some random unknown type is handled gracefully. |
1715 AudioDevice active_input; | 1716 AudioDevice active_input; |
1716 EXPECT_EQ(kInternalMic.id, cras_audio_handler_->GetActiveInputNode()); | 1717 EXPECT_EQ(kInternalMic.id, cras_audio_handler_->GetActiveInputNode()); |
1717 EXPECT_TRUE(cras_audio_handler_->has_alternative_input()); | 1718 EXPECT_TRUE(cras_audio_handler_->has_alternative_input()); |
1718 } | 1719 } |
1719 | 1720 |
1720 } // namespace chromeos | 1721 } // namespace chromeos |
OLD | NEW |