Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Unified Diff: media/midi/midi_manager_alsa_unittest.cc

Issue 968663004: Improve MidiManagerAlsa manufacturer reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@udev
Patch Set: Address reviewer comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« media/midi/midi_manager_alsa.cc ('K') | « media/midi/midi_manager_alsa.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/midi_manager_alsa_unittest.cc
diff --git a/media/midi/midi_manager_alsa_unittest.cc b/media/midi/midi_manager_alsa_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e32d4d91d3c93a90775141291c08e2d45daf40a9
--- /dev/null
+++ b/media/midi/midi_manager_alsa_unittest.cc
@@ -0,0 +1,71 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/midi/midi_manager_alsa.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media {
+
+TEST(MidiManagerAlsaTest, UdevEscape) {
+ ASSERT_EQ(R"()", MidiManagerAlsa::UnescapeUdev(R"()"));
+ ASSERT_EQ(R"(\)", MidiManagerAlsa::UnescapeUdev(R"(\x5c)"));
+ ASSERT_EQ(R"(\x5)", MidiManagerAlsa::UnescapeUdev(R"(\x5)"));
+ ASSERT_EQ(R"(049f)", MidiManagerAlsa::UnescapeUdev(R"(049f)"));
+ ASSERT_EQ(R"(HD Pro Webcam C920)",
+ MidiManagerAlsa::UnescapeUdev(R"(HD\x20Pro\x20Webcam\x20C920)"));
+ ASSERT_EQ(R"(E-MU Systems,Inc.)",
+ MidiManagerAlsa::UnescapeUdev(R"(E-MU\x20Systems\x2cInc.)"));
+}
+
+TEST(MidiManagerAlsaTest, ExtractManufacturer) {
+ ASSERT_EQ("My Vendor",
+ MidiManagerAlsa::ExtractManufacturer(R"(My\x20Vendor)",
+ "1234",
+ "My Vendor, Inc.",
+ "Card",
+ "My Vendor Inc Card at bus"));
+ ASSERT_EQ("My Vendor, Inc.",
+ MidiManagerAlsa::ExtractManufacturer("1234",
+ "1234",
+ "My Vendor, Inc.",
+ "Card",
+ "My Vendor Inc Card at bus"));
+ ASSERT_EQ("My Vendor Inc",
+ MidiManagerAlsa::ExtractManufacturer("1234",
+ "1234",
+ "",
+ "Card",
+ "My Vendor Inc Card at bus"));
+ ASSERT_EQ("My Vendor Inc",
+ MidiManagerAlsa::ExtractManufacturer("",
+ "",
+ "",
+ "Card",
+ "My Vendor Inc Card at bus"));
+ ASSERT_EQ("",
+ MidiManagerAlsa::ExtractManufacturer("1234",
+ "1234",
+ "",
+ "Card",
+ "Longname"));
+ ASSERT_EQ("Keystation Mini 32",
+ MidiManagerAlsa::ExtractManufacturer(
+ R"(Keystation\x20Mini\x2032)",
+ "129d",
+ "Evolution Electronics, Ltd",
+ "Keystation Mini 32",
+ "Keystation Mini 32 Keystation Mini 32 at"
+ " usb-0000:00:14.0-2.4.4, full speed"));
+ ASSERT_EQ("Keystation Mini 32",
+ MidiManagerAlsa::ExtractManufacturer(
+ "",
+ "",
+ "",
+ "Keystation Mini 32",
+ "Keystation Mini 32 Keystation Mini 32 at"
+ " usb-0000:00:14.0-2.4.4, full speed"));
+}
+
+} // namespace media
« media/midi/midi_manager_alsa.cc ('K') | « media/midi/midi_manager_alsa.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698