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

Side by Side Diff: chromeos/dbus/cras_audio_client_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/dbus/cras_audio_client.h" 5 #include "chromeos/dbus/cras_audio_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h"
13 #include "dbus/message.h" 14 #include "dbus/message.h"
14 #include "dbus/mock_bus.h" 15 #include "dbus/mock_bus.h"
15 #include "dbus/mock_object_proxy.h" 16 #include "dbus/mock_object_proxy.h"
16 #include "dbus/object_path.h" 17 #include "dbus/object_path.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h" 20 #include "third_party/cros_system_api/dbus/service_constants.h"
20 21
21 using ::testing::_; 22 using ::testing::_;
22 using ::testing::Invoke; 23 using ::testing::Invoke;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 dbus::ObjectPath(cras::kCrasServicePath))) 300 dbus::ObjectPath(cras::kCrasServicePath)))
300 .WillOnce(Return(mock_cras_proxy_.get())); 301 .WillOnce(Return(mock_cras_proxy_.get()));
301 302
302 // ShutdownAndBlock() will be called in TearDown(). 303 // ShutdownAndBlock() will be called in TearDown().
303 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return()); 304 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return());
304 305
305 // Create a client with the mock bus. 306 // Create a client with the mock bus.
306 client_.reset(CrasAudioClient::Create()); 307 client_.reset(CrasAudioClient::Create());
307 client_->Init(mock_bus_.get()); 308 client_->Init(mock_bus_.get());
308 // Run the message loop to run the signal connection result callback. 309 // Run the message loop to run the signal connection result callback.
309 message_loop_.RunUntilIdle(); 310 base::RunLoop().RunUntilIdle();
310 } 311 }
311 312
312 void TearDown() override { mock_bus_->ShutdownAndBlock(); } 313 void TearDown() override { mock_bus_->ShutdownAndBlock(); }
313 314
314 protected: 315 protected:
315 // A callback to intercept and check the method call arguments. 316 // A callback to intercept and check the method call arguments.
316 typedef base::Callback<void( 317 typedef base::Callback<void(
317 dbus::MessageReader* reader)> ArgumentCheckCallback; 318 dbus::MessageReader* reader)> ArgumentCheckCallback;
318 319
319 // Sets expectations for called method name and arguments, and sets response. 320 // Sets expectations for called method name and arguments, and sets response.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 SendOutputMuteChangedSignal(&signal); 533 SendOutputMuteChangedSignal(&signal);
533 534
534 // Remove the observer. 535 // Remove the observer.
535 client_->RemoveObserver(&observer); 536 client_->RemoveObserver(&observer);
536 537
537 EXPECT_CALL(observer, OutputMuteChanged(_)).Times(0); 538 EXPECT_CALL(observer, OutputMuteChanged(_)).Times(0);
538 539
539 // Run the signal callback again and make sure the observer isn't called. 540 // Run the signal callback again and make sure the observer isn't called.
540 SendOutputMuteChangedSignal(&signal); 541 SendOutputMuteChangedSignal(&signal);
541 542
542 message_loop_.RunUntilIdle(); 543 base::RunLoop().RunUntilIdle();
543 } 544 }
544 545
545 TEST_F(CrasAudioClientTest, InputMuteChanged) { 546 TEST_F(CrasAudioClientTest, InputMuteChanged) {
546 const bool kInputMuteOn = true; 547 const bool kInputMuteOn = true;
547 // Create a signal. 548 // Create a signal.
548 dbus::Signal signal(cras::kCrasControlInterface, 549 dbus::Signal signal(cras::kCrasControlInterface,
549 cras::kInputMuteChanged); 550 cras::kInputMuteChanged);
550 dbus::MessageWriter writer(&signal); 551 dbus::MessageWriter writer(&signal);
551 writer.AppendBool(kInputMuteOn); 552 writer.AppendBool(kInputMuteOn);
552 553
553 // Set expectations. 554 // Set expectations.
554 MockObserver observer; 555 MockObserver observer;
555 EXPECT_CALL(observer, InputMuteChanged(kInputMuteOn)).Times(1); 556 EXPECT_CALL(observer, InputMuteChanged(kInputMuteOn)).Times(1);
556 557
557 // Add the observer. 558 // Add the observer.
558 client_->AddObserver(&observer); 559 client_->AddObserver(&observer);
559 560
560 // Run the signal callback. 561 // Run the signal callback.
561 SendInputMuteChangedSignal(&signal); 562 SendInputMuteChangedSignal(&signal);
562 563
563 // Remove the observer. 564 // Remove the observer.
564 client_->RemoveObserver(&observer); 565 client_->RemoveObserver(&observer);
565 566
566 EXPECT_CALL(observer, InputMuteChanged(_)).Times(0); 567 EXPECT_CALL(observer, InputMuteChanged(_)).Times(0);
567 568
568 // Run the signal callback again and make sure the observer isn't called. 569 // Run the signal callback again and make sure the observer isn't called.
569 SendInputMuteChangedSignal(&signal); 570 SendInputMuteChangedSignal(&signal);
570 571
571 message_loop_.RunUntilIdle(); 572 base::RunLoop().RunUntilIdle();
572 } 573 }
573 574
574 TEST_F(CrasAudioClientTest, NodesChanged) { 575 TEST_F(CrasAudioClientTest, NodesChanged) {
575 // Create a signal. 576 // Create a signal.
576 dbus::Signal signal(cras::kCrasControlInterface, 577 dbus::Signal signal(cras::kCrasControlInterface,
577 cras::kNodesChanged); 578 cras::kNodesChanged);
578 // Set expectations. 579 // Set expectations.
579 MockObserver observer; 580 MockObserver observer;
580 EXPECT_CALL(observer, NodesChanged()).Times(1); 581 EXPECT_CALL(observer, NodesChanged()).Times(1);
581 582
582 // Add the observer. 583 // Add the observer.
583 client_->AddObserver(&observer); 584 client_->AddObserver(&observer);
584 585
585 // Run the signal callback. 586 // Run the signal callback.
586 SendNodesChangedSignal(&signal); 587 SendNodesChangedSignal(&signal);
587 588
588 // Remove the observer. 589 // Remove the observer.
589 client_->RemoveObserver(&observer); 590 client_->RemoveObserver(&observer);
590 591
591 EXPECT_CALL(observer, NodesChanged()).Times(0); 592 EXPECT_CALL(observer, NodesChanged()).Times(0);
592 593
593 // Run the signal callback again and make sure the observer isn't called. 594 // Run the signal callback again and make sure the observer isn't called.
594 SendNodesChangedSignal(&signal); 595 SendNodesChangedSignal(&signal);
595 596
596 message_loop_.RunUntilIdle(); 597 base::RunLoop().RunUntilIdle();
597 } 598 }
598 599
599 TEST_F(CrasAudioClientTest, ActiveOutputNodeChanged) { 600 TEST_F(CrasAudioClientTest, ActiveOutputNodeChanged) {
600 const uint64_t kNodeId = 10002; 601 const uint64_t kNodeId = 10002;
601 // Create a signal. 602 // Create a signal.
602 dbus::Signal signal(cras::kCrasControlInterface, 603 dbus::Signal signal(cras::kCrasControlInterface,
603 cras::kActiveOutputNodeChanged); 604 cras::kActiveOutputNodeChanged);
604 dbus::MessageWriter writer(&signal); 605 dbus::MessageWriter writer(&signal);
605 writer.AppendUint64(kNodeId); 606 writer.AppendUint64(kNodeId);
606 607
607 // Set expectations. 608 // Set expectations.
608 MockObserver observer; 609 MockObserver observer;
609 EXPECT_CALL(observer, ActiveOutputNodeChanged(kNodeId)).Times(1); 610 EXPECT_CALL(observer, ActiveOutputNodeChanged(kNodeId)).Times(1);
610 611
611 // Add the observer. 612 // Add the observer.
612 client_->AddObserver(&observer); 613 client_->AddObserver(&observer);
613 614
614 // Run the signal callback. 615 // Run the signal callback.
615 SendActiveOutputNodeChangedSignal(&signal); 616 SendActiveOutputNodeChangedSignal(&signal);
616 617
617 // Remove the observer. 618 // Remove the observer.
618 client_->RemoveObserver(&observer); 619 client_->RemoveObserver(&observer);
619 EXPECT_CALL(observer, ActiveOutputNodeChanged(_)).Times(0); 620 EXPECT_CALL(observer, ActiveOutputNodeChanged(_)).Times(0);
620 621
621 // Run the signal callback again and make sure the observer isn't called. 622 // Run the signal callback again and make sure the observer isn't called.
622 SendActiveOutputNodeChangedSignal(&signal); 623 SendActiveOutputNodeChangedSignal(&signal);
623 624
624 message_loop_.RunUntilIdle(); 625 base::RunLoop().RunUntilIdle();
625 } 626 }
626 627
627 TEST_F(CrasAudioClientTest, ActiveInputNodeChanged) { 628 TEST_F(CrasAudioClientTest, ActiveInputNodeChanged) {
628 const uint64_t kNodeId = 20002; 629 const uint64_t kNodeId = 20002;
629 // Create a signal. 630 // Create a signal.
630 dbus::Signal signal(cras::kCrasControlInterface, 631 dbus::Signal signal(cras::kCrasControlInterface,
631 cras::kActiveInputNodeChanged); 632 cras::kActiveInputNodeChanged);
632 dbus::MessageWriter writer(&signal); 633 dbus::MessageWriter writer(&signal);
633 writer.AppendUint64(kNodeId); 634 writer.AppendUint64(kNodeId);
634 635
635 // Set expectations. 636 // Set expectations.
636 MockObserver observer; 637 MockObserver observer;
637 EXPECT_CALL(observer, ActiveInputNodeChanged(kNodeId)).Times(1); 638 EXPECT_CALL(observer, ActiveInputNodeChanged(kNodeId)).Times(1);
638 639
639 // Add the observer. 640 // Add the observer.
640 client_->AddObserver(&observer); 641 client_->AddObserver(&observer);
641 642
642 // Run the signal callback. 643 // Run the signal callback.
643 SendActiveInputNodeChangedSignal(&signal); 644 SendActiveInputNodeChangedSignal(&signal);
644 645
645 // Remove the observer. 646 // Remove the observer.
646 client_->RemoveObserver(&observer); 647 client_->RemoveObserver(&observer);
647 EXPECT_CALL(observer, ActiveInputNodeChanged(_)).Times(0); 648 EXPECT_CALL(observer, ActiveInputNodeChanged(_)).Times(0);
648 649
649 // Run the signal callback again and make sure the observer isn't called. 650 // Run the signal callback again and make sure the observer isn't called.
650 SendActiveInputNodeChangedSignal(&signal); 651 SendActiveInputNodeChangedSignal(&signal);
651 652
652 message_loop_.RunUntilIdle(); 653 base::RunLoop().RunUntilIdle();
653 } 654 }
654 655
655 TEST_F(CrasAudioClientTest, OutputNodeVolumeChanged) { 656 TEST_F(CrasAudioClientTest, OutputNodeVolumeChanged) {
656 const uint64_t kNodeId = 20003; 657 const uint64_t kNodeId = 20003;
657 const int32_t volume = 82; 658 const int32_t volume = 82;
658 // Create a signal 659 // Create a signal
659 dbus::Signal signal(cras::kCrasControlInterface, 660 dbus::Signal signal(cras::kCrasControlInterface,
660 cras::kOutputNodeVolumeChanged); 661 cras::kOutputNodeVolumeChanged);
661 dbus::MessageWriter writer(&signal); 662 dbus::MessageWriter writer(&signal);
662 writer.AppendUint64(kNodeId); 663 writer.AppendUint64(kNodeId);
663 writer.AppendInt32(volume); 664 writer.AppendInt32(volume);
664 665
665 // Set expectations 666 // Set expectations
666 MockObserver observer; 667 MockObserver observer;
667 EXPECT_CALL(observer, OutputNodeVolumeChanged(kNodeId, volume)).Times(1); 668 EXPECT_CALL(observer, OutputNodeVolumeChanged(kNodeId, volume)).Times(1);
668 669
669 // Add the observer. 670 // Add the observer.
670 client_->AddObserver(&observer); 671 client_->AddObserver(&observer);
671 672
672 // Run the signal callback. 673 // Run the signal callback.
673 SendOutputNodeVolumeChangedSignal(&signal); 674 SendOutputNodeVolumeChangedSignal(&signal);
674 675
675 // Remove the observer. 676 // Remove the observer.
676 client_->RemoveObserver(&observer); 677 client_->RemoveObserver(&observer);
677 EXPECT_CALL(observer, OutputNodeVolumeChanged(_, _)).Times(0); 678 EXPECT_CALL(observer, OutputNodeVolumeChanged(_, _)).Times(0);
678 679
679 // Run the signal callback again and make sure the observer isn't called. 680 // Run the signal callback again and make sure the observer isn't called.
680 SendOutputNodeVolumeChangedSignal(&signal); 681 SendOutputNodeVolumeChangedSignal(&signal);
681 682
682 message_loop_.RunUntilIdle(); 683 base::RunLoop().RunUntilIdle();
683 } 684 }
684 685
685 TEST_F(CrasAudioClientTest, GetNodes) { 686 TEST_F(CrasAudioClientTest, GetNodes) {
686 // Create the expected value. 687 // Create the expected value.
687 AudioNodeList expected_node_list; 688 AudioNodeList expected_node_list;
688 expected_node_list.push_back(kInternalSpeaker); 689 expected_node_list.push_back(kInternalSpeaker);
689 expected_node_list.push_back(kInternalMic); 690 expected_node_list.push_back(kInternalMic);
690 691
691 // Create response. 692 // Create response.
692 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 693 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
693 dbus::MessageWriter writer(response.get()); 694 dbus::MessageWriter writer(response.get());
694 WriteNodesToResponse(writer, expected_node_list); 695 WriteNodesToResponse(writer, expected_node_list);
695 696
696 // Set expectations. 697 // Set expectations.
697 PrepareForMethodCall(cras::kGetNodes, 698 PrepareForMethodCall(cras::kGetNodes,
698 base::Bind(&ExpectNoArgument), 699 base::Bind(&ExpectNoArgument),
699 response.get()); 700 response.get());
700 // Call method. 701 // Call method.
701 MockErrorCallback error_callback; 702 MockErrorCallback error_callback;
702 client_->GetNodes(base::Bind(&ExpectAudioNodeListResult, 703 client_->GetNodes(base::Bind(&ExpectAudioNodeListResult,
703 &expected_node_list), 704 &expected_node_list),
704 error_callback.GetCallback()); 705 error_callback.GetCallback());
705 EXPECT_CALL(error_callback, Run(_, _)).Times(0); 706 EXPECT_CALL(error_callback, Run(_, _)).Times(0);
706 // Run the message loop. 707 // Run the message loop.
707 message_loop_.RunUntilIdle(); 708 base::RunLoop().RunUntilIdle();
708 } 709 }
709 710
710 TEST_F(CrasAudioClientTest, SetOutputNodeVolume) { 711 TEST_F(CrasAudioClientTest, SetOutputNodeVolume) {
711 const uint64_t kNodeId = 10003; 712 const uint64_t kNodeId = 10003;
712 const int32_t kVolume = 80; 713 const int32_t kVolume = 80;
713 // Create response. 714 // Create response.
714 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 715 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
715 716
716 // Set expectations. 717 // Set expectations.
717 PrepareForMethodCall(cras::kSetOutputNodeVolume, 718 PrepareForMethodCall(cras::kSetOutputNodeVolume,
718 base::Bind(&ExpectUint64AndInt32Arguments, 719 base::Bind(&ExpectUint64AndInt32Arguments,
719 kNodeId, 720 kNodeId,
720 kVolume), 721 kVolume),
721 response.get()); 722 response.get());
722 // Call method. 723 // Call method.
723 client_->SetOutputNodeVolume(kNodeId, kVolume); 724 client_->SetOutputNodeVolume(kNodeId, kVolume);
724 // Run the message loop. 725 // Run the message loop.
725 message_loop_.RunUntilIdle(); 726 base::RunLoop().RunUntilIdle();
726 } 727 }
727 728
728 TEST_F(CrasAudioClientTest, SetOutputUserMute) { 729 TEST_F(CrasAudioClientTest, SetOutputUserMute) {
729 const bool kUserMuteOn = true; 730 const bool kUserMuteOn = true;
730 // Create response. 731 // Create response.
731 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 732 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
732 733
733 // Set expectations. 734 // Set expectations.
734 PrepareForMethodCall(cras::kSetOutputUserMute, 735 PrepareForMethodCall(cras::kSetOutputUserMute,
735 base::Bind(&ExpectBoolArgument, kUserMuteOn), 736 base::Bind(&ExpectBoolArgument, kUserMuteOn),
736 response.get()); 737 response.get());
737 // Call method. 738 // Call method.
738 client_->SetOutputUserMute(kUserMuteOn); 739 client_->SetOutputUserMute(kUserMuteOn);
739 // Run the message loop. 740 // Run the message loop.
740 message_loop_.RunUntilIdle(); 741 base::RunLoop().RunUntilIdle();
741 } 742 }
742 743
743 TEST_F(CrasAudioClientTest, SetInputNodeGain) { 744 TEST_F(CrasAudioClientTest, SetInputNodeGain) {
744 const uint64_t kNodeId = 20003; 745 const uint64_t kNodeId = 20003;
745 const int32_t kInputGain = 2; 746 const int32_t kInputGain = 2;
746 // Create response. 747 // Create response.
747 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 748 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
748 749
749 // Set expectations. 750 // Set expectations.
750 PrepareForMethodCall(cras::kSetInputNodeGain, 751 PrepareForMethodCall(cras::kSetInputNodeGain,
751 base::Bind(&ExpectUint64AndInt32Arguments, 752 base::Bind(&ExpectUint64AndInt32Arguments,
752 kNodeId, 753 kNodeId,
753 kInputGain), 754 kInputGain),
754 response.get()); 755 response.get());
755 // Call method. 756 // Call method.
756 client_->SetInputNodeGain(kNodeId, kInputGain); 757 client_->SetInputNodeGain(kNodeId, kInputGain);
757 // Run the message loop. 758 // Run the message loop.
758 message_loop_.RunUntilIdle(); 759 base::RunLoop().RunUntilIdle();
759 } 760 }
760 761
761 TEST_F(CrasAudioClientTest, SetInputMute) { 762 TEST_F(CrasAudioClientTest, SetInputMute) {
762 const bool kInputMuteOn = true; 763 const bool kInputMuteOn = true;
763 // Create response. 764 // Create response.
764 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 765 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
765 766
766 // Set expectations. 767 // Set expectations.
767 PrepareForMethodCall(cras::kSetInputMute, 768 PrepareForMethodCall(cras::kSetInputMute,
768 base::Bind(&ExpectBoolArgument, kInputMuteOn), 769 base::Bind(&ExpectBoolArgument, kInputMuteOn),
769 response.get()); 770 response.get());
770 // Call method. 771 // Call method.
771 client_->SetInputMute(kInputMuteOn); 772 client_->SetInputMute(kInputMuteOn);
772 // Run the message loop. 773 // Run the message loop.
773 message_loop_.RunUntilIdle(); 774 base::RunLoop().RunUntilIdle();
774 } 775 }
775 776
776 TEST_F(CrasAudioClientTest, SetActiveOutputNode) { 777 TEST_F(CrasAudioClientTest, SetActiveOutputNode) {
777 const uint64_t kNodeId = 10004; 778 const uint64_t kNodeId = 10004;
778 // Create response. 779 // Create response.
779 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 780 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
780 781
781 // Set expectations. 782 // Set expectations.
782 PrepareForMethodCall(cras::kSetActiveOutputNode, 783 PrepareForMethodCall(cras::kSetActiveOutputNode,
783 base::Bind(&ExpectUint64Argument, kNodeId), 784 base::Bind(&ExpectUint64Argument, kNodeId),
784 response.get()); 785 response.get());
785 // Call method. 786 // Call method.
786 client_->SetActiveOutputNode(kNodeId); 787 client_->SetActiveOutputNode(kNodeId);
787 // Run the message loop. 788 // Run the message loop.
788 message_loop_.RunUntilIdle(); 789 base::RunLoop().RunUntilIdle();
789 } 790 }
790 791
791 TEST_F(CrasAudioClientTest, SetActiveInputNode) { 792 TEST_F(CrasAudioClientTest, SetActiveInputNode) {
792 const uint64_t kNodeId = 20004; 793 const uint64_t kNodeId = 20004;
793 // Create response. 794 // Create response.
794 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 795 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
795 796
796 // Set expectations. 797 // Set expectations.
797 PrepareForMethodCall(cras::kSetActiveInputNode, 798 PrepareForMethodCall(cras::kSetActiveInputNode,
798 base::Bind(&ExpectUint64Argument, kNodeId), 799 base::Bind(&ExpectUint64Argument, kNodeId),
799 response.get()); 800 response.get());
800 // Call method. 801 // Call method.
801 client_->SetActiveInputNode(kNodeId); 802 client_->SetActiveInputNode(kNodeId);
802 // Run the message loop. 803 // Run the message loop.
803 message_loop_.RunUntilIdle(); 804 base::RunLoop().RunUntilIdle();
804 } 805 }
805 806
806 TEST_F(CrasAudioClientTest, AddActiveInputNode) { 807 TEST_F(CrasAudioClientTest, AddActiveInputNode) {
807 const uint64_t kNodeId = 20005; 808 const uint64_t kNodeId = 20005;
808 // Create response. 809 // Create response.
809 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 810 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
810 811
811 // Set expectations. 812 // Set expectations.
812 PrepareForMethodCall(cras::kAddActiveInputNode, 813 PrepareForMethodCall(cras::kAddActiveInputNode,
813 base::Bind(&ExpectUint64Argument, kNodeId), 814 base::Bind(&ExpectUint64Argument, kNodeId),
814 response.get()); 815 response.get());
815 // Call method. 816 // Call method.
816 client_->AddActiveInputNode(kNodeId); 817 client_->AddActiveInputNode(kNodeId);
817 // Run the message loop. 818 // Run the message loop.
818 message_loop_.RunUntilIdle(); 819 base::RunLoop().RunUntilIdle();
819 } 820 }
820 821
821 TEST_F(CrasAudioClientTest, RemoveActiveInputNode) { 822 TEST_F(CrasAudioClientTest, RemoveActiveInputNode) {
822 const uint64_t kNodeId = 20006; 823 const uint64_t kNodeId = 20006;
823 // Create response. 824 // Create response.
824 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 825 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
825 826
826 // Set expectations. 827 // Set expectations.
827 PrepareForMethodCall(cras::kRemoveActiveInputNode, 828 PrepareForMethodCall(cras::kRemoveActiveInputNode,
828 base::Bind(&ExpectUint64Argument, kNodeId), 829 base::Bind(&ExpectUint64Argument, kNodeId),
829 response.get()); 830 response.get());
830 // Call method. 831 // Call method.
831 client_->RemoveActiveInputNode(kNodeId); 832 client_->RemoveActiveInputNode(kNodeId);
832 // Run the message loop. 833 // Run the message loop.
833 message_loop_.RunUntilIdle(); 834 base::RunLoop().RunUntilIdle();
834 } 835 }
835 836
836 TEST_F(CrasAudioClientTest, AddActiveOutputNode) { 837 TEST_F(CrasAudioClientTest, AddActiveOutputNode) {
837 const uint64_t kNodeId = 10005; 838 const uint64_t kNodeId = 10005;
838 // Create response. 839 // Create response.
839 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 840 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
840 841
841 // Set expectations. 842 // Set expectations.
842 PrepareForMethodCall(cras::kAddActiveOutputNode, 843 PrepareForMethodCall(cras::kAddActiveOutputNode,
843 base::Bind(&ExpectUint64Argument, kNodeId), 844 base::Bind(&ExpectUint64Argument, kNodeId),
844 response.get()); 845 response.get());
845 // Call method. 846 // Call method.
846 client_->AddActiveOutputNode(kNodeId); 847 client_->AddActiveOutputNode(kNodeId);
847 // Run the message loop. 848 // Run the message loop.
848 message_loop_.RunUntilIdle(); 849 base::RunLoop().RunUntilIdle();
849 } 850 }
850 851
851 TEST_F(CrasAudioClientTest, RemoveActiveOutputNode) { 852 TEST_F(CrasAudioClientTest, RemoveActiveOutputNode) {
852 const uint64_t kNodeId = 10006; 853 const uint64_t kNodeId = 10006;
853 // Create response. 854 // Create response.
854 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 855 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
855 856
856 // Set expectations. 857 // Set expectations.
857 PrepareForMethodCall(cras::kRemoveActiveOutputNode, 858 PrepareForMethodCall(cras::kRemoveActiveOutputNode,
858 base::Bind(&ExpectUint64Argument, kNodeId), 859 base::Bind(&ExpectUint64Argument, kNodeId),
859 response.get()); 860 response.get());
860 // Call method. 861 // Call method.
861 client_->RemoveActiveOutputNode(kNodeId); 862 client_->RemoveActiveOutputNode(kNodeId);
862 // Run the message loop. 863 // Run the message loop.
863 message_loop_.RunUntilIdle(); 864 base::RunLoop().RunUntilIdle();
864 } 865 }
865 866
866 TEST_F(CrasAudioClientTest, SwapLeftRight) { 867 TEST_F(CrasAudioClientTest, SwapLeftRight) {
867 const uint64_t kNodeId = 10007; 868 const uint64_t kNodeId = 10007;
868 const bool kSwap = true; 869 const bool kSwap = true;
869 // Create response. 870 // Create response.
870 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 871 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
871 872
872 // Set expectations. 873 // Set expectations.
873 PrepareForMethodCall(cras::kSwapLeftRight, 874 PrepareForMethodCall(cras::kSwapLeftRight,
874 base::Bind(&ExpectUint64AndBoolArguments, 875 base::Bind(&ExpectUint64AndBoolArguments,
875 kNodeId, 876 kNodeId,
876 kSwap), 877 kSwap),
877 response.get()); 878 response.get());
878 // Call method. 879 // Call method.
879 client_->SwapLeftRight(kNodeId, kSwap); 880 client_->SwapLeftRight(kNodeId, kSwap);
880 // Run the message loop. 881 // Run the message loop.
881 message_loop_.RunUntilIdle(); 882 base::RunLoop().RunUntilIdle();
882 } 883 }
883 884
884 TEST_F(CrasAudioClientTest, SetGlobalOutputChannelRemix) { 885 TEST_F(CrasAudioClientTest, SetGlobalOutputChannelRemix) {
885 const int32_t kChannels = 2; 886 const int32_t kChannels = 2;
886 const std::vector<double> kMixer = {0, 0.1, 0.5, 1}; 887 const std::vector<double> kMixer = {0, 0.1, 0.5, 1};
887 // Create response. 888 // Create response.
888 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 889 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
889 890
890 // Set expectations. 891 // Set expectations.
891 PrepareForMethodCall(cras::kSetGlobalOutputChannelRemix, 892 PrepareForMethodCall(cras::kSetGlobalOutputChannelRemix,
892 base::Bind(&ExpectInt32AndArrayOfDoublesArguments, 893 base::Bind(&ExpectInt32AndArrayOfDoublesArguments,
893 kChannels, 894 kChannels,
894 kMixer), 895 kMixer),
895 response.get()); 896 response.get());
896 897
897 // Call method. 898 // Call method.
898 client_->SetGlobalOutputChannelRemix(kChannels, kMixer); 899 client_->SetGlobalOutputChannelRemix(kChannels, kMixer);
899 // Run the message loop. 900 // Run the message loop.
900 message_loop_.RunUntilIdle(); 901 base::RunLoop().RunUntilIdle();
901 } 902 }
902 903
903 } // namespace chromeos 904 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698