Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 2529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2540 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice( | 2540 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice( |
| 2541 &primary_active_device)); | 2541 &primary_active_device)); |
| 2542 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, primary_active_device.id); | 2542 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, primary_active_device.id); |
| 2543 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | 2543 EXPECT_EQ(kUSBJabraSpeakerInput1->id, |
| 2544 cras_audio_handler_->GetPrimaryActiveInputNode()); | 2544 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2545 | 2545 |
| 2546 // Set both jabra speakers's input and output nodes to active, this simulate | 2546 // Set both jabra speakers's input and output nodes to active, this simulate |
| 2547 // the call sent by hotrod initialization process. | 2547 // the call sent by hotrod initialization process. |
| 2548 test_observer_->reset_active_output_node_changed_count(); | 2548 test_observer_->reset_active_output_node_changed_count(); |
| 2549 test_observer_->reset_active_input_node_changed_count(); | 2549 test_observer_->reset_active_input_node_changed_count(); |
| 2550 CrasAudioHandler::NodeIdList active_nodes; | 2550 cras_audio_handler_->ChangeActiveNodes( |
| 2551 active_nodes.push_back(kUSBJabraSpeakerOutput1->id); | 2551 {kUSBJabraSpeakerOutput1->id, kUSBJabraSpeakerOutput2->id, |
| 2552 active_nodes.push_back(kUSBJabraSpeakerOutput2->id); | 2552 kUSBJabraSpeakerInput1->id, kUSBJabraSpeakerInput2->id}); |
| 2553 active_nodes.push_back(kUSBJabraSpeakerInput1->id); | |
| 2554 active_nodes.push_back(kUSBJabraSpeakerInput2->id); | |
| 2555 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2556 | 2553 |
| 2557 // Verify both jabra speakers' input/output nodes are made active. | 2554 // Verify both jabra speakers' input/output nodes are made active. |
| 2558 // num_active_nodes = GetActiveDeviceCount(); | 2555 // num_active_nodes = GetActiveDeviceCount(); |
| 2559 EXPECT_EQ(4, GetActiveDeviceCount()); | 2556 EXPECT_EQ(4, GetActiveDeviceCount()); |
| 2560 const AudioDevice* active_output_1 = | 2557 const AudioDevice* active_output_1 = |
| 2561 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | 2558 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); |
| 2562 EXPECT_TRUE(active_output_1->active); | 2559 EXPECT_TRUE(active_output_1->active); |
| 2563 const AudioDevice* active_output_2 = | 2560 const AudioDevice* active_output_2 = |
| 2564 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | 2561 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); |
| 2565 EXPECT_TRUE(active_output_2->active); | 2562 EXPECT_TRUE(active_output_2->active); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2597 // Adjust the volume of output devices, verify all active nodes are set to | 2594 // Adjust the volume of output devices, verify all active nodes are set to |
| 2598 // the same volume. | 2595 // the same volume. |
| 2599 cras_audio_handler_->SetOutputVolumePercent(25); | 2596 cras_audio_handler_->SetOutputVolumePercent(25); |
| 2600 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercent()); | 2597 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercent()); |
| 2601 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercentForDevice( | 2598 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercentForDevice( |
| 2602 kUSBJabraSpeakerOutput1->id)); | 2599 kUSBJabraSpeakerOutput1->id)); |
| 2603 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercentForDevice( | 2600 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercentForDevice( |
| 2604 kUSBJabraSpeakerOutput2->id)); | 2601 kUSBJabraSpeakerOutput2->id)); |
| 2605 } | 2602 } |
| 2606 | 2603 |
| 2604 TEST_P(CrasAudioHandlerTest, SetActiveNodesHotrodInit) { | |
| 2605 AudioNodeList audio_nodes = GenerateAudioNodeList( | |
| 2606 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerOutput2, | |
| 2607 kUSBJabraSpeakerInput1, kUSBJabraSpeakerInput2, kUSBCameraInput}); | |
|
jennyz
2017/01/07 00:33:00
Add a comment here: This simulates a typical hotro
tbarzic
2017/01/07 05:16:31
Done.
| |
| 2608 SetUpCrasAudioHandler(audio_nodes); | |
| 2609 | |
| 2610 // Verify the audio devices size. | |
| 2611 AudioDeviceList audio_devices; | |
| 2612 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 2613 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 2614 | |
| 2615 // Verify only the 1st jabra speaker's output and input are selected as active | |
| 2616 // nodes by CrasAudioHandler. | |
| 2617 AudioDevice active_output; | |
| 2618 EXPECT_TRUE( | |
| 2619 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); | |
| 2620 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 2621 AudioDevice primary_active_device; | |
| 2622 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice( | |
| 2623 &primary_active_device)); | |
| 2624 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, primary_active_device.id); | |
| 2625 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 2626 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 2627 | |
| 2628 // Set both jabra speakers's input and output nodes to active, this simulate | |
| 2629 // the call sent by hotrod initialization process. | |
| 2630 test_observer_->reset_active_output_node_changed_count(); | |
| 2631 test_observer_->reset_active_input_node_changed_count(); | |
| 2632 | |
| 2633 cras_audio_handler_->SetActiveInputNodes( | |
| 2634 {kUSBJabraSpeakerInput1->id, kUSBJabraSpeakerInput2->id}); | |
| 2635 | |
| 2636 cras_audio_handler_->SetActiveOutputNodes( | |
| 2637 {kUSBJabraSpeakerOutput1->id, kUSBJabraSpeakerOutput2->id}); | |
| 2638 | |
| 2639 // Verify both jabra speakers' input/output nodes are made active. | |
| 2640 // num_active_nodes = GetActiveDeviceCount(); | |
| 2641 EXPECT_EQ(4, GetActiveDeviceCount()); | |
| 2642 const AudioDevice* active_output_1 = | |
| 2643 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | |
| 2644 EXPECT_TRUE(active_output_1->active); | |
| 2645 const AudioDevice* active_output_2 = | |
| 2646 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | |
| 2647 EXPECT_TRUE(active_output_2->active); | |
| 2648 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice( | |
| 2649 &primary_active_device)); | |
| 2650 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, primary_active_device.id); | |
| 2651 const AudioDevice* active_input_1 = | |
| 2652 GetDeviceFromId(kUSBJabraSpeakerInput1->id); | |
| 2653 EXPECT_TRUE(active_input_1->active); | |
| 2654 const AudioDevice* active_input_2 = | |
| 2655 GetDeviceFromId(kUSBJabraSpeakerInput2->id); | |
| 2656 EXPECT_TRUE(active_input_2->active); | |
| 2657 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 2658 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 2659 | |
| 2660 // Verify only 1 ActiveOutputNodeChanged notification has been sent out | |
| 2661 // by calling SetActiveNodes. | |
| 2662 EXPECT_EQ(1, test_observer_->active_output_node_changed_count()); | |
| 2663 EXPECT_EQ(1, test_observer_->active_input_node_changed_count()); | |
| 2664 | |
| 2665 // Verify all active devices are the not muted and their volume values are | |
| 2666 // the same. | |
| 2667 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); | |
| 2668 EXPECT_FALSE( | |
| 2669 cras_audio_handler_->IsOutputMutedForDevice(kUSBJabraSpeakerOutput1->id)); | |
| 2670 EXPECT_FALSE( | |
| 2671 cras_audio_handler_->IsOutputMutedForDevice(kUSBJabraSpeakerOutput2->id)); | |
| 2672 EXPECT_EQ(cras_audio_handler_->GetOutputVolumePercent(), | |
| 2673 cras_audio_handler_->GetOutputVolumePercentForDevice( | |
| 2674 kUSBJabraSpeakerOutput1->id)); | |
| 2675 EXPECT_EQ(cras_audio_handler_->GetOutputVolumePercent(), | |
| 2676 cras_audio_handler_->GetOutputVolumePercentForDevice( | |
| 2677 kUSBJabraSpeakerOutput2->id)); | |
| 2678 | |
| 2679 // Adjust the volume of output devices, verify all active nodes are set to | |
| 2680 // the same volume. | |
| 2681 cras_audio_handler_->SetOutputVolumePercent(25); | |
| 2682 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercent()); | |
| 2683 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercentForDevice( | |
| 2684 kUSBJabraSpeakerOutput1->id)); | |
| 2685 EXPECT_EQ(25, cras_audio_handler_->GetOutputVolumePercentForDevice( | |
| 2686 kUSBJabraSpeakerOutput2->id)); | |
| 2687 } | |
| 2688 | |
| 2607 TEST_P(CrasAudioHandlerTest, ChangeVolumeHotrodDualSpeakersWithDelayedSignals) { | 2689 TEST_P(CrasAudioHandlerTest, ChangeVolumeHotrodDualSpeakersWithDelayedSignals) { |
| 2608 AudioNodeList audio_nodes = GenerateAudioNodeList( | 2690 AudioNodeList audio_nodes = GenerateAudioNodeList( |
| 2609 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerOutput2}); | 2691 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerOutput2}); |
| 2610 SetUpCrasAudioHandler(audio_nodes); | 2692 SetUpCrasAudioHandler(audio_nodes); |
| 2611 | 2693 |
| 2612 // Verify the audio devices size. | 2694 // Verify the audio devices size. |
| 2613 AudioDeviceList audio_devices; | 2695 AudioDeviceList audio_devices; |
| 2614 cras_audio_handler_->GetAudioDevices(&audio_devices); | 2696 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 2615 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | 2697 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); |
| 2616 | 2698 |
| 2617 // Set both jabra speakers nodes to active, this simulate | 2699 // Set both jabra speakers nodes to active, this simulate |
| 2618 // the call sent by hotrod initialization process. | 2700 // the call sent by hotrod initialization process. |
| 2619 test_observer_->reset_active_output_node_changed_count(); | 2701 test_observer_->reset_active_output_node_changed_count(); |
| 2620 CrasAudioHandler::NodeIdList active_nodes; | 2702 cras_audio_handler_->ChangeActiveNodes( |
| 2621 active_nodes.push_back(kUSBJabraSpeakerOutput1->id); | 2703 {kUSBJabraSpeakerOutput1->id, kUSBJabraSpeakerOutput2->id}); |
| 2622 active_nodes.push_back(kUSBJabraSpeakerOutput2->id); | |
| 2623 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2624 | 2704 |
| 2625 // Verify both jabra speakers are made active. | 2705 // Verify both jabra speakers are made active. |
| 2626 EXPECT_EQ(2, GetActiveDeviceCount()); | 2706 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2627 const AudioDevice* active_output_1 = | 2707 const AudioDevice* active_output_1 = |
| 2628 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | 2708 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); |
| 2629 EXPECT_TRUE(active_output_1->active); | 2709 EXPECT_TRUE(active_output_1->active); |
| 2630 const AudioDevice* active_output_2 = | 2710 const AudioDevice* active_output_2 = |
| 2631 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | 2711 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); |
| 2632 EXPECT_TRUE(active_output_2->active); | 2712 EXPECT_TRUE(active_output_2->active); |
| 2633 | 2713 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2695 EXPECT_EQ(2, GetActiveDeviceCount()); | 2775 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2696 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | 2776 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, |
| 2697 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 2777 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2698 EXPECT_EQ(kUSBCameraInput->id, | 2778 EXPECT_EQ(kUSBCameraInput->id, |
| 2699 cras_audio_handler_->GetPrimaryActiveInputNode()); | 2779 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2700 | 2780 |
| 2701 // Set both jabra speakers's input and output nodes to active, this simulates | 2781 // Set both jabra speakers's input and output nodes to active, this simulates |
| 2702 // the call sent by hotrod initialization process. | 2782 // the call sent by hotrod initialization process. |
| 2703 test_observer_->reset_active_output_node_changed_count(); | 2783 test_observer_->reset_active_output_node_changed_count(); |
| 2704 test_observer_->reset_active_input_node_changed_count(); | 2784 test_observer_->reset_active_input_node_changed_count(); |
| 2705 CrasAudioHandler::NodeIdList active_nodes; | 2785 cras_audio_handler_->ChangeActiveNodes( |
| 2706 active_nodes.push_back(kUSBJabraSpeakerOutput1->id); | 2786 {kUSBJabraSpeakerOutput1->id, kUSBJabraSpeakerOutput2->id, |
| 2707 active_nodes.push_back(kUSBJabraSpeakerOutput2->id); | 2787 kUSBJabraSpeakerInput1->id, kUSBJabraSpeakerInput2->id}); |
| 2708 active_nodes.push_back(kUSBJabraSpeakerInput1->id); | |
| 2709 active_nodes.push_back(kUSBJabraSpeakerInput2->id); | |
| 2710 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2711 | 2788 |
| 2712 // Verify both jabra speakers' input/output nodes are made active. | 2789 // Verify both jabra speakers' input/output nodes are made active. |
| 2713 // num_active_nodes = GetActiveDeviceCount(); | 2790 // num_active_nodes = GetActiveDeviceCount(); |
| 2791 EXPECT_EQ(4, GetActiveDeviceCount()); | |
| 2792 const AudioDevice* active_output_1 = | |
| 2793 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | |
| 2794 EXPECT_TRUE(active_output_1->active); | |
| 2795 const AudioDevice* active_output_2 = | |
| 2796 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | |
| 2797 EXPECT_TRUE(active_output_2->active); | |
| 2798 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 2799 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 2800 const AudioDevice* active_input_1 = | |
| 2801 GetDeviceFromId(kUSBJabraSpeakerInput1->id); | |
| 2802 EXPECT_TRUE(active_input_1->active); | |
| 2803 const AudioDevice* active_input_2 = | |
| 2804 GetDeviceFromId(kUSBJabraSpeakerInput2->id); | |
| 2805 EXPECT_TRUE(active_input_2->active); | |
| 2806 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 2807 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 2808 | |
| 2809 // Verify only 1 ActiveOutputNodeChanged notification has been sent out | |
| 2810 // by calling ChangeActiveNodes. | |
| 2811 EXPECT_EQ(1, test_observer_->active_output_node_changed_count()); | |
| 2812 EXPECT_EQ(1, test_observer_->active_input_node_changed_count()); | |
| 2813 } | |
| 2814 | |
| 2815 TEST_P(CrasAudioHandlerTest, SetActiveNodesHotrodInitWithCameraInputActive) { | |
| 2816 AudioNodeList audio_nodes = GenerateAudioNodeList( | |
| 2817 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerOutput2, | |
| 2818 kUSBJabraSpeakerInput1, kUSBJabraSpeakerInput2}); | |
| 2819 // Make the camera input to be plugged in later than jabra's input. | |
| 2820 AudioNode usb_camera = GenerateAudioNode(kUSBCameraInput); | |
| 2821 usb_camera.plugged_time = 10000000; | |
| 2822 audio_nodes.push_back(usb_camera); | |
| 2823 SetUpCrasAudioHandler(audio_nodes); | |
| 2824 | |
| 2825 // Verify the audio devices size. | |
| 2826 AudioDeviceList audio_devices; | |
| 2827 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 2828 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 2829 | |
| 2830 // Verify the 1st jabra speaker's output is selected as active output | |
| 2831 // node and camera's input is selected active input by CrasAudioHandler. | |
| 2832 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 2833 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 2834 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 2835 EXPECT_EQ(kUSBCameraInput->id, | |
| 2836 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 2837 | |
| 2838 // Set both jabra speakers's input and output nodes to active, this simulates | |
| 2839 // the call sent by hotrod initialization process. | |
| 2840 test_observer_->reset_active_output_node_changed_count(); | |
| 2841 test_observer_->reset_active_input_node_changed_count(); | |
| 2842 | |
| 2843 cras_audio_handler_->SetActiveOutputNodes( | |
| 2844 {kUSBJabraSpeakerOutput1->id, kUSBJabraSpeakerOutput2->id}); | |
| 2845 | |
| 2846 cras_audio_handler_->SetActiveInputNodes( | |
| 2847 {kUSBJabraSpeakerInput1->id, kUSBJabraSpeakerInput2->id}); | |
| 2848 | |
| 2849 // Verify both jabra speakers' input/output nodes are made active. | |
| 2850 // num_active_nodes = GetActiveDeviceCount(); | |
| 2714 EXPECT_EQ(4, GetActiveDeviceCount()); | 2851 EXPECT_EQ(4, GetActiveDeviceCount()); |
| 2715 const AudioDevice* active_output_1 = | 2852 const AudioDevice* active_output_1 = |
| 2716 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | 2853 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); |
| 2717 EXPECT_TRUE(active_output_1->active); | 2854 EXPECT_TRUE(active_output_1->active); |
| 2718 const AudioDevice* active_output_2 = | 2855 const AudioDevice* active_output_2 = |
| 2719 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | 2856 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); |
| 2720 EXPECT_TRUE(active_output_2->active); | 2857 EXPECT_TRUE(active_output_2->active); |
| 2721 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | 2858 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, |
| 2722 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 2859 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2723 const AudioDevice* active_input_1 = | 2860 const AudioDevice* active_input_1 = |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2739 AudioNodeList audio_nodes = GenerateAudioNodeList( | 2876 AudioNodeList audio_nodes = GenerateAudioNodeList( |
| 2740 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerOutput2}); | 2877 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerOutput2}); |
| 2741 SetUpCrasAudioHandler(audio_nodes); | 2878 SetUpCrasAudioHandler(audio_nodes); |
| 2742 | 2879 |
| 2743 // Verify the audio devices size. | 2880 // Verify the audio devices size. |
| 2744 AudioDeviceList audio_devices; | 2881 AudioDeviceList audio_devices; |
| 2745 cras_audio_handler_->GetAudioDevices(&audio_devices); | 2882 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 2746 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | 2883 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); |
| 2747 | 2884 |
| 2748 // Set all three nodes to be active. | 2885 // Set all three nodes to be active. |
| 2749 CrasAudioHandler::NodeIdList active_nodes; | 2886 cras_audio_handler_->ChangeActiveNodes({kHDMIOutput->id, |
| 2750 active_nodes.push_back(kHDMIOutput->id); | 2887 kUSBJabraSpeakerOutput1->id, |
| 2751 active_nodes.push_back(kUSBJabraSpeakerOutput1->id); | 2888 kUSBJabraSpeakerOutput2->id}); |
| 2752 active_nodes.push_back(kUSBJabraSpeakerOutput2->id); | |
| 2753 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2754 | 2889 |
| 2755 // Verify all three nodes are active. | 2890 // Verify all three nodes are active. |
| 2756 EXPECT_EQ(3, GetActiveDeviceCount()); | 2891 EXPECT_EQ(3, GetActiveDeviceCount()); |
| 2757 const AudioDevice* active_output_1 = GetDeviceFromId(kHDMIOutput->id); | 2892 const AudioDevice* active_output_1 = GetDeviceFromId(kHDMIOutput->id); |
| 2758 EXPECT_TRUE(active_output_1->active); | 2893 EXPECT_TRUE(active_output_1->active); |
| 2759 const AudioDevice* active_output_2 = | 2894 const AudioDevice* active_output_2 = |
| 2760 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | 2895 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); |
| 2761 EXPECT_TRUE(active_output_2->active); | 2896 EXPECT_TRUE(active_output_2->active); |
| 2762 const AudioDevice* active_output_3 = | 2897 const AudioDevice* active_output_3 = |
| 2763 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | 2898 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); |
| 2764 EXPECT_TRUE(active_output_3->active); | 2899 EXPECT_TRUE(active_output_3->active); |
| 2765 | 2900 |
| 2766 // Now call ChangeActiveDevices with only 2 nodes. | 2901 // Now call ChangeActiveDevices with only 2 nodes. |
| 2767 active_nodes.clear(); | 2902 cras_audio_handler_->ChangeActiveNodes( |
| 2768 active_nodes.push_back(kUSBJabraSpeakerOutput1->id); | 2903 {kUSBJabraSpeakerOutput1->id, kUSBJabraSpeakerOutput2->id}); |
| 2769 active_nodes.push_back(kUSBJabraSpeakerOutput2->id); | |
| 2770 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2771 | 2904 |
| 2772 // Verify only 2 nodes are active. | 2905 // Verify only 2 nodes are active. |
| 2773 EXPECT_EQ(2, GetActiveDeviceCount()); | 2906 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2907 const AudioDevice* output_1 = GetDeviceFromId(kHDMIOutput->id); | |
| 2908 EXPECT_FALSE(output_1->active); | |
| 2909 const AudioDevice* output_2 = GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | |
| 2910 EXPECT_TRUE(output_2->active); | |
| 2911 const AudioDevice* output_3 = GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | |
| 2912 EXPECT_TRUE(output_3->active); | |
| 2913 } | |
| 2914 | |
| 2915 TEST_P(CrasAudioHandlerTest, SetActiveNodesWithFewerActives) { | |
| 2916 AudioNodeList audio_nodes = GenerateAudioNodeList( | |
| 2917 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerOutput2}); | |
| 2918 SetUpCrasAudioHandler(audio_nodes); | |
| 2919 | |
| 2920 // Verify the audio devices size. | |
| 2921 AudioDeviceList audio_devices; | |
| 2922 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 2923 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 2924 | |
| 2925 // Set all three nodes to be active. | |
| 2926 cras_audio_handler_->SetActiveOutputNodes({kHDMIOutput->id, | |
| 2927 kUSBJabraSpeakerOutput1->id, | |
| 2928 kUSBJabraSpeakerOutput2->id}); | |
| 2929 | |
| 2930 // Verify all three nodes are active. | |
| 2931 EXPECT_EQ(3, GetActiveDeviceCount()); | |
| 2932 const AudioDevice* active_output_1 = GetDeviceFromId(kHDMIOutput->id); | |
| 2933 EXPECT_TRUE(active_output_1->active); | |
| 2934 const AudioDevice* active_output_2 = | |
| 2935 GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | |
| 2936 EXPECT_TRUE(active_output_2->active); | |
| 2937 const AudioDevice* active_output_3 = | |
| 2938 GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | |
| 2939 EXPECT_TRUE(active_output_3->active); | |
| 2940 | |
| 2941 // Now call SetActiveOutputNodes with only 2 nodes. | |
| 2942 cras_audio_handler_->SetActiveOutputNodes( | |
| 2943 {kUSBJabraSpeakerOutput1->id, kUSBJabraSpeakerOutput2->id}); | |
| 2944 | |
| 2945 // Verify only 2 nodes are active. | |
| 2946 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 2774 const AudioDevice* output_1 = GetDeviceFromId(kHDMIOutput->id); | 2947 const AudioDevice* output_1 = GetDeviceFromId(kHDMIOutput->id); |
| 2775 EXPECT_FALSE(output_1->active); | 2948 EXPECT_FALSE(output_1->active); |
| 2776 const AudioDevice* output_2 = GetDeviceFromId(kUSBJabraSpeakerOutput1->id); | 2949 const AudioDevice* output_2 = GetDeviceFromId(kUSBJabraSpeakerOutput1->id); |
| 2777 EXPECT_TRUE(output_2->active); | 2950 EXPECT_TRUE(output_2->active); |
| 2778 const AudioDevice* output_3 = GetDeviceFromId(kUSBJabraSpeakerOutput2->id); | 2951 const AudioDevice* output_3 = GetDeviceFromId(kUSBJabraSpeakerOutput2->id); |
| 2779 EXPECT_TRUE(output_3->active); | 2952 EXPECT_TRUE(output_3->active); |
| 2780 } | 2953 } |
| 2781 | 2954 |
| 2782 TEST_P(CrasAudioHandlerTest, HotrodInitWithSingleJabra) { | 2955 TEST_P(CrasAudioHandlerTest, HotrodInitWithSingleJabra) { |
| 2783 // Simulates the hotrod initializated with a single jabra device and | 2956 // Simulates the hotrod initializated with a single jabra device and |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2820 EXPECT_EQ(2, GetActiveDeviceCount()); | 2993 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2821 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | 2994 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, |
| 2822 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 2995 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2823 EXPECT_EQ(kUSBCameraInput->id, | 2996 EXPECT_EQ(kUSBCameraInput->id, |
| 2824 cras_audio_handler_->GetPrimaryActiveInputNode()); | 2997 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2825 | 2998 |
| 2826 // Simulate hotrod app call to set jabra input as active device with only | 2999 // Simulate hotrod app call to set jabra input as active device with only |
| 2827 // jabra input node in the active node list, which does not conform to the | 3000 // jabra input node in the active node list, which does not conform to the |
| 2828 // new SetActiveDevices protocol, but just show we can still handle it if | 3001 // new SetActiveDevices protocol, but just show we can still handle it if |
| 2829 // this happens. | 3002 // this happens. |
| 2830 CrasAudioHandler::NodeIdList active_nodes; | 3003 cras_audio_handler_->ChangeActiveNodes( |
| 2831 active_nodes.push_back(kUSBJabraSpeakerOutput1->id); | 3004 {kUSBJabraSpeakerOutput1->id, kUSBJabraSpeakerInput1->id}); |
| 2832 active_nodes.push_back(kUSBJabraSpeakerInput1->id); | |
| 2833 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2834 | 3005 |
| 2835 // Verify the jabra speaker's output is selected as active output, and | 3006 // Verify the jabra speaker's output is selected as active output, and |
| 2836 // jabra's input is selected as active input. | 3007 // jabra's input is selected as active input. |
| 3008 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3009 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3010 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3011 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3012 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3013 } | |
| 3014 | |
| 3015 TEST_P(CrasAudioHandlerTest, | |
| 3016 SetActiveNodesHotrodInitWithSingleJabraCameraPlugInLater) { | |
| 3017 AudioNodeList audio_nodes = GenerateAudioNodeList( | |
| 3018 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerInput1}); | |
| 3019 AudioNode usb_camera = GenerateAudioNode(kUSBCameraInput); | |
| 3020 usb_camera.plugged_time = 10000000; | |
| 3021 audio_nodes.push_back(usb_camera); | |
| 3022 SetUpCrasAudioHandler(audio_nodes); | |
| 3023 | |
| 3024 // Verify the audio devices size. | |
| 3025 AudioDeviceList audio_devices; | |
| 3026 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 3027 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 3028 | |
| 3029 // Verify the jabra speaker's output is selected as active output, and | |
| 3030 // camera's input is selected as active input by CrasAudioHandler | |
| 3031 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3032 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3033 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3034 EXPECT_EQ(kUSBCameraInput->id, | |
| 3035 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3036 | |
| 3037 // Simulate hotrod app call to set jabra input as active device with only | |
| 3038 // jabra input node in the active node list, which does not conform to the | |
| 3039 // new SetActiveDevices protocol, but just show we can still handle it if | |
| 3040 // this happens. | |
| 3041 cras_audio_handler_->SetActiveOutputNodes({kUSBJabraSpeakerOutput1->id}); | |
| 3042 | |
| 3043 cras_audio_handler_->SetActiveInputNodes({kUSBJabraSpeakerInput1->id}); | |
| 3044 | |
| 3045 // Verify the jabra speaker's output is selected as active output, and | |
| 3046 // jabra's input is selected as active input. | |
| 2837 EXPECT_EQ(2, GetActiveDeviceCount()); | 3047 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2838 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | 3048 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, |
| 2839 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3049 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2840 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | 3050 EXPECT_EQ(kUSBJabraSpeakerInput1->id, |
| 2841 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3051 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2842 } | 3052 } |
| 2843 | 3053 |
| 2844 TEST_P(CrasAudioHandlerTest, ChangeActiveNodesDeactivatePrimaryActiveNode) { | 3054 TEST_P(CrasAudioHandlerTest, ChangeActiveNodesDeactivatePrimaryActiveNode) { |
| 2845 AudioNodeList audio_nodes = | 3055 AudioNodeList audio_nodes = |
| 2846 GenerateAudioNodeList({kUSBJabraSpeakerInput1, kUSBJabraSpeakerInput2}); | 3056 GenerateAudioNodeList({kUSBJabraSpeakerInput1, kUSBJabraSpeakerInput2}); |
| 2847 AudioNode usb_camera = GenerateAudioNode(kUSBCameraInput); | 3057 AudioNode usb_camera = GenerateAudioNode(kUSBCameraInput); |
| 2848 usb_camera.plugged_time = 10000000; | 3058 usb_camera.plugged_time = 10000000; |
| 2849 audio_nodes.push_back(usb_camera); | 3059 audio_nodes.push_back(usb_camera); |
| 2850 SetUpCrasAudioHandler(audio_nodes); | 3060 SetUpCrasAudioHandler(audio_nodes); |
| 2851 | 3061 |
| 2852 // Verify the audio devices size. | 3062 // Verify the audio devices size. |
| 2853 AudioDeviceList audio_devices; | 3063 AudioDeviceList audio_devices; |
| 2854 cras_audio_handler_->GetAudioDevices(&audio_devices); | 3064 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 2855 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | 3065 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); |
| 2856 | 3066 |
| 2857 // Verify the camera's input is selected as active input by CrasAudioHandler | 3067 // Verify the camera's input is selected as active input by CrasAudioHandler |
| 2858 EXPECT_EQ(1, GetActiveDeviceCount()); | 3068 EXPECT_EQ(1, GetActiveDeviceCount()); |
| 2859 EXPECT_EQ(kUSBCameraInput->id, | 3069 EXPECT_EQ(kUSBCameraInput->id, |
| 2860 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3070 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2861 | 3071 |
| 2862 // Simulate hotrod app call to set jabra input as active device with only | 3072 // Simulate hotrod app call to set jabra input as active device with only |
| 2863 // jabra input node in the active node list, which does not conform to the | 3073 // jabra input node in the active node list, which does not conform to the |
| 2864 // new SetActiveDevices protocol, but just show we can still handle it if | 3074 // new SetActiveDevices protocol, but just show we can still handle it if |
| 2865 // this happens. | 3075 // this happens. |
| 2866 { | 3076 cras_audio_handler_->ChangeActiveNodes( |
| 2867 CrasAudioHandler::NodeIdList active_nodes; | 3077 {kUSBJabraSpeakerInput1->id, kUSBCameraInput->id}); |
| 2868 active_nodes.push_back(kUSBJabraSpeakerInput1->id); | |
| 2869 active_nodes.push_back(kUSBCameraInput->id); | |
| 2870 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2871 } | |
| 2872 | 3078 |
| 2873 // Verify the jabra speaker's output is selected as active output, and | 3079 // Verify the jabra speaker's output is selected as active output, and |
| 2874 // jabra's input is selected as active input. | 3080 // jabra's input is selected as active input. |
| 2875 EXPECT_EQ(2, GetActiveDeviceCount()); | 3081 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2876 EXPECT_EQ(kUSBCameraInput->id, | 3082 EXPECT_EQ(kUSBCameraInput->id, |
| 2877 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3083 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2878 | 3084 |
| 2879 const AudioDevice* additional_speaker = | 3085 const AudioDevice* additional_speaker = |
| 2880 cras_audio_handler_->GetDeviceFromId(kUSBJabraSpeakerInput1->id); | 3086 cras_audio_handler_->GetDeviceFromId(kUSBJabraSpeakerInput1->id); |
| 2881 ASSERT_TRUE(additional_speaker); | 3087 ASSERT_TRUE(additional_speaker); |
| 2882 EXPECT_TRUE(additional_speaker->active); | 3088 EXPECT_TRUE(additional_speaker->active); |
| 2883 | 3089 |
| 2884 { | 3090 cras_audio_handler_->ChangeActiveNodes( |
| 2885 CrasAudioHandler::NodeIdList active_nodes; | 3091 {kUSBJabraSpeakerInput1->id, kUSBJabraSpeakerInput2->id}); |
| 2886 active_nodes.push_back(kUSBJabraSpeakerInput1->id); | |
| 2887 active_nodes.push_back(kUSBJabraSpeakerInput2->id); | |
| 2888 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2889 } | |
| 2890 | 3092 |
| 2891 EXPECT_EQ(2, GetActiveDeviceCount()); | 3093 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2892 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | 3094 EXPECT_EQ(kUSBJabraSpeakerInput1->id, |
| 3095 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3096 | |
| 3097 additional_speaker = | |
| 3098 cras_audio_handler_->GetDeviceFromId(kUSBJabraSpeakerInput2->id); | |
| 3099 ASSERT_TRUE(additional_speaker); | |
| 3100 EXPECT_TRUE(additional_speaker->active); | |
| 3101 } | |
| 3102 | |
| 3103 TEST_P(CrasAudioHandlerTest, SetActiveNodesDeactivatePrimaryActiveNode) { | |
| 3104 AudioNodeList audio_nodes = | |
| 3105 GenerateAudioNodeList({kUSBJabraSpeakerInput1, kUSBJabraSpeakerInput2}); | |
| 3106 AudioNode usb_camera = GenerateAudioNode(kUSBCameraInput); | |
| 3107 usb_camera.plugged_time = 10000000; | |
| 3108 audio_nodes.push_back(usb_camera); | |
| 3109 SetUpCrasAudioHandler(audio_nodes); | |
| 3110 | |
| 3111 // Verify the audio devices size. | |
| 3112 AudioDeviceList audio_devices; | |
| 3113 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 3114 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 3115 | |
| 3116 // Verify the camera's input is selected as active input by CrasAudioHandler | |
| 3117 EXPECT_EQ(1, GetActiveDeviceCount()); | |
| 3118 EXPECT_EQ(kUSBCameraInput->id, | |
| 3119 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3120 | |
| 3121 // Simulate hotrod app call to set jabra input as active device with only | |
| 3122 // jabra input node in the active node list, which does not conform to the | |
| 3123 // new SetActiveDevices protocol, but just show we can still handle it if | |
| 3124 // this happens. | |
|
jennyz
2017/01/07 00:33:00
The comment says only jabra input node in active n
tbarzic
2017/01/07 05:16:31
Oh, sorry, I blindly copied comment from kine 2862
| |
| 3125 cras_audio_handler_->SetActiveInputNodes( | |
| 3126 {kUSBJabraSpeakerInput1->id, kUSBCameraInput->id}); | |
| 3127 | |
| 3128 // Verify the jabra speaker's output is selected as active output, and | |
| 3129 // jabra's input is selected as active input. | |
|
jennyz
2017/01/07 00:33:00
why is jabra speaker's output relevant here? The c
tbarzic
2017/01/07 05:16:31
ditto
| |
| 3130 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3131 EXPECT_EQ(kUSBCameraInput->id, | |
| 3132 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3133 | |
| 3134 const AudioDevice* additional_speaker = | |
| 3135 cras_audio_handler_->GetDeviceFromId(kUSBJabraSpeakerInput1->id); | |
| 3136 ASSERT_TRUE(additional_speaker); | |
| 3137 EXPECT_TRUE(additional_speaker->active); | |
| 3138 | |
| 3139 cras_audio_handler_->SetActiveInputNodes( | |
| 3140 {kUSBJabraSpeakerInput1->id, kUSBJabraSpeakerInput2->id}); | |
| 3141 | |
| 3142 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3143 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 2893 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3144 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2894 | 3145 |
| 2895 additional_speaker = | 3146 additional_speaker = |
| 2896 cras_audio_handler_->GetDeviceFromId(kUSBJabraSpeakerInput2->id); | 3147 cras_audio_handler_->GetDeviceFromId(kUSBJabraSpeakerInput2->id); |
| 2897 ASSERT_TRUE(additional_speaker); | 3148 ASSERT_TRUE(additional_speaker); |
| 2898 EXPECT_TRUE(additional_speaker->active); | 3149 EXPECT_TRUE(additional_speaker->active); |
| 2899 } | 3150 } |
| 2900 | 3151 |
| 2901 TEST_P(CrasAudioHandlerTest, | 3152 TEST_P(CrasAudioHandlerTest, |
| 2902 ChangeActiveNodesHotrodInitWithSingleJabraCameraPlugInLaterOldCall) { | 3153 ChangeActiveNodesHotrodInitWithSingleJabraCameraPlugInLaterOldCall) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2917 EXPECT_EQ(2, GetActiveDeviceCount()); | 3168 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2918 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | 3169 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, |
| 2919 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3170 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2920 EXPECT_EQ(kUSBCameraInput->id, | 3171 EXPECT_EQ(kUSBCameraInput->id, |
| 2921 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3172 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2922 | 3173 |
| 2923 // Simulate hotrod app call to set jabra input as active device with only | 3174 // Simulate hotrod app call to set jabra input as active device with only |
| 2924 // jabra input node in the active node list, which does not conform to the | 3175 // jabra input node in the active node list, which does not conform to the |
| 2925 // new SetActiveDevices protocol, but just show we can still handle it if | 3176 // new SetActiveDevices protocol, but just show we can still handle it if |
| 2926 // this happens. | 3177 // this happens. |
| 2927 CrasAudioHandler::NodeIdList active_nodes; | 3178 cras_audio_handler_->ChangeActiveNodes({kUSBJabraSpeakerInput1->id}); |
| 2928 active_nodes.push_back(kUSBJabraSpeakerInput1->id); | |
| 2929 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2930 | 3179 |
| 2931 // Verify the jabra speaker's output is selected as active output, and | 3180 // Verify the jabra speaker's output is selected as active output, and |
| 2932 // jabra's input is selected as active input. | 3181 // jabra's input is selected as active input. |
| 3182 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3183 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3184 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3185 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3186 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3187 } | |
| 3188 | |
| 3189 TEST_P(CrasAudioHandlerTest, | |
| 3190 SetActiveNodesHotrodInitWithSingleJabraCameraPlugInLaterOldCall) { | |
| 3191 AudioNodeList audio_nodes = GenerateAudioNodeList( | |
| 3192 {kHDMIOutput, kUSBJabraSpeakerOutput1, kUSBJabraSpeakerInput1}); | |
| 3193 AudioNode usb_camera = GenerateAudioNode(kUSBCameraInput); | |
| 3194 usb_camera.plugged_time = 10000000; | |
| 3195 audio_nodes.push_back(usb_camera); | |
| 3196 SetUpCrasAudioHandler(audio_nodes); | |
| 3197 | |
| 3198 // Verify the audio devices size. | |
| 3199 AudioDeviceList audio_devices; | |
| 3200 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 3201 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 3202 | |
| 3203 // Verify the jabra speaker's output is selected as active output, and | |
| 3204 // camera's input is selected as active input by CrasAudioHandler | |
| 3205 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3206 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3207 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3208 EXPECT_EQ(kUSBCameraInput->id, | |
| 3209 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3210 | |
| 3211 // Simulate hotrod app call to set jabra input as active device with only | |
| 3212 // jabra input node in the active node list, which does not conform to the | |
| 3213 // new SetActiveDevices protocol, but just show we can still handle it if | |
| 3214 // this happens. | |
| 3215 cras_audio_handler_->SetActiveInputNodes({kUSBJabraSpeakerInput1->id}); | |
| 3216 | |
| 3217 // Verify the jabra speaker's output is selected as active output, and | |
| 3218 // jabra's input is selected as active input. | |
| 2933 EXPECT_EQ(2, GetActiveDeviceCount()); | 3219 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2934 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | 3220 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, |
| 2935 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3221 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2936 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | 3222 EXPECT_EQ(kUSBJabraSpeakerInput1->id, |
| 2937 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3223 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2938 } | 3224 } |
| 2939 | 3225 |
| 2940 TEST_P(CrasAudioHandlerTest, | 3226 TEST_P(CrasAudioHandlerTest, |
| 2941 ChangeActiveNodesHotrodInitWithSingleJabraChangeOutput) { | 3227 ChangeActiveNodesHotrodInitWithSingleJabraChangeOutput) { |
| 2942 AudioNodeList audio_nodes = | 3228 AudioNodeList audio_nodes = |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2953 // by CrasAudioHandler. | 3239 // by CrasAudioHandler. |
| 2954 EXPECT_EQ(2, GetActiveDeviceCount()); | 3240 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2955 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | 3241 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, |
| 2956 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3242 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2957 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | 3243 EXPECT_EQ(kUSBJabraSpeakerInput1->id, |
| 2958 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3244 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2959 | 3245 |
| 2960 // Simulate hotrod app call SetActiveDevices to change active output | 3246 // Simulate hotrod app call SetActiveDevices to change active output |
| 2961 // with only complete list of active nodes passed in, which is the new | 3247 // with only complete list of active nodes passed in, which is the new |
| 2962 // way of hotrod app. | 3248 // way of hotrod app. |
| 2963 CrasAudioHandler::NodeIdList active_nodes; | 3249 cras_audio_handler_->ChangeActiveNodes( |
| 2964 active_nodes.push_back(kHDMIOutput->id); | 3250 {kHDMIOutput->id, kUSBJabraSpeakerInput1->id}); |
| 2965 active_nodes.push_back(kUSBJabraSpeakerInput1->id); | |
| 2966 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 2967 | 3251 |
| 2968 // Verify the jabra speaker's output is selected as active output, and | 3252 // Verify the jabra speaker's output is selected as active output, and |
| 2969 // jabra's input is selected as active input. | 3253 // jabra's input is selected as active input. |
| 3254 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3255 EXPECT_EQ(kHDMIOutput->id, cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3256 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3257 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3258 } | |
| 3259 | |
| 3260 TEST_P(CrasAudioHandlerTest, | |
| 3261 SetActiveNodesHotrodInitWithSingleJabraChangeOutput) { | |
| 3262 AudioNodeList audio_nodes = | |
| 3263 GenerateAudioNodeList({kHDMIOutput, kUSBJabraSpeakerOutput1, | |
| 3264 kUSBJabraSpeakerInput1, kUSBCameraInput}); | |
| 3265 SetUpCrasAudioHandler(audio_nodes); | |
| 3266 | |
| 3267 // Verify the audio devices size. | |
| 3268 AudioDeviceList audio_devices; | |
| 3269 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 3270 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 3271 | |
| 3272 // Verify the jabra speaker's output and input are selected as active output | |
| 3273 // by CrasAudioHandler. | |
| 3274 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3275 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3276 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3277 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3278 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3279 | |
| 3280 // Simulate hotrod app call SetActiveDevices to change active output | |
| 3281 // with only complete list of active nodes passed in, which is the new | |
| 3282 // way of hotrod app. | |
|
jennyz
2017/01/07 00:33:00
The comment needs to be updated to be consistent w
tbarzic
2017/01/07 05:16:31
this is supposed to be the same test case as 2963
| |
| 3283 cras_audio_handler_->SetActiveOutputNodes({kHDMIOutput->id}); | |
| 3284 cras_audio_handler_->SetActiveInputNodes({kUSBJabraSpeakerInput1->id}); | |
| 3285 | |
| 3286 // Verify the jabra speaker's output is selected as active output, and | |
| 3287 // jabra's input is selected as active input. | |
| 2970 EXPECT_EQ(2, GetActiveDeviceCount()); | 3288 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2971 EXPECT_EQ(kHDMIOutput->id, cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3289 EXPECT_EQ(kHDMIOutput->id, cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2972 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | 3290 EXPECT_EQ(kUSBJabraSpeakerInput1->id, |
| 2973 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3291 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2974 } | 3292 } |
| 2975 | 3293 |
| 2976 TEST_P(CrasAudioHandlerTest, | 3294 TEST_P(CrasAudioHandlerTest, |
| 2977 ChangeActiveNodesHotrodInitWithSingleJabraChangeOutputOldCall) { | 3295 ChangeActiveNodesHotrodInitWithSingleJabraChangeOutputOldCall) { |
| 2978 AudioNodeList audio_nodes = | 3296 AudioNodeList audio_nodes = |
| 2979 GenerateAudioNodeList({kHDMIOutput, kUSBJabraSpeakerOutput1, | 3297 GenerateAudioNodeList({kHDMIOutput, kUSBJabraSpeakerOutput1, |
| 2980 kUSBJabraSpeakerInput1, kUSBCameraInput}); | 3298 kUSBJabraSpeakerInput1, kUSBCameraInput}); |
| 2981 SetUpCrasAudioHandler(audio_nodes); | 3299 SetUpCrasAudioHandler(audio_nodes); |
| 2982 | 3300 |
| 2983 // Verify the audio devices size. | 3301 // Verify the audio devices size. |
| 2984 AudioDeviceList audio_devices; | 3302 AudioDeviceList audio_devices; |
| 2985 cras_audio_handler_->GetAudioDevices(&audio_devices); | 3303 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 2986 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | 3304 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); |
| 2987 | 3305 |
| 2988 // Verify the jabra speaker's output and input are selected as active output | 3306 // Verify the jabra speaker's output and input are selected as active output |
| 2989 // by CrasAudioHandler. | 3307 // by CrasAudioHandler. |
| 2990 EXPECT_EQ(2, GetActiveDeviceCount()); | 3308 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 2991 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | 3309 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, |
| 2992 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3310 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2993 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | 3311 EXPECT_EQ(kUSBJabraSpeakerInput1->id, |
| 2994 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3312 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 2995 | 3313 |
| 2996 // Simulate hotrod app call SetActiveDevices to change active output | 3314 // Simulate hotrod app call SetActiveDevices to change active output |
| 2997 // with only a single active output nodes passed in, which is the old | 3315 // with only a single active output nodes passed in, which is the old |
| 2998 // way of hotrod app. | 3316 // way of hotrod app. |
| 2999 CrasAudioHandler::NodeIdList active_nodes; | 3317 cras_audio_handler_->ChangeActiveNodes({kHDMIOutput->id}); |
| 3000 active_nodes.push_back(kHDMIOutput->id); | |
| 3001 cras_audio_handler_->ChangeActiveNodes(active_nodes); | |
| 3002 | 3318 |
| 3003 // Verify the jabra speaker's output is selected as active output, and | 3319 // Verify the jabra speaker's output is selected as active output, and |
| 3004 // jabra's input is selected as active input. | 3320 // jabra's input is selected as active input. |
| 3321 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3322 EXPECT_EQ(kHDMIOutput->id, cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3323 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3324 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3325 } | |
| 3326 | |
| 3327 TEST_P(CrasAudioHandlerTest, | |
| 3328 SetActiveNodesHotrodInitWithSingleJabraChangeOutputOldCall) { | |
| 3329 AudioNodeList audio_nodes = | |
| 3330 GenerateAudioNodeList({kHDMIOutput, kUSBJabraSpeakerOutput1, | |
| 3331 kUSBJabraSpeakerInput1, kUSBCameraInput}); | |
| 3332 SetUpCrasAudioHandler(audio_nodes); | |
| 3333 | |
| 3334 // Verify the audio devices size. | |
| 3335 AudioDeviceList audio_devices; | |
| 3336 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 3337 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 3338 | |
| 3339 // Verify the jabra speaker's output and input are selected as active output | |
| 3340 // by CrasAudioHandler. | |
| 3341 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3342 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3343 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3344 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3345 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3346 | |
| 3347 // Simulate hotrod app call SetActiveDevices to change active output | |
| 3348 // with only a single active output nodes passed in, which is the old | |
| 3349 // way of hotrod app. | |
| 3350 cras_audio_handler_->SetActiveOutputNodes({kHDMIOutput->id}); | |
| 3351 | |
| 3352 // Verify the jabra speaker's output is selected as active output, and | |
| 3353 // jabra's input is selected as active input. | |
| 3005 EXPECT_EQ(2, GetActiveDeviceCount()); | 3354 EXPECT_EQ(2, GetActiveDeviceCount()); |
| 3006 EXPECT_EQ(kHDMIOutput->id, cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3355 EXPECT_EQ(kHDMIOutput->id, cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 3007 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | 3356 EXPECT_EQ(kUSBJabraSpeakerInput1->id, |
| 3008 cras_audio_handler_->GetPrimaryActiveInputNode()); | 3357 cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 3009 } | 3358 } |
| 3010 | 3359 |
| 3360 TEST_P(CrasAudioHandlerTest, SetEmptyActiveOutputNodes) { | |
| 3361 AudioNodeList audio_nodes = | |
| 3362 GenerateAudioNodeList({kHDMIOutput, kUSBJabraSpeakerOutput1, | |
| 3363 kUSBJabraSpeakerInput1, kUSBCameraInput}); | |
| 3364 SetUpCrasAudioHandler(audio_nodes); | |
| 3365 | |
| 3366 // Verify the audio devices size. | |
| 3367 AudioDeviceList audio_devices; | |
| 3368 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 3369 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 3370 | |
| 3371 // Verify the jabra speaker's output and input are selected as active output | |
| 3372 // by CrasAudioHandler. | |
| 3373 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3374 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3375 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3376 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3377 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3378 | |
| 3379 cras_audio_handler_->SetActiveOutputNodes(CrasAudioHandler::NodeIdList()); | |
| 3380 | |
| 3381 // Verify the jabra speaker's output is selected as active output, and | |
| 3382 // jabra's input is selected as active input. | |
|
jennyz
2017/01/07 00:33:00
Wrong comment.
tbarzic
2017/01/07 05:16:31
Done.
| |
| 3383 EXPECT_EQ(1, GetActiveDeviceCount()); | |
| 3384 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3385 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
|
jennyz
2017/01/07 00:33:00
You can also verify cras_audio_handler_->GetPrimar
tbarzic
2017/01/07 05:16:31
Done.
| |
| 3386 } | |
| 3387 | |
| 3388 TEST_P(CrasAudioHandlerTest, SetEmptyActiveInputNodes) { | |
| 3389 AudioNodeList audio_nodes = | |
| 3390 GenerateAudioNodeList({kHDMIOutput, kUSBJabraSpeakerOutput1, | |
| 3391 kUSBJabraSpeakerInput1, kUSBCameraInput}); | |
| 3392 SetUpCrasAudioHandler(audio_nodes); | |
| 3393 | |
| 3394 // Verify the audio devices size. | |
| 3395 AudioDeviceList audio_devices; | |
| 3396 cras_audio_handler_->GetAudioDevices(&audio_devices); | |
| 3397 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | |
| 3398 | |
| 3399 // Verify the jabra speaker's output and input are selected as active output | |
| 3400 // by CrasAudioHandler. | |
| 3401 EXPECT_EQ(2, GetActiveDeviceCount()); | |
| 3402 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3403 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3404 EXPECT_EQ(kUSBJabraSpeakerInput1->id, | |
| 3405 cras_audio_handler_->GetPrimaryActiveInputNode()); | |
| 3406 | |
| 3407 cras_audio_handler_->SetActiveInputNodes(CrasAudioHandler::NodeIdList()); | |
| 3408 | |
| 3409 // Verify the jabra speaker's output is selected as active output, and | |
| 3410 // jabra's input is selected as active input. | |
|
jennyz
2017/01/07 00:33:00
ditto.
tbarzic
2017/01/07 05:16:31
Done.
| |
| 3411 EXPECT_EQ(1, GetActiveDeviceCount()); | |
| 3412 EXPECT_EQ(kUSBJabraSpeakerOutput1->id, | |
| 3413 cras_audio_handler_->GetPrimaryActiveOutputNode()); | |
| 3414 } | |
| 3415 | |
| 3011 TEST_P(CrasAudioHandlerTest, NoMoreAudioInputDevices) { | 3416 TEST_P(CrasAudioHandlerTest, NoMoreAudioInputDevices) { |
| 3012 // Some device like chromebox does not have the internal input device. The | 3417 // Some device like chromebox does not have the internal input device. The |
| 3013 // active devices should be reset when the user plugs a device and then | 3418 // active devices should be reset when the user plugs a device and then |
| 3014 // unplugs it to such device. | 3419 // unplugs it to such device. |
| 3015 AudioNodeList audio_nodes = GenerateAudioNodeList({kInternalSpeaker}); | 3420 AudioNodeList audio_nodes = GenerateAudioNodeList({kInternalSpeaker}); |
| 3016 SetUpCrasAudioHandler(audio_nodes); | 3421 SetUpCrasAudioHandler(audio_nodes); |
| 3017 | 3422 |
| 3018 EXPECT_EQ(0ULL, cras_audio_handler_->GetPrimaryActiveInputNode()); | 3423 EXPECT_EQ(0ULL, cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 3019 | 3424 |
| 3020 audio_nodes.push_back(GenerateAudioNode(kMicJack)); | 3425 audio_nodes.push_back(GenerateAudioNode(kMicJack)); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3294 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); | 3699 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); |
| 3295 EXPECT_EQ(kInternalSpeaker->id, active_output.id); | 3700 EXPECT_EQ(kInternalSpeaker->id, active_output.id); |
| 3296 EXPECT_EQ(kInternalSpeaker->id, | 3701 EXPECT_EQ(kInternalSpeaker->id, |
| 3297 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3702 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 3298 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); | 3703 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); |
| 3299 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); | 3704 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); |
| 3300 EXPECT_TRUE(test_observer_->output_mute_by_system()); | 3705 EXPECT_TRUE(test_observer_->output_mute_by_system()); |
| 3301 } | 3706 } |
| 3302 | 3707 |
| 3303 } // namespace chromeos | 3708 } // namespace chromeos |
| OLD | NEW |