128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org/* 228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * libjingle 328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * Copyright 2004 Google Inc. 428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * 528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without 628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * modification, are permitted provided that the following conditions are met: 728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * 828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * this list of conditions and the following disclaimer. 1028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 1128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * this list of conditions and the following disclaimer in the documentation 1228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * and/or other materials provided with the distribution. 1328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * 3. The name of the author may not be used to endorse or promote products 1428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * derived from this software without specific prior written permission. 1528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * 1628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 1728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 1928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 2228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 2528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org */ 2728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org 2828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/media/devices/dummydevicemanager.h" 29a09a99950ec40aef6421e4ba35eee7196b7a6e68buildbot@webrtc.org#include "webrtc/base/gunit.h" 3028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org 3128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgusing cricket::Device; 3228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgusing cricket::DummyDeviceManager; 3328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org 3428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Test that we startup/shutdown properly. 3528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgTEST(DummyDeviceManagerTest, StartupShutdown) { 3628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org DummyDeviceManager dm; 3728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.Init()); 3828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org dm.Terminate(); 3928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org} 4028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org 4128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Test enumerating capabilities. 4228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgTEST(DummyDeviceManagerTest, GetCapabilities) { 4328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org DummyDeviceManager dm; 4428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org int capabilities = dm.GetCapabilities(); 4528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_EQ((cricket::AUDIO_SEND | cricket::AUDIO_RECV | 4628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org cricket::VIDEO_SEND | cricket::VIDEO_RECV), capabilities); 4728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org} 4828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org 4928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Test enumerating devices. 5028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgTEST(DummyDeviceManagerTest, GetDevices) { 5128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org DummyDeviceManager dm; 5228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.Init()); 5328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org std::vector<Device> audio_ins, audio_outs, video_ins; 5428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetAudioInputDevices(&audio_ins)); 5528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetAudioOutputDevices(&audio_outs)); 5628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetVideoCaptureDevices(&video_ins)); 5728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org} 5828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org 5928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Test that we return correct ids for default and bogus devices. 6028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgTEST(DummyDeviceManagerTest, GetAudioDeviceIds) { 6128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org DummyDeviceManager dm; 6228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org Device device; 6328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.Init()); 6428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetAudioInputDevice( 6528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org cricket::DeviceManagerInterface::kDefaultDeviceName, &device)); 6628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_EQ("-1", device.id); 6728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetAudioOutputDevice( 6828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org cricket::DeviceManagerInterface::kDefaultDeviceName, &device)); 6928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_EQ("-1", device.id); 7028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_FALSE(dm.GetAudioInputDevice("_NOT A REAL DEVICE_", &device)); 7128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_FALSE(dm.GetAudioOutputDevice("_NOT A REAL DEVICE_", &device)); 7228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org} 7328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org 7428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Test that we get the video capture device by name properly. 7528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgTEST(DummyDeviceManagerTest, GetVideoDeviceIds) { 7628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org DummyDeviceManager dm; 7728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org Device device; 7828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.Init()); 7928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_FALSE(dm.GetVideoCaptureDevice("_NOT A REAL DEVICE_", &device)); 8028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetVideoCaptureDevice( 8128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org cricket::DeviceManagerInterface::kDefaultDeviceName, &device)); 8228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org} 8328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org 8428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgTEST(DummyDeviceManagerTest, VerifyDevicesListsAreCleared) { 8528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org const std::string imaginary("_NOT A REAL DEVICE_"); 8628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org DummyDeviceManager dm; 8728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org std::vector<Device> audio_ins, audio_outs, video_ins; 8828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org audio_ins.push_back(Device(imaginary, imaginary)); 8928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org audio_outs.push_back(Device(imaginary, imaginary)); 9028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org video_ins.push_back(Device(imaginary, imaginary)); 9128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.Init()); 9228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetAudioInputDevices(&audio_ins)); 9328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetAudioOutputDevices(&audio_outs)); 9428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_TRUE(dm.GetVideoCaptureDevices(&video_ins)); 9528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org for (size_t i = 0; i < audio_ins.size(); ++i) { 9628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_NE(imaginary, audio_ins[i].name); 9728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org } 9828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org for (size_t i = 0; i < audio_outs.size(); ++i) { 9928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_NE(imaginary, audio_outs[i].name); 10028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org } 10128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org for (size_t i = 0; i < video_ins.size(); ++i) { 10228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org EXPECT_NE(imaginary, video_ins[i].name); 10328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org } 10428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org} 105