Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1192)

Side by Side Diff: chromeos/audio/cras_audio_handler_unittest.cc

Issue 515573003: app_shell: Do simple audio initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wrap line Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/audio/audio_device.cc ('k') | chromeos/dbus/cras_audio_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chromeos/audio/audio_device.cc ('k') | chromeos/dbus/cras_audio_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698