2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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.
13 #include "webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h"
15 using namespace webrtc;
17 class HardwareBeforeStreamingTest : public AfterInitializationFixture {
20 // Tests that apply to both mobile and desktop:
22 TEST_F(HardwareBeforeStreamingTest,
23 SetAudioDeviceLayerFailsSinceTheVoiceEngineHasBeenInitialized) {
24 EXPECT_NE(0, voe_hardware_->SetAudioDeviceLayer(kAudioPlatformDefault));
25 EXPECT_EQ(VE_ALREADY_INITED, voe_base_->LastError());
28 // Tests that only apply to mobile:
31 TEST_F(HardwareBeforeStreamingTest, ResetsAudioDeviceOnIphone) {
32 EXPECT_EQ(0, voe_hardware_->ResetAudioDevice());
36 // Tests that only apply to desktop:
37 #if !defined(WEBRTC_IOS) & !defined(WEBRTC_ANDROID)
39 static const char* kNoDevicesErrorMessage =
40 "Either you have no recording / playout device "
41 "on your system, or the method failed.";
43 // Win, Mac and Linux sound device tests.
44 TEST_F(HardwareBeforeStreamingTest,
45 GetRecordingDeviceNameRetrievesDeviceNames) {
46 char device_name[128] = {0};
47 char guid_name[128] = {0};
50 EXPECT_EQ(0, voe_hardware_->GetRecordingDeviceName(
51 -1, device_name, guid_name));
52 EXPECT_GT(strlen(device_name), 0u) << kNoDevicesErrorMessage;
53 device_name[0] = '\0';
55 EXPECT_EQ(0, voe_hardware_->GetPlayoutDeviceName(
56 -1, device_name, guid_name));
57 EXPECT_GT(strlen(device_name), 0u) << kNoDevicesErrorMessage;
60 EXPECT_EQ(0, voe_hardware_->GetRecordingDeviceName(
61 0, device_name, guid_name));
62 EXPECT_GT(strlen(device_name), 0u) << kNoDevicesErrorMessage;
63 device_name[0] = '\0';
65 EXPECT_EQ(0, voe_hardware_->GetPlayoutDeviceName(
66 0, device_name, guid_name));
67 EXPECT_GT(strlen(device_name), 0u) << kNoDevicesErrorMessage;
71 TEST_F(HardwareBeforeStreamingTest,
72 AllEnumeratedRecordingDevicesCanBeSetAsRecordingDevice) {
73 // Check recording side.
74 // Extended Win32 enumeration tests: unique GUID outputs on Vista and up:
75 // Win XP and below : device_name is copied to guid_name.
76 // Win Vista and up : device_name is the friendly name and GUID is a unique
78 // Other : guid_name is left unchanged.
79 int num_of_recording_devices = 0;
80 EXPECT_EQ(0, voe_hardware_->GetNumOfRecordingDevices(
81 num_of_recording_devices));
82 EXPECT_GT(num_of_recording_devices, 0) << kNoDevicesErrorMessage;
84 char device_name[128] = {0};
85 char guid_name[128] = {0};
87 for (int i = 0; i < num_of_recording_devices; i++) {
88 EXPECT_EQ(0, voe_hardware_->GetRecordingDeviceName(
89 i, device_name, guid_name));
90 EXPECT_GT(strlen(device_name), 0u) <<
91 "There should be no empty device names "
92 "among the ones the system gives us.";
93 EXPECT_EQ(0, voe_hardware_->SetRecordingDevice(i));
97 TEST_F(HardwareBeforeStreamingTest,
98 AllEnumeratedPlayoutDevicesCanBeSetAsPlayoutDevice) {
99 // Check playout side (see recording side test for more info on GUIDs).
100 int num_of_playout_devices = 0;
101 EXPECT_EQ(0, voe_hardware_->GetNumOfPlayoutDevices(
102 num_of_playout_devices));
103 EXPECT_GT(num_of_playout_devices, 0) << kNoDevicesErrorMessage;
105 char device_name[128] = {0};
106 char guid_name[128] = {0};
108 for (int i = 0; i < num_of_playout_devices; ++i) {
109 EXPECT_EQ(0, voe_hardware_->GetPlayoutDeviceName(
110 i, device_name, guid_name));
111 EXPECT_GT(strlen(device_name), 0u) <<
112 "There should be no empty device names "
113 "among the ones the system gives us.";
114 EXPECT_EQ(0, voe_hardware_->SetPlayoutDevice(i));
118 TEST_F(HardwareBeforeStreamingTest,
119 SetDeviceWithMagicalArgumentsSetsDefaultSoundDevices) {
121 // -1 means "default device" on Windows.
122 EXPECT_EQ(0, voe_hardware_->SetRecordingDevice(-1));
123 EXPECT_EQ(0, voe_hardware_->SetPlayoutDevice(-1));
125 EXPECT_EQ(0, voe_hardware_->SetRecordingDevice(0));
126 EXPECT_EQ(0, voe_hardware_->SetPlayoutDevice(0));
130 #endif // !defined(WEBRTC_IOS) & !defined(WEBRTC_ANDROID)