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

Side by Side Diff: media/audio/android/audio_android_unittest.cc

Issue 2563653002: Replace AudioManager::GetAudio*DeviceNames with AudioManager::GetAudio*DeviceDescriptions (Closed)
Patch Set: nit fixes Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/media/media_devices.cc ('k') | media/audio/audio_device_description.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 double ExpectedTimeBetweenCallbacks(AudioParameters params) { 88 double ExpectedTimeBetweenCallbacks(AudioParameters params) {
89 return (base::TimeDelta::FromMicroseconds( 89 return (base::TimeDelta::FromMicroseconds(
90 params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / 90 params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond /
91 static_cast<double>(params.sample_rate()))).InMillisecondsF(); 91 static_cast<double>(params.sample_rate()))).InMillisecondsF();
92 } 92 }
93 93
94 // Helper method which verifies that the device list starts with a valid 94 // Helper method which verifies that the device list starts with a valid
95 // default device name followed by non-default device names. 95 // default device name followed by non-default device names.
96 void CheckDeviceNames(const AudioDeviceNames& device_names) { 96 void CheckDeviceDescriptions(
97 DVLOG(2) << "Got " << device_names.size() << " audio devices."; 97 const AudioDeviceDescriptions& device_descriptions) {
98 if (device_names.empty()) { 98 DVLOG(2) << "Got " << device_descriptions.size() << " audio devices.";
99 if (device_descriptions.empty()) {
99 // Log a warning so we can see the status on the build bots. No need to 100 // Log a warning so we can see the status on the build bots. No need to
100 // break the test though since this does successfully test the code and 101 // break the test though since this does successfully test the code and
101 // some failure cases. 102 // some failure cases.
102 LOG(WARNING) << "No input devices detected"; 103 LOG(WARNING) << "No input devices detected";
103 return; 104 return;
104 } 105 }
105 106
106 AudioDeviceNames::const_iterator it = device_names.begin(); 107 AudioDeviceDescriptions::const_iterator it = device_descriptions.begin();
107 108
108 // The first device in the list should always be the default device. 109 // The first device in the list should always be the default device.
109 EXPECT_EQ(AudioDeviceDescription::GetDefaultDeviceName(), it->device_name); 110 EXPECT_EQ(AudioDeviceDescription::GetDefaultDeviceName(), it->device_name);
110 EXPECT_EQ(std::string(AudioDeviceDescription::kDefaultDeviceId), 111 EXPECT_EQ(std::string(AudioDeviceDescription::kDefaultDeviceId),
111 it->unique_id); 112 it->unique_id);
112 ++it; 113 ++it;
113 114
114 // Other devices should have non-empty name and id and should not contain 115 // Other devices should have non-empty name and id and should not contain
115 // default name or id. 116 // default name or id.
116 while (it != device_names.end()) { 117 while (it != device_descriptions.end()) {
117 EXPECT_FALSE(it->device_name.empty()); 118 EXPECT_FALSE(it->device_name.empty());
118 EXPECT_FALSE(it->unique_id.empty()); 119 EXPECT_FALSE(it->unique_id.empty());
119 DVLOG(2) << "Device ID(" << it->unique_id 120 EXPECT_FALSE(it->group_id.empty());
120 << "), label: " << it->device_name; 121 DVLOG(2) << "Device ID(" << it->unique_id << "), label: " << it->device_name
122 << " group: " << it->group_id;
121 EXPECT_NE(AudioDeviceDescription::GetDefaultDeviceName(), it->device_name); 123 EXPECT_NE(AudioDeviceDescription::GetDefaultDeviceName(), it->device_name);
122 EXPECT_NE(std::string(AudioDeviceDescription::kDefaultDeviceId), 124 EXPECT_NE(std::string(AudioDeviceDescription::kDefaultDeviceId),
123 it->unique_id); 125 it->unique_id);
124 ++it; 126 ++it;
125 } 127 }
126 } 128 }
127 129
128 // We clear the data bus to ensure that the test does not cause noise. 130 // We clear the data bus to ensure that the test does not cause noise.
129 int RealOnMoreData(base::TimeDelta /* delay */, 131 int RealOnMoreData(base::TimeDelta /* delay */,
130 base::TimeTicks /* delay_timestamp */, 132 base::TimeTicks /* delay_timestamp */,
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 DVLOG(1) << audio_input_parameters(); 734 DVLOG(1) << audio_input_parameters();
733 } 735 }
734 736
735 // Get the default audio output parameters and log the result. 737 // Get the default audio output parameters and log the result.
736 TEST_F(AudioAndroidOutputTest, GetDefaultOutputStreamParameters) { 738 TEST_F(AudioAndroidOutputTest, GetDefaultOutputStreamParameters) {
737 GetDefaultOutputStreamParametersOnAudioThread(); 739 GetDefaultOutputStreamParametersOnAudioThread();
738 DVLOG(1) << audio_output_parameters(); 740 DVLOG(1) << audio_output_parameters();
739 } 741 }
740 742
741 // Verify input device enumeration. 743 // Verify input device enumeration.
742 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) { 744 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceDescriptions) {
743 ABORT_AUDIO_TEST_IF_NOT(audio_manager()->HasAudioInputDevices()); 745 ABORT_AUDIO_TEST_IF_NOT(audio_manager()->HasAudioInputDevices());
744 AudioDeviceNames devices; 746 AudioDeviceDescriptions devices;
745 RunOnAudioThread( 747 RunOnAudioThread(base::Bind(&AudioManager::GetAudioInputDeviceDescriptions,
746 base::Bind(&AudioManager::GetAudioInputDeviceNames, 748 base::Unretained(audio_manager()), &devices));
747 base::Unretained(audio_manager()), 749 CheckDeviceDescriptions(devices);
748 &devices));
749 CheckDeviceNames(devices);
750 } 750 }
751 751
752 // Verify output device enumeration. 752 // Verify output device enumeration.
753 TEST_F(AudioAndroidOutputTest, GetAudioOutputDeviceNames) { 753 TEST_F(AudioAndroidOutputTest, GetAudioOutputDeviceDescriptions) {
754 ABORT_AUDIO_TEST_IF_NOT(audio_manager()->HasAudioOutputDevices()); 754 ABORT_AUDIO_TEST_IF_NOT(audio_manager()->HasAudioOutputDevices());
755 AudioDeviceNames devices; 755 AudioDeviceDescriptions devices;
756 RunOnAudioThread( 756 RunOnAudioThread(base::Bind(&AudioManager::GetAudioOutputDeviceDescriptions,
757 base::Bind(&AudioManager::GetAudioOutputDeviceNames, 757 base::Unretained(audio_manager()), &devices));
758 base::Unretained(audio_manager()), 758 CheckDeviceDescriptions(devices);
759 &devices));
760 CheckDeviceNames(devices);
761 } 759 }
762 760
763 // Ensure that a default input stream can be created and closed. 761 // Ensure that a default input stream can be created and closed.
764 TEST_P(AudioAndroidInputTest, CreateAndCloseInputStream) { 762 TEST_P(AudioAndroidInputTest, CreateAndCloseInputStream) {
765 AudioParameters params = GetInputStreamParameters(); 763 AudioParameters params = GetInputStreamParameters();
766 MakeAudioInputStreamOnAudioThread(params); 764 MakeAudioInputStreamOnAudioThread(params);
767 RunOnAudioThread( 765 RunOnAudioThread(
768 base::Bind(&AudioInputStream::Close, 766 base::Bind(&AudioInputStream::Close,
769 base::Unretained(audio_input_stream_))); 767 base::Unretained(audio_input_stream_)));
770 } 768 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 printf("\n"); 963 printf("\n");
966 StopAndCloseAudioOutputStreamOnAudioThread(); 964 StopAndCloseAudioOutputStreamOnAudioThread();
967 StopAndCloseAudioInputStreamOnAudioThread(); 965 StopAndCloseAudioInputStreamOnAudioThread();
968 } 966 }
969 967
970 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, 968 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest,
971 AudioAndroidInputTest, 969 AudioAndroidInputTest,
972 testing::Bool()); 970 testing::Bool());
973 971
974 } // namespace media 972 } // namespace media
OLDNEW
« no previous file with comments | « content/common/media/media_devices.cc ('k') | media/audio/audio_device_description.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698