| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "googleurl/src/gurl.h" | 6 #include "googleurl/src/gurl.h" |
| 7 #include "net/base/mime_sniffer.h" | 7 #include "net/base/mime_sniffer.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 "http://www.example.com/foo", | 74 "http://www.example.com/foo", |
| 75 "text/plain", "image/gif" }, | 75 "text/plain", "image/gif" }, |
| 76 { "Gif87a\x1F\x83\x94", sizeof("Gif87a\xAF\x83\x94")-1, | 76 { "Gif87a\x1F\x83\x94", sizeof("Gif87a\xAF\x83\x94")-1, |
| 77 "http://www.example.com/foo?param=tt.gif", | 77 "http://www.example.com/foo?param=tt.gif", |
| 78 "", "application/octet-stream" }, | 78 "", "application/octet-stream" }, |
| 79 { "%!PS-Adobe-3.0", sizeof("%!PS-Adobe-3.0")-1, | 79 { "%!PS-Adobe-3.0", sizeof("%!PS-Adobe-3.0")-1, |
| 80 "http://www.example.com/foo", | 80 "http://www.example.com/foo", |
| 81 "text/plain", "text/plain" }, | 81 "text/plain", "text/plain" }, |
| 82 { "\x89" "PNG\x0D\x0A\x1A\x0A", sizeof("\x89" "PNG\x0D\x0A\x1A\x0A")-1, | 82 { "\x89" "PNG\x0D\x0A\x1A\x0A", sizeof("\x89" "PNG\x0D\x0A\x1A\x0A")-1, |
| 83 "http://www.example.com/foo", | 83 "http://www.example.com/foo", |
| 84 "application/octet-stream", "image/png" }, | 84 "application/octet-stream", "application/octet-stream" }, |
| 85 { "\xFF\xD8\xFF\x23\x49\xAF", sizeof("\xFF\xD8\xFF\x23\x49\xAF")-1, | 85 { "\xFF\xD8\xFF\x23\x49\xAF", sizeof("\xFF\xD8\xFF\x23\x49\xAF")-1, |
| 86 "http://www.example.com/foo", | 86 "http://www.example.com/foo", |
| 87 "", "image/jpeg" }, | 87 "", "image/jpeg" }, |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 TestArray(tests, arraysize(tests)); | 90 TestArray(tests, arraysize(tests)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 TEST(MimeSnifferTest, ChromeExtensionsTest) { | 93 TEST(MimeSnifferTest, ChromeExtensionsTest) { |
| 94 SnifferTest tests[] = { | 94 SnifferTest tests[] = { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // Make a large input, with 600 bytes of "x". | 365 // Make a large input, with 600 bytes of "x". |
| 366 std::string content; | 366 std::string content; |
| 367 content.resize(600); | 367 content.resize(600); |
| 368 std::fill(content.begin(), content.end(), 'x'); | 368 std::fill(content.begin(), content.end(), 'x'); |
| 369 | 369 |
| 370 // content.size() >= kMaxBytesToSniff (512) so the sniff is unambiguous. | 370 // content.size() >= kMaxBytesToSniff (512) so the sniff is unambiguous. |
| 371 std::string mime_type; | 371 std::string mime_type; |
| 372 EXPECT_TRUE(net::SniffMimeType(content.data(), content.size(), GURL(), | 372 EXPECT_TRUE(net::SniffMimeType(content.data(), content.size(), GURL(), |
| 373 "text/xml", &mime_type)); | 373 "text/xml", &mime_type)); |
| 374 } | 374 } |
| OLD | NEW |