1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "webrtc/modules/audio_device/include/audio_device.h" 12 #include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h" 13 14 class HardwareTest : public AfterStreamingFixture { 15 }; 16 17 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) 18 TEST_F(HardwareTest, AbleToQueryForDevices) { 19 int num_recording_devices = 0; 20 int num_playout_devices = 0; 21 EXPECT_EQ(0, voe_hardware_->GetNumOfRecordingDevices(num_recording_devices)); 22 EXPECT_EQ(0, voe_hardware_->GetNumOfPlayoutDevices(num_playout_devices)); 23 24 ASSERT_GT(num_recording_devices, 0) << 25 "There seem to be no recording devices on your system, " 26 "and this test really doesn't make sense then."; 27 ASSERT_GT(num_playout_devices, 0) << 28 "There seem to be no playout devices on your system, " 29 "and this test really doesn't make sense then."; 30 31 // Recording devices are handled a bit differently on Windows - we can 32 // just tell it to set the 'default' communication device there. 33 #ifdef _WIN32 34 // Should also work while already recording. 35 EXPECT_EQ(0, voe_hardware_->SetRecordingDevice( 36 webrtc::AudioDeviceModule::kDefaultCommunicationDevice)); 37 // Should also work while already playing. 38 EXPECT_EQ(0, voe_hardware_->SetPlayoutDevice( 39 webrtc::AudioDeviceModule::kDefaultCommunicationDevice)); 40 #else 41 // For other platforms, just use the first device encountered. 42 EXPECT_EQ(0, voe_hardware_->SetRecordingDevice(0)); 43 EXPECT_EQ(0, voe_hardware_->SetPlayoutDevice(0)); 44 #endif 45 46 // It's hard to know what names this will return (it's system-dependent), 47 // so just check that it's possible to do it. 48 char device_name[128] = {0}; 49 char guid_name[128] = {0}; 50 EXPECT_EQ(0, voe_hardware_->GetRecordingDeviceName( 51 0, device_name, guid_name)); 52 EXPECT_EQ(0, voe_hardware_->GetPlayoutDeviceName( 53 0, device_name, guid_name)); 54 } 55 #endif 56