158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// found in the LICENSE file. 458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "base/environment.h" 658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "base/logging.h" 758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/synchronization/waitable_event.h" 958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "media/audio/audio_manager.h" 10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "media/audio/audio_manager_base.h" 11a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "media/audio/fake_audio_log_factory.h" 1258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 1358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 14f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#if defined(USE_ALSA) 15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "media/audio/alsa/audio_manager_alsa.h" 16f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#endif // defined(USE_ALSA) 1758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 1858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_WIN) 19d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "base/win/scoped_com_initializer.h" 2058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "media/audio/win/audio_manager_win.h" 21d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "media/audio/win/wavein_input_win.h" 22d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif 2358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 2458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(USE_PULSEAUDIO) 2558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "media/audio/pulse/audio_manager_pulse.h" 2658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif // defined(USE_PULSEAUDIO) 2758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 2858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace media { 2958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 30d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Test fixture which allows us to override the default enumeration API on 31d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Windows. 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class AudioManagerTest : public ::testing::Test { 33d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) protected: 34d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioManagerTest() 35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) : audio_manager_(AudioManager::CreateForTesting()) 36d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#if defined(OS_WIN) 37d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) , com_init_(base::win::ScopedCOMInitializer::kMTA) 38d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif 39d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) { 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Wait for audio thread initialization to complete. Otherwise the 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // enumeration type may not have been set yet. 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::WaitableEvent event(false, false); 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) audio_manager_->GetTaskRunner()->PostTask(FROM_HERE, base::Bind( 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) &base::WaitableEvent::Signal, base::Unretained(&event))); 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) event.Wait(); 4658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 4758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) AudioManager* audio_manager() { return audio_manager_.get(); }; 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_WIN) 51d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool SetMMDeviceEnumeration() { 52d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); 53d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Windows Wave is used as default if Windows XP was detected => 54d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // return false since MMDevice is not supported on XP. 55d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (amw->enumeration_type() == AudioManagerWin::kWaveEnumeration) 56d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return false; 57d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 58d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) amw->SetEnumerationType(AudioManagerWin::kMMDeviceEnumeration); 59d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return true; 60d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 61d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 62d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void SetWaveEnumeration() { 63d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); 64d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) amw->SetEnumerationType(AudioManagerWin::kWaveEnumeration); 65d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 66d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 67d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) std::string GetDeviceIdFromPCMWaveInAudioInputStream( 68d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const std::string& device_id) { 69d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); 70d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioParameters parameters( 71d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 72d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioParameters::kAudioCDSampleRate, 16, 73d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 1024); 74d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) scoped_ptr<PCMWaveInAudioInputStream> stream( 75d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) static_cast<PCMWaveInAudioInputStream*>( 76d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) amw->CreatePCMWaveInAudioInputStream(parameters, device_id))); 77d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return stream.get() ? stream->device_id_ : std::string(); 78d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 79d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif 80d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 81d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Helper method which verifies that the device list starts with a valid 82d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // default record followed by non-default device names. 83d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) static void CheckDeviceNames(const AudioDeviceNames& device_names) { 84d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) VLOG(2) << "Got " << device_names.size() << " audio devices."; 85d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!device_names.empty()) { 86d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames::const_iterator it = device_names.begin(); 87d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 88d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // The first device in the list should always be the default device. 89d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName), 90d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) it->device_name); 91d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); 92d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ++it; 93d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 94d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Other devices should have non-empty name and id and should not contain 95d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // default name or id. 96d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) while (it != device_names.end()) { 97d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_FALSE(it->device_name.empty()); 98d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_FALSE(it->unique_id.empty()); 99d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) VLOG(2) << "Device ID(" << it->unique_id 100d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) << "), label: " << it->device_name; 101d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), 102d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) it->device_name); 103d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), 104d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) it->unique_id); 105d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ++it; 106d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 10758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } else { 108d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Log a warning so we can see the status on the build bots. No need to 109d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // break the test though since this does successfully test the code and 110d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // some failure cases. 111d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) LOG(WARNING) << "No input devices detected"; 11258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 11358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 11458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 115d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool CanRunInputTest() { 116d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return audio_manager_->HasAudioInputDevices(); 11758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 118d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 119d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) bool CanRunOutputTest() { 120d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return audio_manager_->HasAudioOutputDevices(); 12158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 12258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 123a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#if defined(USE_ALSA) || defined(USE_PULSEAUDIO) 124a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) template <class T> 125a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void CreateAudioManagerForTesting() { 126a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Only one AudioManager may exist at a time, so destroy the one we're 127a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // currently holding before creating a new one. 128a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) audio_manager_.reset(); 129a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) audio_manager_.reset(T::Create(&fake_audio_log_factory_)); 130a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 131a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif 132a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Synchronously runs the provided callback/closure on the audio thread. 134a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void RunOnAudioThread(const base::Closure& closure) { 135a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!audio_manager()->GetTaskRunner()->BelongsToCurrentThread()) { 136a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::WaitableEvent event(false, false); 137a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) audio_manager_->GetTaskRunner()->PostTask( 138a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FROM_HERE, 139a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Bind(&AudioManagerTest::RunOnAudioThreadImpl, 140a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Unretained(this), 141a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) closure, 142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) &event)); 143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event.Wait(); 144a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } else { 145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) closure.Run(); 146a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 147a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 148a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 149a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void RunOnAudioThreadImpl(const base::Closure& closure, 150a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::WaitableEvent* event) { 151a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); 152a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) closure.Run(); 153a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event->Signal(); 154a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 155a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 156a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) FakeAudioLogFactory fake_audio_log_factory_; 157d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) scoped_ptr<AudioManager> audio_manager_; 15858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 15958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_WIN) 160d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // The MMDevice API requires COM to be initialized on the current thread. 161d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) base::win::ScopedCOMInitializer com_init_; 162d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif 163d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)}; 164d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 165d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Test that devices can be enumerated. 166d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateInputDevices) { 167d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest()) 168d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 169d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 170d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 171a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) RunOnAudioThread( 172a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Bind(&AudioManager::GetAudioInputDeviceNames, 173a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Unretained(audio_manager()), 174a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) &device_names)); 175d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 176d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 177d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 178d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Test that devices can be enumerated. 179d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateOutputDevices) { 180d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunOutputTest()) 181d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 182d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 183d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) RunOnAudioThread( 185a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Bind(&AudioManager::GetAudioOutputDeviceNames, 186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Unretained(audio_manager()), 187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) &device_names)); 188d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 189d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 190d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 191d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Run additional tests for Windows since enumeration can be done using 192d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// two different APIs. MMDevice is default for Vista and higher and Wave 193d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// is default for XP and lower. 194d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#if defined(OS_WIN) 195d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 196d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Override default enumeration API and force usage of Windows MMDevice. 197d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// This test will only run on Windows Vista and higher. 198d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateInputDevicesWinMMDevice) { 199d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest()) 200d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 201d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 202d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 203d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!SetMMDeviceEnumeration()) { 204d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Usage of MMDevice will fail on XP and lower. 205d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) LOG(WARNING) << "MM device enumeration is not supported."; 206d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 207d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 208d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioInputDeviceNames(&device_names); 209d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 210d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 211d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 212d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateOutputDevicesWinMMDevice) { 213d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunOutputTest()) 214d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 215d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 216d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 217d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!SetMMDeviceEnumeration()) { 218d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Usage of MMDevice will fail on XP and lower. 219d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) LOG(WARNING) << "MM device enumeration is not supported."; 220d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 221d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 222d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioOutputDeviceNames(&device_names); 223d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 224d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 225d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 226d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Override default enumeration API and force usage of Windows Wave. 227d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// This test will run on Windows XP, Windows Vista and Windows 7. 228d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateInputDevicesWinWave) { 229d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest()) 230d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 231d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 232d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 233d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) SetWaveEnumeration(); 234d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioInputDeviceNames(&device_names); 235d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 236d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 237d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 238d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateOutputDevicesWinWave) { 239d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunOutputTest()) 240d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 241d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 242d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 243d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) SetWaveEnumeration(); 244d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioOutputDeviceNames(&device_names); 245d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 246d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 247d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 248d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, WinXPDeviceIdUnchanged) { 249d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest()) 250d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 251d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 252d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames xp_device_names; 253d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) SetWaveEnumeration(); 254d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioInputDeviceNames(&xp_device_names); 255d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(xp_device_names); 256d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 257d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Device ID should remain unchanged, including the default device ID. 258d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) for (AudioDeviceNames::iterator i = xp_device_names.begin(); 259d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) i != xp_device_names.end(); ++i) { 260d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_EQ(i->unique_id, 261d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) GetDeviceIdFromPCMWaveInAudioInputStream(i->unique_id)); 262d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 263d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 264d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 265d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, ConvertToWinXPInputDeviceId) { 266d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest()) 267d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 268d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 269d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!SetMMDeviceEnumeration()) { 270d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Usage of MMDevice will fail on XP and lower. 271d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) LOG(WARNING) << "MM device enumeration is not supported."; 272d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 273d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 274d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 275d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 276d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioInputDeviceNames(&device_names); 277d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 278d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 279d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) for (AudioDeviceNames::iterator i = device_names.begin(); 280d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) i != device_names.end(); ++i) { 281d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) std::string converted_id = 282d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) GetDeviceIdFromPCMWaveInAudioInputStream(i->unique_id); 283d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (i == device_names.begin()) { 284d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // The first in the list is the default device ID, which should not be 285d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // changed when passed to PCMWaveInAudioInputStream. 286d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_EQ(i->unique_id, converted_id); 287d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } else { 288d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // MMDevice-style device IDs should be converted to WaveIn-style device 289d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // IDs. 290d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_NE(i->unique_id, converted_id); 29158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 29258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 293d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 294d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 29558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif // defined(OS_WIN) 296d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 297d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#if defined(USE_PULSEAUDIO) 298d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// On Linux, there are two implementations available and both can 299d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// sometimes be tested on a single system. These tests specifically 300d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// test Pulseaudio. 301d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 302d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateInputDevicesPulseaudio) { 303d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest()) 304d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 305d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 306a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CreateAudioManagerForTesting<AudioManagerPulse>(); 307d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (audio_manager_.get()) { 308d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 309d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioInputDeviceNames(&device_names); 310d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 311d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } else { 312d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) LOG(WARNING) << "No pulseaudio on this system."; 313d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 31458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)} 31558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 316d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateOutputDevicesPulseaudio) { 317d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunOutputTest()) 318d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 319d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 320a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CreateAudioManagerForTesting<AudioManagerPulse>(); 321d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (audio_manager_.get()) { 322d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 323d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioOutputDeviceNames(&device_names); 324d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 325d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } else { 326d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) LOG(WARNING) << "No pulseaudio on this system."; 327d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 328d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 329d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif // defined(USE_PULSEAUDIO) 330d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 331d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#if defined(USE_ALSA) 332d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// On Linux, there are two implementations available and both can 333d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// sometimes be tested on a single system. These tests specifically 334d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// test Alsa. 335d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 336d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateInputDevicesAlsa) { 337d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest()) 338d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 339d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 340f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) VLOG(2) << "Testing AudioManagerAlsa."; 341a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CreateAudioManagerForTesting<AudioManagerAlsa>(); 342d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 343d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioInputDeviceNames(&device_names); 344d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 345d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 346d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 347d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)TEST_F(AudioManagerTest, EnumerateOutputDevicesAlsa) { 348d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunOutputTest()) 349d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return; 350d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 351f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) VLOG(2) << "Testing AudioManagerAlsa."; 352a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CreateAudioManagerForTesting<AudioManagerAlsa>(); 353d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioDeviceNames device_names; 354d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioOutputDeviceNames(&device_names); 355d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) CheckDeviceNames(device_names); 356d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 357d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif // defined(USE_ALSA) 358d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 35958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)TEST_F(AudioManagerTest, GetDefaultOutputStreamParameters) { 36058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_WIN) || defined(OS_MACOSX) 361d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest()) 36258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) return; 36358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 364d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) AudioParameters params = audio_manager_->GetDefaultOutputStreamParameters(); 36558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_TRUE(params.IsValid()); 36658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif // defined(OS_WIN) || defined(OS_MACOSX) 36758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)} 36858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 36958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)TEST_F(AudioManagerTest, GetAssociatedOutputDeviceID) { 37058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_WIN) || defined(OS_MACOSX) 371d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if (!CanRunInputTest() || !CanRunOutputTest()) 37258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) return; 37358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 37458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) AudioDeviceNames device_names; 375d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAudioInputDeviceNames(&device_names); 37658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) bool found_an_associated_device = false; 37758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) for (AudioDeviceNames::iterator it = device_names.begin(); 37858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) it != device_names.end(); 37958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) ++it) { 38058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_FALSE(it->unique_id.empty()); 38158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_FALSE(it->device_name.empty()); 38258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) std::string output_device_id( 383d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) audio_manager_->GetAssociatedOutputDeviceID(it->unique_id)); 38458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) if (!output_device_id.empty()) { 38558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) VLOG(2) << it->unique_id << " matches with " << output_device_id; 38658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) found_an_associated_device = true; 38758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 38858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 38958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 39058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_TRUE(found_an_associated_device); 39158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif // defined(OS_WIN) || defined(OS_MACOSX) 39258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)} 39358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 39458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)} // namespace media 395