1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "media/audio/win/device_enumeration_win.h" 6 7 #include "testing/gtest/include/gtest/gtest.h" 8 9 namespace media { 10 TEST(DeviceEnumerationWin,GetDeviceSuffix)11TEST(DeviceEnumerationWin, GetDeviceSuffix) { 12 // Some real-world USB devices 13 EXPECT_EQ( 14 GetDeviceSuffixWin("USB\\VID_046D&PID_09A6&MI_02\\6&318d810e&1&0002"), 15 " (046d:09a6)"); 16 EXPECT_EQ(GetDeviceSuffixWin("USB\\VID_8087&PID_07DC&REV_0001"), 17 " (8087:07dc)"); 18 EXPECT_EQ(GetDeviceSuffixWin("USB\\VID_0403&PID_6010"), " (0403:6010)"); 19 20 // Some real-world Bluetooth devices 21 EXPECT_EQ(GetDeviceSuffixWin("BTHHFENUM\\BthHFPAudio\\8&39e29755&0&97"), 22 " (Bluetooth)"); 23 EXPECT_EQ(GetDeviceSuffixWin("BTHENUM\\{0000110b-0000-1000-8000-" 24 "00805f9b34fb}_LOCALMFG&0002\\7&25f92e87&0&" 25 "70886B900BB0_C00000000"), 26 " (Bluetooth)"); 27 28 // Other real-world devices 29 EXPECT_TRUE(GetDeviceSuffixWin("INTELAUDIO\\FUNC_01&VEN_8086&DEV_280B&SUBSYS_" 30 "80860101&REV_1000\\4&c083774&0&0201") 31 .empty()); 32 EXPECT_TRUE(GetDeviceSuffixWin("INTELAUDIO\\FUNC_01&VEN_10EC&DEV_0298&SUBSYS_" 33 "102807BF&REV_1001\\4&c083774&0&0001") 34 .empty()); 35 EXPECT_TRUE( 36 GetDeviceSuffixWin("PCI\\VEN_1000&DEV_0001&SUBSYS_00000000&REV_02\\1&08") 37 .empty()); 38 39 // Other input strings. 40 EXPECT_TRUE(GetDeviceSuffixWin(std::string()).empty()); 41 EXPECT_TRUE(GetDeviceSuffixWin(" ").empty()); 42 EXPECT_TRUE(GetDeviceSuffixWin("USBVID_1234&PID1234").empty()); 43 } 44 45 } // namespace media 46