| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "content/renderer/media/media_stream_constraints_util_audio.h" | 5 #include "content/renderer/media/media_stream_constraints_util_audio.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 | 768 |
| 769 // Test advanced constraints sets that can be satisfied. | 769 // Test advanced constraints sets that can be satisfied. |
| 770 TEST_P(MediaStreamConstraintsUtilAudioTest, AdvancedCompatibleConstraints) { | 770 TEST_P(MediaStreamConstraintsUtilAudioTest, AdvancedCompatibleConstraints) { |
| 771 constraint_factory_.AddAdvanced().render_to_associated_sink.SetExact(true); | 771 constraint_factory_.AddAdvanced().render_to_associated_sink.SetExact(true); |
| 772 constraint_factory_.AddAdvanced().goog_audio_mirroring.SetExact(true); | 772 constraint_factory_.AddAdvanced().goog_audio_mirroring.SetExact(true); |
| 773 auto result = SelectSettings(); | 773 auto result = SelectSettings(); |
| 774 EXPECT_TRUE(result.HasValue()); | 774 EXPECT_TRUE(result.HasValue()); |
| 775 CheckDeviceDefaults(result); | 775 CheckDeviceDefaults(result); |
| 776 CheckBoolDefaults({&AudioCaptureSettings::render_to_associated_sink}, | 776 // TODO(crbug.com/736309): Fold this local when clang is fixed. |
| 777 auto render_to_associated_sink = |
| 778 &AudioCaptureSettings::render_to_associated_sink; |
| 779 CheckBoolDefaults({render_to_associated_sink}, |
| 777 {&AudioProcessingProperties::goog_audio_mirroring}, result); | 780 {&AudioProcessingProperties::goog_audio_mirroring}, result); |
| 778 CheckGeometryDefaults(result); | 781 CheckGeometryDefaults(result); |
| 779 EXPECT_TRUE(result.render_to_associated_sink()); | 782 EXPECT_TRUE(result.render_to_associated_sink()); |
| 780 EXPECT_TRUE(result.audio_processing_properties().goog_audio_mirroring); | 783 EXPECT_TRUE(result.audio_processing_properties().goog_audio_mirroring); |
| 781 } | 784 } |
| 782 | 785 |
| 783 // Test that an advanced constraint set that contradicts a previous constraint | 786 // Test that an advanced constraint set that contradicts a previous constraint |
| 784 // set is ignored, but that further constraint sets that can be satisfied are | 787 // set is ignored, but that further constraint sets that can be satisfied are |
| 785 // applied. | 788 // applied. |
| 786 TEST_P(MediaStreamConstraintsUtilAudioTest, | 789 TEST_P(MediaStreamConstraintsUtilAudioTest, |
| 787 AdvancedConflictingMiddleConstraints) { | 790 AdvancedConflictingMiddleConstraints) { |
| 788 constraint_factory_.AddAdvanced().goog_highpass_filter.SetExact(true); | 791 constraint_factory_.AddAdvanced().goog_highpass_filter.SetExact(true); |
| 789 auto& advanced2 = constraint_factory_.AddAdvanced(); | 792 auto& advanced2 = constraint_factory_.AddAdvanced(); |
| 790 advanced2.goog_highpass_filter.SetExact(false); | 793 advanced2.goog_highpass_filter.SetExact(false); |
| 791 advanced2.hotword_enabled.SetExact(true); | 794 advanced2.hotword_enabled.SetExact(true); |
| 792 constraint_factory_.AddAdvanced().goog_audio_mirroring.SetExact(true); | 795 constraint_factory_.AddAdvanced().goog_audio_mirroring.SetExact(true); |
| 793 auto result = SelectSettings(); | 796 auto result = SelectSettings(); |
| 794 EXPECT_TRUE(result.HasValue()); | 797 EXPECT_TRUE(result.HasValue()); |
| 795 CheckDeviceDefaults(result); | 798 CheckDeviceDefaults(result); |
| 796 EXPECT_FALSE(result.hotword_enabled()); | 799 EXPECT_FALSE(result.hotword_enabled()); |
| 797 CheckBoolDefaults({&AudioCaptureSettings::hotword_enabled}, | 800 // TODO(crbug.com/736309): Fold this local when clang is fixed. |
| 801 auto hotword_enabled = &AudioCaptureSettings::hotword_enabled; |
| 802 CheckBoolDefaults({hotword_enabled}, |
| 798 {&AudioProcessingProperties::goog_audio_mirroring, | 803 {&AudioProcessingProperties::goog_audio_mirroring, |
| 799 &AudioProcessingProperties::goog_highpass_filter}, | 804 &AudioProcessingProperties::goog_highpass_filter}, |
| 800 result); | 805 result); |
| 801 CheckGeometryDefaults(result); | 806 CheckGeometryDefaults(result); |
| 802 EXPECT_FALSE(result.hotword_enabled()); | 807 EXPECT_FALSE(result.hotword_enabled()); |
| 803 EXPECT_TRUE(result.audio_processing_properties().goog_audio_mirroring); | 808 EXPECT_TRUE(result.audio_processing_properties().goog_audio_mirroring); |
| 804 EXPECT_TRUE(result.audio_processing_properties().goog_highpass_filter); | 809 EXPECT_TRUE(result.audio_processing_properties().goog_highpass_filter); |
| 805 } | 810 } |
| 806 | 811 |
| 807 // Test that an advanced constraint set that contradicts a previous constraint | 812 // Test that an advanced constraint set that contradicts a previous constraint |
| 808 // set with a boolean constraint is ignored. | 813 // set with a boolean constraint is ignored. |
| 809 TEST_P(MediaStreamConstraintsUtilAudioTest, AdvancedConflictingLastConstraint) { | 814 TEST_P(MediaStreamConstraintsUtilAudioTest, AdvancedConflictingLastConstraint) { |
| 810 constraint_factory_.AddAdvanced().goog_highpass_filter.SetExact(true); | 815 constraint_factory_.AddAdvanced().goog_highpass_filter.SetExact(true); |
| 811 constraint_factory_.AddAdvanced().hotword_enabled.SetExact(true); | 816 constraint_factory_.AddAdvanced().hotword_enabled.SetExact(true); |
| 812 constraint_factory_.AddAdvanced().goog_audio_mirroring.SetExact(true); | 817 constraint_factory_.AddAdvanced().goog_audio_mirroring.SetExact(true); |
| 813 constraint_factory_.AddAdvanced().hotword_enabled.SetExact(false); | 818 constraint_factory_.AddAdvanced().hotword_enabled.SetExact(false); |
| 814 auto result = SelectSettings(); | 819 auto result = SelectSettings(); |
| 815 EXPECT_TRUE(result.HasValue()); | 820 EXPECT_TRUE(result.HasValue()); |
| 816 CheckDeviceDefaults(result); | 821 CheckDeviceDefaults(result); |
| 817 CheckBoolDefaults({&AudioCaptureSettings::hotword_enabled}, | 822 // TODO(crbug.com/736309): Fold this local when clang is fixed. |
| 823 auto hotword_enabled = &AudioCaptureSettings::hotword_enabled; |
| 824 CheckBoolDefaults({hotword_enabled}, |
| 818 {&AudioProcessingProperties::goog_audio_mirroring, | 825 {&AudioProcessingProperties::goog_audio_mirroring, |
| 819 &AudioProcessingProperties::goog_highpass_filter}, | 826 &AudioProcessingProperties::goog_highpass_filter}, |
| 820 result); | 827 result); |
| 821 CheckGeometryDefaults(result); | 828 CheckGeometryDefaults(result); |
| 822 // The fourth advanced set is ignored because it contradicts the second set. | 829 // The fourth advanced set is ignored because it contradicts the second set. |
| 823 EXPECT_TRUE(result.hotword_enabled()); | 830 EXPECT_TRUE(result.hotword_enabled()); |
| 824 EXPECT_TRUE(result.audio_processing_properties().goog_audio_mirroring); | 831 EXPECT_TRUE(result.audio_processing_properties().goog_audio_mirroring); |
| 825 EXPECT_TRUE(result.audio_processing_properties().goog_highpass_filter); | 832 EXPECT_TRUE(result.audio_processing_properties().goog_highpass_filter); |
| 826 } | 833 } |
| 827 | 834 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 } | 975 } |
| 969 | 976 |
| 970 INSTANTIATE_TEST_CASE_P(, | 977 INSTANTIATE_TEST_CASE_P(, |
| 971 MediaStreamConstraintsUtilAudioTest, | 978 MediaStreamConstraintsUtilAudioTest, |
| 972 testing::Values("", | 979 testing::Values("", |
| 973 kMediaStreamSourceTab, | 980 kMediaStreamSourceTab, |
| 974 kMediaStreamSourceSystem, | 981 kMediaStreamSourceSystem, |
| 975 kMediaStreamSourceDesktop)); | 982 kMediaStreamSourceDesktop)); |
| 976 | 983 |
| 977 } // namespace content | 984 } // namespace content |
| OLD | NEW |