| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/midi/midi_manager_alsa.h" | 5 #include "media/midi/midi_manager_alsa.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| 11 TEST(MidiManagerAlsaTest, ExtractManufacturer) { | 11 TEST(MidiManagerAlsaTest, ExtractManufacturer) { |
| 12 ASSERT_EQ("My\\x20Vendor", | 12 ASSERT_EQ("My\\x20Vendor", |
| 13 MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 13 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 14 "My\\x20Vendor", "1234", "My Vendor, Inc.", "Card", | 14 "My\\x20Vendor", "1234", "My Vendor, Inc.", "Card", |
| 15 "My Vendor Inc Card at bus")); | 15 "My Vendor Inc Card at bus")); |
| 16 ASSERT_EQ("My Vendor", MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 16 ASSERT_EQ("My Vendor", |
| 17 "My Vendor", "1234", "My Vendor, Inc.", "Card", | 17 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 18 "My Vendor Inc Card at bus")); | 18 "My Vendor", "1234", "My Vendor, Inc.", "Card", |
| 19 "My Vendor Inc Card at bus")); |
| 19 ASSERT_EQ("My Vendor, Inc.", | 20 ASSERT_EQ("My Vendor, Inc.", |
| 20 MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 21 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 21 "1234", "1234", "My Vendor, Inc.", "Card", | 22 "1234", "1234", "My Vendor, Inc.", "Card", |
| 22 "My Vendor Inc Card at bus")); | 23 "My Vendor Inc Card at bus")); |
| 23 ASSERT_EQ("My Vendor Inc", | 24 ASSERT_EQ("My Vendor Inc", |
| 24 MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 25 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 25 "1234", "1234", "", "Card", "My Vendor Inc Card at bus")); | 26 "1234", "1234", "", "Card", "My Vendor Inc Card at bus")); |
| 26 ASSERT_EQ("My Vendor Inc", | 27 ASSERT_EQ("My Vendor Inc", |
| 27 MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 28 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 28 "", "", "", "Card", "My Vendor Inc Card at bus")); | 29 "", "", "", "Card", "My Vendor Inc Card at bus")); |
| 29 ASSERT_EQ("", MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 30 ASSERT_EQ("", MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 30 "1234", "1234", "", "Card", "Longname")); | 31 "1234", "1234", "", "Card", "Longname")); |
| 31 ASSERT_EQ("Keystation\\x20Mini\\x2032", | 32 ASSERT_EQ("Keystation\\x20Mini\\x2032", |
| 32 MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 33 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 33 "Keystation\\x20Mini\\x2032", "129d", | 34 "Keystation\\x20Mini\\x2032", "129d", |
| 34 "Evolution Electronics, Ltd", "Keystation Mini 32", | 35 "Evolution Electronics, Ltd", "Keystation Mini 32", |
| 35 "Keystation Mini 32 Keystation Mini 32 at" | 36 "Keystation Mini 32 Keystation Mini 32 at" |
| 36 " usb-0000:00:14.0-2.4.4, full speed")); | 37 " usb-0000:00:14.0-2.4.4, full speed")); |
| 37 ASSERT_EQ("Keystation Mini 32", | 38 ASSERT_EQ("Keystation Mini 32", |
| 38 MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 39 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 39 "Keystation Mini 32", "129d", "Evolution Electronics, Ltd", | 40 "Keystation Mini 32", "129d", "Evolution Electronics, Ltd", |
| 40 "Keystation Mini 32", | 41 "Keystation Mini 32", |
| 41 "Keystation Mini 32 Keystation Mini 32 at" | 42 "Keystation Mini 32 Keystation Mini 32 at" |
| 42 " usb-0000:00:14.0-2.4.4, full speed")); | 43 " usb-0000:00:14.0-2.4.4, full speed")); |
| 43 ASSERT_EQ("Keystation Mini 32", | 44 ASSERT_EQ("Keystation Mini 32", |
| 44 MidiManagerAlsa::MidiDevice::ExtractManufacturerString( | 45 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 45 "", "", "", "Keystation Mini 32", | 46 "", "", "", "Keystation Mini 32", |
| 46 "Keystation Mini 32 Keystation Mini 32 at" | 47 "Keystation Mini 32 Keystation Mini 32 at" |
| 47 " usb-0000:00:14.0-2.4.4, full speed")); | 48 " usb-0000:00:14.0-2.4.4, full speed")); |
| 49 ASSERT_EQ("", MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 50 "", "", "", "Serial MIDI (UART16550A)", |
| 51 "Serial MIDI (UART16550A) [Soundcanvas] at 0x3f8, irq 4")); |
| 52 ASSERT_EQ("", MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( |
| 53 "", "", "", "VirMIDI", "Virtual MIDI Card 1")); |
| 54 } |
| 55 |
| 56 TEST(MidiManagerAlsaTest, JSONPortMetadata) { |
| 57 snd_seq_addr_t address; |
| 58 address.client = 1; |
| 59 address.port = 2; |
| 60 |
| 61 MidiManagerAlsa::AlsaPortMetadata input( |
| 62 "path", "bus", "id", &address, "client_name", "port_name", "card_name", |
| 63 "card_longname", MidiManagerAlsa::AlsaPortMetadata::Type::kInput); |
| 64 |
| 65 MidiManagerAlsa::AlsaPortMetadata output( |
| 66 "path", "bus", "id", &address, "client_name", "port_name", "card_name", |
| 67 "card_longname", MidiManagerAlsa::AlsaPortMetadata::Type::kOutput); |
| 68 |
| 69 ASSERT_EQ( |
| 70 "{\"bus\":\"bus\",\"cardLongname\":\"card_longname\",\"cardName\":\"card_" |
| 71 "name\"," |
| 72 "\"clientAddr\":1,\"clientName\":\"client_name\",\"id\":\"id\",\"path\":" |
| 73 "\"path\"," |
| 74 "\"portAddr\":2,\"portName\":\"port_name\",\"type\":\"input\"}", |
| 75 input.JSONValue()); |
| 76 |
| 77 ASSERT_EQ("6D6186ACF60BB2FD26B5D2E21881CF0541FDB80FAC5BDFFA95CD55739E3BC526", |
| 78 input.OpaqueKey()); |
| 79 |
| 80 ASSERT_EQ( |
| 81 "{\"bus\":\"bus\",\"cardLongname\":\"card_longname\",\"cardName\":\"card_" |
| 82 "name\"," |
| 83 "\"clientAddr\":1,\"clientName\":\"client_name\",\"id\":\"id\",\"path\":" |
| 84 "\"path\"," |
| 85 "\"portAddr\":2,\"portName\":\"port_name\",\"type\":\"output\"}", |
| 86 output.JSONValue()); |
| 87 ASSERT_EQ("747E553D40F8388A0C1C51261B82869D5EFA8A54860AAFB2F4F7437744982495", |
| 88 output.OpaqueKey()); |
| 48 } | 89 } |
| 49 | 90 |
| 50 } // namespace media | 91 } // namespace media |
| OLD | NEW |