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

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

Issue 2314853004: Remove calls to deprecated MessageLoop methods in chromeos. (Closed)
Patch Set: Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 void SetUpCrasAudioHandler(const AudioNodeList& audio_nodes) { 328 void SetUpCrasAudioHandler(const AudioNodeList& audio_nodes) {
329 DBusThreadManager::Initialize(); 329 DBusThreadManager::Initialize();
330 fake_cras_audio_client_ = static_cast<FakeCrasAudioClient*>( 330 fake_cras_audio_client_ = static_cast<FakeCrasAudioClient*>(
331 DBusThreadManager::Get()->GetCrasAudioClient()); 331 DBusThreadManager::Get()->GetCrasAudioClient());
332 fake_cras_audio_client_->SetAudioNodesForTesting(audio_nodes); 332 fake_cras_audio_client_->SetAudioNodesForTesting(audio_nodes);
333 audio_pref_handler_ = new AudioDevicesPrefHandlerStub(); 333 audio_pref_handler_ = new AudioDevicesPrefHandlerStub();
334 CrasAudioHandler::Initialize(audio_pref_handler_); 334 CrasAudioHandler::Initialize(audio_pref_handler_);
335 cras_audio_handler_ = CrasAudioHandler::Get(); 335 cras_audio_handler_ = CrasAudioHandler::Get();
336 test_observer_.reset(new TestObserver); 336 test_observer_.reset(new TestObserver);
337 cras_audio_handler_->AddAudioObserver(test_observer_.get()); 337 cras_audio_handler_->AddAudioObserver(test_observer_.get());
338 message_loop_.RunUntilIdle(); 338 base::RunLoop().RunUntilIdle();
339 } 339 }
340 340
341 // Set up cras audio handlers with |audio_nodes| and set the active state of 341 // Set up cras audio handlers with |audio_nodes| and set the active state of
342 // |active_device_in_pref| as active and |activate_by_user| in the pref, 342 // |active_device_in_pref| as active and |activate_by_user| in the pref,
343 // and rest of nodes in |audio_nodes_in_pref| as inactive. 343 // and rest of nodes in |audio_nodes_in_pref| as inactive.
344 void SetupCrasAudioHandlerWithActiveNodeInPref( 344 void SetupCrasAudioHandlerWithActiveNodeInPref(
345 const AudioNodeList& audio_nodes, 345 const AudioNodeList& audio_nodes,
346 const AudioNodeList& audio_nodes_in_pref, 346 const AudioNodeList& audio_nodes_in_pref,
347 const AudioDevice& active_device_in_pref, 347 const AudioDevice& active_device_in_pref,
348 bool activate_by_user) { 348 bool activate_by_user) {
(...skipping 13 matching lines...) Expand all
362 &active, &activate_by)); 362 &active, &activate_by));
363 EXPECT_TRUE(active); 363 EXPECT_TRUE(active);
364 EXPECT_EQ(activate_by, activate_by_user); 364 EXPECT_EQ(activate_by, activate_by_user);
365 365
366 fake_cras_audio_client_->SetAudioNodesForTesting(audio_nodes); 366 fake_cras_audio_client_->SetAudioNodesForTesting(audio_nodes);
367 CrasAudioHandler::Initialize(audio_pref_handler_); 367 CrasAudioHandler::Initialize(audio_pref_handler_);
368 368
369 cras_audio_handler_ = CrasAudioHandler::Get(); 369 cras_audio_handler_ = CrasAudioHandler::Get();
370 test_observer_.reset(new TestObserver); 370 test_observer_.reset(new TestObserver);
371 cras_audio_handler_->AddAudioObserver(test_observer_.get()); 371 cras_audio_handler_->AddAudioObserver(test_observer_.get());
372 message_loop_.RunUntilIdle(); 372 base::RunLoop().RunUntilIdle();
373 } 373 }
374 374
375 void SetUpCrasAudioHandlerWithPrimaryActiveNode( 375 void SetUpCrasAudioHandlerWithPrimaryActiveNode(
376 const AudioNodeList& audio_nodes, 376 const AudioNodeList& audio_nodes,
377 const AudioNode& primary_active_node) { 377 const AudioNode& primary_active_node) {
378 DBusThreadManager::Initialize(); 378 DBusThreadManager::Initialize();
379 fake_cras_audio_client_ = static_cast<FakeCrasAudioClient*>( 379 fake_cras_audio_client_ = static_cast<FakeCrasAudioClient*>(
380 DBusThreadManager::Get()->GetCrasAudioClient()); 380 DBusThreadManager::Get()->GetCrasAudioClient());
381 fake_cras_audio_client_->SetAudioNodesForTesting(audio_nodes); 381 fake_cras_audio_client_->SetAudioNodesForTesting(audio_nodes);
382 fake_cras_audio_client_->SetActiveOutputNode(primary_active_node.id), 382 fake_cras_audio_client_->SetActiveOutputNode(primary_active_node.id),
383 audio_pref_handler_ = new AudioDevicesPrefHandlerStub(); 383 audio_pref_handler_ = new AudioDevicesPrefHandlerStub();
384 CrasAudioHandler::Initialize(audio_pref_handler_); 384 CrasAudioHandler::Initialize(audio_pref_handler_);
385 cras_audio_handler_ = CrasAudioHandler::Get(); 385 cras_audio_handler_ = CrasAudioHandler::Get();
386 test_observer_.reset(new TestObserver); 386 test_observer_.reset(new TestObserver);
387 cras_audio_handler_->AddAudioObserver(test_observer_.get()); 387 cras_audio_handler_->AddAudioObserver(test_observer_.get());
388 message_loop_.RunUntilIdle(); 388 base::RunLoop().RunUntilIdle();
389 } 389 }
390 390
391 void ChangeAudioNodes(const AudioNodeList& audio_nodes) { 391 void ChangeAudioNodes(const AudioNodeList& audio_nodes) {
392 fake_cras_audio_client_->SetAudioNodesAndNotifyObserversForTesting( 392 fake_cras_audio_client_->SetAudioNodesAndNotifyObserversForTesting(
393 audio_nodes); 393 audio_nodes);
394 message_loop_.RunUntilIdle(); 394 base::RunLoop().RunUntilIdle();
395 } 395 }
396 396
397 const AudioDevice* GetDeviceFromId(uint64_t id) { 397 const AudioDevice* GetDeviceFromId(uint64_t id) {
398 return cras_audio_handler_->GetDeviceFromId(id); 398 return cras_audio_handler_->GetDeviceFromId(id);
399 } 399 }
400 400
401 int GetActiveDeviceCount() const { 401 int GetActiveDeviceCount() const {
402 int num_active_nodes = 0; 402 int num_active_nodes = 0;
403 AudioDeviceList audio_devices; 403 AudioDeviceList audio_devices;
404 cras_audio_handler_->GetAudioDevices(&audio_devices); 404 cras_audio_handler_->GetAudioDevices(&audio_devices);
(...skipping 11 matching lines...) Expand all
416 void SetHDMIRediscoverGracePeriodDuration(int duration_in_ms) { 416 void SetHDMIRediscoverGracePeriodDuration(int duration_in_ms) {
417 cras_audio_handler_->SetHDMIRediscoverGracePeriodForTesting(duration_in_ms); 417 cras_audio_handler_->SetHDMIRediscoverGracePeriodForTesting(duration_in_ms);
418 } 418 }
419 419
420 bool IsDuringHDMIRediscoverGracePeriod() { 420 bool IsDuringHDMIRediscoverGracePeriod() {
421 return cras_audio_handler_->hdmi_rediscovering(); 421 return cras_audio_handler_->hdmi_rediscovering();
422 } 422 }
423 423
424 void RestartAudioClient() { 424 void RestartAudioClient() {
425 cras_audio_handler_->AudioClientRestarted(); 425 cras_audio_handler_->AudioClientRestarted();
426 message_loop_.RunUntilIdle(); 426 base::RunLoop().RunUntilIdle();
427 } 427 }
428 428
429 protected: 429 protected:
430 base::MessageLoopForUI message_loop_; 430 base::MessageLoopForUI message_loop_;
431 CrasAudioHandler* cras_audio_handler_; // Not owned. 431 CrasAudioHandler* cras_audio_handler_; // Not owned.
432 FakeCrasAudioClient* fake_cras_audio_client_; // Not owned. 432 FakeCrasAudioClient* fake_cras_audio_client_; // Not owned.
433 std::unique_ptr<TestObserver> test_observer_; 433 std::unique_ptr<TestObserver> test_observer_;
434 scoped_refptr<AudioDevicesPrefHandlerStub> audio_pref_handler_; 434 scoped_refptr<AudioDevicesPrefHandlerStub> audio_pref_handler_;
435 435
436 private: 436 private:
(...skipping 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after
3403 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); 3403 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output));
3404 EXPECT_EQ(kInternalSpeaker.id, active_output.id); 3404 EXPECT_EQ(kInternalSpeaker.id, active_output.id);
3405 EXPECT_EQ(kInternalSpeaker.id, 3405 EXPECT_EQ(kInternalSpeaker.id,
3406 cras_audio_handler_->GetPrimaryActiveOutputNode()); 3406 cras_audio_handler_->GetPrimaryActiveOutputNode());
3407 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); 3407 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted());
3408 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); 3408 EXPECT_EQ(1, test_observer_->output_mute_changed_count());
3409 EXPECT_TRUE(test_observer_->output_mute_by_system()); 3409 EXPECT_TRUE(test_observer_->output_mute_by_system());
3410 } 3410 }
3411 3411
3412 } // namespace chromeos 3412 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/dbus/cras_audio_client_unittest.cc » ('j') | chromeos/geolocation/simple_geolocation_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698