Index: media/audio/android/audio_android_unittest.cc |
diff --git a/media/audio/android/audio_android_unittest.cc b/media/audio/android/audio_android_unittest.cc |
index 300e1545322feabcb104f35947b66c866404455d..bb927938261348e005db0fe0703b72ec39012db4 100644 |
--- a/media/audio/android/audio_android_unittest.cc |
+++ b/media/audio/android/audio_android_unittest.cc |
@@ -84,6 +84,40 @@ static double ExpectedTimeBetweenCallbacks(AudioParameters params) { |
static_cast<double>(params.sample_rate()))).InMillisecondsF(); |
} |
+// Helper method which verifies that the device list starts with a valid |
+// default device name followed by non-default device names. |
+static void CheckDeviceNames(const AudioDeviceNames& device_names) { |
+ VLOG(2) << "Got " << device_names.size() << " audio devices."; |
+ if (device_names.empty()) { |
+ // Log a warning so we can see the status on the build bots. No need to |
+ // break the test though since this does successfully test the code and |
+ // some failure cases. |
+ LOG(WARNING) << "No input devices detected"; |
bulach
2013/12/13 15:17:05
nit: perhaps return here? otherwise 101 will fail,
|
+ } |
+ |
+ AudioDeviceNames::const_iterator it = device_names.begin(); |
+ |
+ // The first device in the list should always be the default device. |
+ EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName), |
+ it->device_name); |
+ EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); |
+ ++it; |
+ |
+ // Other devices should have non-empty name and id and should not contain |
+ // default name or id. |
+ while (it != device_names.end()) { |
+ EXPECT_FALSE(it->device_name.empty()); |
+ EXPECT_FALSE(it->unique_id.empty()); |
+ VLOG(2) << "Device ID(" << it->unique_id |
+ << "), label: " << it->device_name; |
+ EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), |
+ it->device_name); |
+ EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), |
+ it->unique_id); |
+ ++it; |
+ } |
+} |
+ |
std::ostream& operator<<(std::ostream& os, const AudioParameters& params) { |
using namespace std; |
os << endl << "format: " << FormatToString(params.format()) << endl |
@@ -524,6 +558,24 @@ TEST_F(AudioAndroidTest, IsAudioLowLatencySupported) { |
: VLOG(0) << "Low latency output is *not* supported"; |
} |
+// Verify input device enumeration. |
+TEST_F(AudioAndroidTest, GetAudioInputDeviceNames) { |
+ if (!audio_manager()->HasAudioInputDevices()) |
+ return; |
+ AudioDeviceNames devices; |
+ audio_manager()->GetAudioInputDeviceNames(&devices); |
+ CheckDeviceNames(devices); |
+} |
+ |
+// Verify output device enumeration. |
+TEST_F(AudioAndroidTest, GetAudioOutputDeviceNames) { |
+ if (!audio_manager()->HasAudioOutputDevices()) |
+ return; |
+ AudioDeviceNames devices; |
+ audio_manager()->GetAudioOutputDeviceNames(&devices); |
+ CheckDeviceNames(devices); |
+} |
+ |
// Ensure that a default input stream can be created and closed. |
TEST_F(AudioAndroidTest, CreateAndCloseInputStream) { |
AudioParameters params = GetDefaultInputStreamParameters(); |