| 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::AlsaRawmidi::ExtractManufacturerString( | 13 MidiManagerAlsa::AlsaCard::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", | 16 ASSERT_EQ("My Vendor", MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 17 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 17 "My Vendor", "1234", "My Vendor, Inc.", "Card", |
| 18 "My Vendor", "1234", "My Vendor, Inc.", "Card", | 18 "My Vendor Inc Card at bus")); |
| 19 "My Vendor Inc Card at bus")); | |
| 20 ASSERT_EQ("My Vendor, Inc.", | 19 ASSERT_EQ("My Vendor, Inc.", |
| 21 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 20 MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 22 "1234", "1234", "My Vendor, Inc.", "Card", | 21 "1234", "1234", "My Vendor, Inc.", "Card", |
| 23 "My Vendor Inc Card at bus")); | 22 "My Vendor Inc Card at bus")); |
| 24 ASSERT_EQ("My Vendor Inc", | 23 ASSERT_EQ("My Vendor Inc", |
| 25 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 24 MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 26 "1234", "1234", "", "Card", "My Vendor Inc Card at bus")); | 25 "1234", "1234", "", "Card", "My Vendor Inc Card at bus")); |
| 27 ASSERT_EQ("My Vendor Inc", | 26 ASSERT_EQ("My Vendor Inc", |
| 28 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 27 MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 29 "", "", "", "Card", "My Vendor Inc Card at bus")); | 28 "", "", "", "Card", "My Vendor Inc Card at bus")); |
| 30 ASSERT_EQ("", MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 29 ASSERT_EQ("", MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 31 "1234", "1234", "", "Card", "Longname")); | 30 "1234", "1234", "", "Card", "Longname")); |
| 32 ASSERT_EQ("Keystation\\x20Mini\\x2032", | 31 ASSERT_EQ("Keystation\\x20Mini\\x2032", |
| 33 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 32 MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 34 "Keystation\\x20Mini\\x2032", "129d", | 33 "Keystation\\x20Mini\\x2032", "129d", |
| 35 "Evolution Electronics, Ltd", "Keystation Mini 32", | 34 "Evolution Electronics, Ltd", "Keystation Mini 32", |
| 36 "Keystation Mini 32 Keystation Mini 32 at" | 35 "Keystation Mini 32 Keystation Mini 32 at" |
| 37 " usb-0000:00:14.0-2.4.4, full speed")); | 36 " usb-0000:00:14.0-2.4.4, full speed")); |
| 38 ASSERT_EQ("Keystation Mini 32", | 37 ASSERT_EQ("Keystation Mini 32", |
| 39 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 38 MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 40 "Keystation Mini 32", "129d", "Evolution Electronics, Ltd", | 39 "Keystation Mini 32", "129d", "Evolution Electronics, Ltd", |
| 41 "Keystation Mini 32", | 40 "Keystation Mini 32", |
| 42 "Keystation Mini 32 Keystation Mini 32 at" | 41 "Keystation Mini 32 Keystation Mini 32 at" |
| 43 " usb-0000:00:14.0-2.4.4, full speed")); | 42 " usb-0000:00:14.0-2.4.4, full speed")); |
| 44 ASSERT_EQ("Keystation Mini 32", | 43 ASSERT_EQ("Keystation Mini 32", |
| 45 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 44 MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 46 "", "", "", "Keystation Mini 32", | 45 "", "", "", "Keystation Mini 32", |
| 47 "Keystation Mini 32 Keystation Mini 32 at" | 46 "Keystation Mini 32 Keystation Mini 32 at" |
| 48 " usb-0000:00:14.0-2.4.4, full speed")); | 47 " usb-0000:00:14.0-2.4.4, full speed")); |
| 49 ASSERT_EQ("", MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 48 ASSERT_EQ("", MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 50 "", "", "", "Serial MIDI (UART16550A)", | 49 "", "", "", "Serial MIDI (UART16550A)", |
| 51 "Serial MIDI (UART16550A) [Soundcanvas] at 0x3f8, irq 4")); | 50 "Serial MIDI (UART16550A) [Soundcanvas] at 0x3f8, irq 4")); |
| 52 ASSERT_EQ("", MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 51 ASSERT_EQ("", MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 53 "", "", "", "VirMIDI", "Virtual MIDI Card 1")); | 52 "", "", "", "VirMIDI", "Virtual MIDI Card 1")); |
| 54 ASSERT_EQ("C-Media Electronics Inc", | 53 ASSERT_EQ("C-Media Electronics Inc", |
| 55 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 54 MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 56 "", "0x13f6", "C-Media Electronics Inc", "C-Media CMI8738 MIDI", | 55 "", "0x13f6", "C-Media Electronics Inc", "C-Media CMI8738 MIDI", |
| 57 "C-Media CMI8738 (model 55) at 0xd000, irq 19")); | 56 "C-Media CMI8738 (model 55) at 0xd000, irq 19")); |
| 58 ASSERT_EQ("C-Media Electronics Inc", | 57 ASSERT_EQ("C-Media Electronics Inc", |
| 59 MidiManagerAlsa::AlsaRawmidi::ExtractManufacturerString( | 58 MidiManagerAlsa::AlsaCard::ExtractManufacturerString( |
| 60 "", "0x13f6", "C-Media Electronics Inc", "C-Media CMI8738 FM", | 59 "", "0x13f6", "C-Media Electronics Inc", "C-Media CMI8738 FM", |
| 61 "C-Media CMI8738 (model 55) at 0xd000, irq 19")); | 60 "C-Media CMI8738 (model 55) at 0xd000, irq 19")); |
| 62 } | 61 } |
| 63 | 62 |
| 64 TEST(MidiManagerAlsaTest, JSONPortMetadata) { | 63 TEST(MidiManagerAlsaTest, JSONPortMetadata) { |
| 65 snd_seq_addr_t address; | 64 snd_seq_addr_t address; |
| 66 address.client = 1; | 65 address.client = 1; |
| 67 address.port = 2; | 66 address.port = 2; |
| 68 | 67 |
| 69 MidiManagerAlsa::AlsaPortMetadata input( | 68 MidiManagerAlsa::AlsaPortMetadata input( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 "{\"cardLongname\":\"card_longname\",\"cardName\":\"card_" | 102 "{\"cardLongname\":\"card_longname\",\"cardName\":\"card_" |
| 104 "name\"," | 103 "name\"," |
| 105 "\"clientAddr\":1,\"clientName\":\"client_name\"," | 104 "\"clientAddr\":1,\"clientName\":\"client_name\"," |
| 106 "\"portAddr\":2,\"portName\":\"port_name\",\"type\":\"output\"}", | 105 "\"portAddr\":2,\"portName\":\"port_name\",\"type\":\"output\"}", |
| 107 partial.JSONValue()); | 106 partial.JSONValue()); |
| 108 ASSERT_EQ("51DF7AF543B5BDF83C0B8DE3A00A0BC588DDFCA8600671EF7D59828B40DFF6D3", | 107 ASSERT_EQ("51DF7AF543B5BDF83C0B8DE3A00A0BC588DDFCA8600671EF7D59828B40DFF6D3", |
| 109 partial.OpaqueKey()); | 108 partial.OpaqueKey()); |
| 110 } | 109 } |
| 111 | 110 |
| 112 } // namespace media | 111 } // namespace media |
| OLD | NEW |