Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / media / midi / midi_manager_alsa_unittest.cc
blob9aaf400f06bda8275ba0f0a40ae05a3c17b7ea3c
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
3 // found in the LICENSE file.
5 #include "media/midi/midi_manager_alsa.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace media {
11 TEST(MidiManagerAlsaTest, ExtractManufacturer) {
12 ASSERT_EQ("My\\x20Vendor",
13 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
14 "My\\x20Vendor", "1234", "My Vendor, Inc.", "Card",
15 "My Vendor Inc Card at bus"));
16 ASSERT_EQ("My Vendor", MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
17 "My Vendor", "1234", "My Vendor, Inc.", "Card",
18 "My Vendor Inc Card at bus"));
19 ASSERT_EQ("My Vendor, Inc.",
20 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
21 "1234", "1234", "My Vendor, Inc.", "Card",
22 "My Vendor Inc Card at bus"));
23 ASSERT_EQ("My Vendor Inc",
24 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
25 "1234", "1234", "", "Card", "My Vendor Inc Card at bus"));
26 ASSERT_EQ("My Vendor Inc",
27 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
28 "", "", "", "Card", "My Vendor Inc Card at bus"));
29 ASSERT_EQ("", MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
30 "1234", "1234", "", "Card", "Longname"));
31 ASSERT_EQ("Keystation\\x20Mini\\x2032",
32 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
33 "Keystation\\x20Mini\\x2032", "129d",
34 "Evolution Electronics, Ltd", "Keystation Mini 32",
35 "Keystation Mini 32 Keystation Mini 32 at"
36 " usb-0000:00:14.0-2.4.4, full speed"));
37 ASSERT_EQ("Keystation Mini 32",
38 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
39 "Keystation Mini 32", "129d", "Evolution Electronics, Ltd",
40 "Keystation Mini 32",
41 "Keystation Mini 32 Keystation Mini 32 at"
42 " usb-0000:00:14.0-2.4.4, full speed"));
43 ASSERT_EQ("Keystation Mini 32",
44 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
45 "", "", "", "Keystation Mini 32",
46 "Keystation Mini 32 Keystation Mini 32 at"
47 " usb-0000:00:14.0-2.4.4, full speed"));
48 ASSERT_EQ("", MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
49 "", "", "", "Serial MIDI (UART16550A)",
50 "Serial MIDI (UART16550A) [Soundcanvas] at 0x3f8, irq 4"));
51 ASSERT_EQ("", MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
52 "", "", "", "VirMIDI", "Virtual MIDI Card 1"));
53 ASSERT_EQ("C-Media Electronics Inc",
54 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
55 "", "0x13f6", "C-Media Electronics Inc", "C-Media CMI8738 MIDI",
56 "C-Media CMI8738 (model 55) at 0xd000, irq 19"));
57 ASSERT_EQ("C-Media Electronics Inc",
58 MidiManagerAlsa::AlsaCard::ExtractManufacturerString(
59 "", "0x13f6", "C-Media Electronics Inc", "C-Media CMI8738 FM",
60 "C-Media CMI8738 (model 55) at 0xd000, irq 19"));
63 TEST(MidiManagerAlsaTest, JSONPortMetadata) {
64 snd_seq_addr_t address;
65 address.client = 1;
66 address.port = 2;
68 MidiManagerAlsa::AlsaPortMetadata input(
69 "path", "bus", "id", &address, "client_name", "port_name", "card_name",
70 "card_longname", MidiManagerAlsa::AlsaPortMetadata::Type::kInput);
72 MidiManagerAlsa::AlsaPortMetadata output(
73 "path", "bus", "id", &address, "client_name", "port_name", "card_name",
74 "card_longname", MidiManagerAlsa::AlsaPortMetadata::Type::kOutput);
76 MidiManagerAlsa::AlsaPortMetadata partial(
77 "", "", "", &address, "client_name", "port_name", "card_name",
78 "card_longname", MidiManagerAlsa::AlsaPortMetadata::Type::kOutput);
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\":\"input\"}",
86 input.JSONValue());
88 ASSERT_EQ("6D6186ACF60BB2FD26B5D2E21881CF0541FDB80FAC5BDFFA95CD55739E3BC526",
89 input.OpaqueKey());
91 ASSERT_EQ(
92 "{\"bus\":\"bus\",\"cardLongname\":\"card_longname\",\"cardName\":\"card_"
93 "name\","
94 "\"clientAddr\":1,\"clientName\":\"client_name\",\"id\":\"id\",\"path\":"
95 "\"path\","
96 "\"portAddr\":2,\"portName\":\"port_name\",\"type\":\"output\"}",
97 output.JSONValue());
98 ASSERT_EQ("747E553D40F8388A0C1C51261B82869D5EFA8A54860AAFB2F4F7437744982495",
99 output.OpaqueKey());
101 ASSERT_EQ(
102 "{\"cardLongname\":\"card_longname\",\"cardName\":\"card_"
103 "name\","
104 "\"clientAddr\":1,\"clientName\":\"client_name\","
105 "\"portAddr\":2,\"portName\":\"port_name\",\"type\":\"output\"}",
106 partial.JSONValue());
107 ASSERT_EQ("51DF7AF543B5BDF83C0B8DE3A00A0BC588DDFCA8600671EF7D59828B40DFF6D3",
108 partial.OpaqueKey());
111 } // namespace media