summaryrefslogtreecommitdiffstats
path: root/net/base/mime_util_unittest.cc
diff options
context:
space:
mode:
authorkylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-17 23:22:55 +0000
committerkylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-17 23:22:55 +0000
commite9696d5781422146bfd90766ab9307dc614c587a (patch)
treebbb2836b03cd6c6615c592892c6c698ceb248559 /net/base/mime_util_unittest.cc
parent356182ef5387439466a819e9bfd49929d5349155 (diff)
downloadchromium_src-e9696d5781422146bfd90766ab9307dc614c587a.zip
chromium_src-e9696d5781422146bfd90766ab9307dc614c587a.tar.gz
chromium_src-e9696d5781422146bfd90766ab9307dc614c587a.tar.bz2
Add codec parsing capability to MimeUtil
BUG=16636 TEST=mime_util_unittest.cc Review URL: http://codereview.chromium.org/149761 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/mime_util_unittest.cc')
-rw-r--r--net/base/mime_util_unittest.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/net/base/mime_util_unittest.cc b/net/base/mime_util_unittest.cc
index e1d7906..0300da8 100644
--- a/net/base/mime_util_unittest.cc
+++ b/net/base/mime_util_unittest.cc
@@ -96,3 +96,32 @@ TEST(MimeUtilTest, MatchesMimeType) {
EXPECT_EQ(false, net::MatchesMimeType("aaa*aaa",
"aaaaa"));
}
+
+// Note: codecs should only be a list of 2 or fewer; hence the restriction of
+// results' length to 2.
+TEST(MimeUtilTest, ParseCodecString) {
+ const struct {
+ const char* original;
+ size_t expected_size;
+ const char* results[2];
+ } tests[] = {
+ { "\"bogus\"", 1, { "bogus" } },
+ { "0", 1, { "0" } },
+ { "avc1.42E01E, mp4a.40.2", 2, { "avc1", "mp4a" } },
+ { "\"mp4v.20.240, mp4a.40.2\"", 2, { "mp4v", "mp4a" } },
+ { "mp4v.20.8, samr", 2, { "mp4v", "samr" } },
+ { "\"theora, vorbis\"", 2, { "theora", "vorbis" } },
+ { "", 1, { "" } },
+ { "\"\"", 1, { "" } },
+ { ",", 2, { "", "" } },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
+ std::vector<std::string> codecs_out;
+ net::ParseCodecString(tests[i].original, &codecs_out);
+ EXPECT_EQ(tests[i].expected_size, codecs_out.size());
+ for (size_t j = 0; j < tests[i].expected_size; ++j) {
+ EXPECT_EQ(tests[i].results[j], codecs_out[j]);
+ }
+ }
+}