Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/strings/string_split.h" | 6 #include "base/strings/string_split.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "net/base/mime_util.h" | 8 #include "net/base/mime_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 EXPECT_TRUE(IsStrictMediaMimeType("video/webm")); | 98 EXPECT_TRUE(IsStrictMediaMimeType("video/webm")); |
| 99 EXPECT_TRUE(IsStrictMediaMimeType("audio/webm")); | 99 EXPECT_TRUE(IsStrictMediaMimeType("audio/webm")); |
| 100 | 100 |
| 101 EXPECT_TRUE(IsStrictMediaMimeType("audio/wav")); | 101 EXPECT_TRUE(IsStrictMediaMimeType("audio/wav")); |
| 102 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav")); | 102 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav")); |
| 103 | 103 |
| 104 EXPECT_TRUE(IsStrictMediaMimeType("video/ogg")); | 104 EXPECT_TRUE(IsStrictMediaMimeType("video/ogg")); |
| 105 EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg")); | 105 EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg")); |
| 106 EXPECT_TRUE(IsStrictMediaMimeType("application/ogg")); | 106 EXPECT_TRUE(IsStrictMediaMimeType("application/ogg")); |
| 107 | 107 |
| 108 // TODO(amogh.bihani): These formats should be in stict-format_map_. This will | |
| 109 // be fixed with bug 53193 (http://crbug.com/53193)--------------------------- | |
| 110 EXPECT_FALSE(IsStrictMediaMimeType("audio/mpeg")); | 108 EXPECT_FALSE(IsStrictMediaMimeType("audio/mpeg")); |
| 111 EXPECT_FALSE(IsStrictMediaMimeType("audio/mp3")); | 109 EXPECT_FALSE(IsStrictMediaMimeType("audio/mp3")); |
| 112 EXPECT_FALSE(IsStrictMediaMimeType("audio/x-mp3")); | 110 EXPECT_FALSE(IsStrictMediaMimeType("audio/x-mp3")); |
| 113 | 111 |
| 112 // TODO(amogh.bihani): These formats should be in stict_format_map_. This will | |
| 113 // be fixed with bug 53193 (http://crbug.com/53193)--------------------------- | |
|
scherkus (not reviewing)
2014/04/10 18:30:11
nit: you can just say "This will be fixed in http:
amogh.bihani
2014/04/11 05:24:07
Done.
| |
| 114 EXPECT_FALSE(IsStrictMediaMimeType("video/mp4")); | 114 EXPECT_FALSE(IsStrictMediaMimeType("video/mp4")); |
| 115 EXPECT_FALSE(IsStrictMediaMimeType("video/x-mp4v")); | 115 EXPECT_FALSE(IsStrictMediaMimeType("video/x-m4v")); |
| 116 EXPECT_FALSE(IsStrictMediaMimeType("audio/mp4")); | 116 EXPECT_FALSE(IsStrictMediaMimeType("audio/mp4")); |
| 117 EXPECT_FALSE(IsStrictMediaMimeType("audio/x-mp4a")); | 117 EXPECT_FALSE(IsStrictMediaMimeType("audio/x-m4a")); |
|
Ryan Sleevi
2014/04/10 19:04:16
Seems like an unrelated change?
amogh.bihani
2014/04/11 05:24:07
Yes it is an unrelated change. This test was added
| |
| 118 | 118 |
| 119 EXPECT_FALSE(IsStrictMediaMimeType("application/x-mpegurl")); | 119 EXPECT_FALSE(IsStrictMediaMimeType("application/x-mpegurl")); |
| 120 EXPECT_FALSE(IsStrictMediaMimeType("application/vnd.apple.mpegurl")); | 120 EXPECT_FALSE(IsStrictMediaMimeType("application/vnd.apple.mpegurl")); |
| 121 // --------------------------------------------------------------------------- | 121 // --------------------------------------------------------------------------- |
| 122 | 122 |
| 123 EXPECT_FALSE(IsStrictMediaMimeType("video/unknown")); | 123 EXPECT_FALSE(IsStrictMediaMimeType("video/unknown")); |
| 124 EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown")); | 124 EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown")); |
| 125 EXPECT_FALSE(IsStrictMediaMimeType("application/unknown")); | 125 EXPECT_FALSE(IsStrictMediaMimeType("application/unknown")); |
| 126 EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown")); | 126 EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown")); |
| 127 } | 127 } |
| 128 | 128 |
| 129 TEST(MimeUtilTest, MimeTypeDoesNotNeedCodecs) { | |
| 130 EXPECT_TRUE(MimeTypeDoesNotNeedCodecs("audio/mpeg")); | |
| 131 EXPECT_TRUE(MimeTypeDoesNotNeedCodecs("audio/mp3")); | |
| 132 EXPECT_TRUE(MimeTypeDoesNotNeedCodecs("audio/x-mp3")); | |
| 133 | |
| 134 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("audio/webm")); | |
| 135 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("video/webm")); | |
| 136 | |
| 137 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("audio/wav")); | |
| 138 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("audio/x-wav")); | |
| 139 | |
| 140 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("audio/ogg")); | |
| 141 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("video/ogg")); | |
| 142 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("application/ogg")); | |
| 143 | |
| 144 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("audio/mp4")); | |
| 145 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("video/mp4")); | |
| 146 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("audio/x-m4a")); | |
| 147 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("video/x-m4v")); | |
| 148 | |
| 149 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("application/x-mpegurl")); | |
| 150 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("application/vnd.apple.mpegurl")); | |
| 151 | |
| 152 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("video/unknown")); | |
| 153 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("audio/unknown")); | |
| 154 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("application/unknown")); | |
| 155 EXPECT_FALSE(MimeTypeDoesNotNeedCodecs("unknown/unknown")); | |
| 156 } | |
| 157 | |
| 129 TEST(MimeUtilTest, MatchesMimeType) { | 158 TEST(MimeUtilTest, MatchesMimeType) { |
| 130 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg")); | 159 EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg")); |
| 131 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg")); | 160 EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg")); |
| 132 EXPECT_TRUE(MatchesMimeType("video/*", "video/*")); | 161 EXPECT_TRUE(MatchesMimeType("video/*", "video/*")); |
| 133 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg")); | 162 EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg")); |
| 134 EXPECT_TRUE(MatchesMimeType("application/*+xml", | 163 EXPECT_TRUE(MatchesMimeType("application/*+xml", |
| 135 "application/html+xml")); | 164 "application/html+xml")); |
| 136 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml")); | 165 EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml")); |
| 137 EXPECT_TRUE(MatchesMimeType("application/*+json", | 166 EXPECT_TRUE(MatchesMimeType("application/*+json", |
| 138 "application/x-myformat+json")); | 167 "application/x-myformat+json")); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 std::string post_data; | 382 std::string post_data; |
| 354 AddMultipartValueForUpload("value name", "value", "boundary", | 383 AddMultipartValueForUpload("value name", "value", "boundary", |
| 355 "content type", &post_data); | 384 "content type", &post_data); |
| 356 AddMultipartValueForUpload("value name", "value", "boundary", | 385 AddMultipartValueForUpload("value name", "value", "boundary", |
| 357 "", &post_data); | 386 "", &post_data); |
| 358 AddMultipartFinalDelimiterForUpload("boundary", &post_data); | 387 AddMultipartFinalDelimiterForUpload("boundary", &post_data); |
| 359 EXPECT_STREQ(ref_output, post_data.c_str()); | 388 EXPECT_STREQ(ref_output, post_data.c_str()); |
| 360 } | 389 } |
| 361 | 390 |
| 362 } // namespace net | 391 } // namespace net |
| OLD | NEW |