aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-04-13 16:11:10 -0500
committerbors-servo <metajack+bors@gmail.com>2015-04-13 16:11:10 -0500
commitf67749fc7d9eab13086fbea32b684f3a8eff6688 (patch)
treeb3642241223a702bfd1c9b93814add77417d1aab
parent1f9c2f9b34dede8182f45655b03380f8c26f3475 (diff)
parentd0469dfaf3024897e0e51b69eb8279d6c0616c69 (diff)
downloadservo-f67749fc7d9eab13086fbea32b684f3a8eff6688.tar.gz
servo-f67749fc7d9eab13086fbea32b684f3a8eff6688.zip
Auto merge of #5671 - zerokarmaleft:move_mime_classifier_tests, r=SimonSapin
Closes #5667.
-rw-r--r--components/net/lib.rs2
-rw-r--r--components/net/mime_classifier.rs440
-rw-r--r--tests/unit/net/mime_classifier.rs433
-rw-r--r--tests/unit/net/mod.rs1
4 files changed, 438 insertions, 438 deletions
diff --git a/components/net/lib.rs b/components/net/lib.rs
index d4e69232779..8de25245a56 100644
--- a/components/net/lib.rs
+++ b/components/net/lib.rs
@@ -45,7 +45,7 @@ pub mod image_cache_task;
pub mod pub_domains;
pub mod resource_task;
pub mod storage_task;
-mod mime_classifier;
+pub mod mime_classifier;
/// An implementation of the [Fetch spec](http://fetch.spec.whatwg.org/)
pub mod fetch {
diff --git a/components/net/mime_classifier.rs b/components/net/mime_classifier.rs
index 6501abdb6bb..fabfdae9e8a 100644
--- a/components/net/mime_classifier.rs
+++ b/components/net/mime_classifier.rs
@@ -122,7 +122,7 @@ impl MIMEClassifier {
}
}
-fn as_string_option(tup: Option<(&'static str, &'static str)>) -> Option<(String,String)> {
+pub fn as_string_option(tup: Option<(&'static str, &'static str)>) -> Option<(String,String)> {
tup.map(|(a, b)| (a.to_owned(), b.to_owned()))
}
@@ -223,10 +223,10 @@ impl MIMEChecker for TagTerminatedByteMatcher {
}
}
}
-struct Mp4Matcher;
+pub struct Mp4Matcher;
impl Mp4Matcher {
- fn matches(&self,data: &Vec<u8>) -> bool {
+ pub fn matches(&self,data: &Vec<u8>) -> bool {
if data.len() < 12 {
return false;
}
@@ -979,437 +979,3 @@ impl ByteMatcher {
}
}
}
-
-#[cfg(test)]
-mod tests {
-
- use std::old_io::File;
- use std::os;
- use super::Mp4Matcher;
- use super::MIMEClassifier;
- use super::as_string_option;
-
- #[test]
- fn test_sniff_mp4_matcher() {
- let matcher = Mp4Matcher;
-
- let p = Path::new("../../tests/content/parsable_mime/video/mp4/test.mp4");
- let mut file = File::open(&p);
- let read_result = file.read_to_end();
- match read_result {
- Ok(data) => {
- println!("Data Length {:?}",data.len());
- if !matcher.matches(&data) {
- panic!("Didn't read mime type")
- }
- },
- Err(e) => panic!("Couldn't read from file with error {}",e)
- }
- }
-
- #[cfg(test)]
- fn test_sniff_full(filename_orig: &Path,type_string: &str,subtype_string: &str,
- supplied_type: Option<(&'static str,&'static str)>){
- let current_working_directory = os::getcwd().unwrap();
- println!("The current directory is {}", current_working_directory.display());
-
- let mut filename = Path::new("../../tests/content/parsable_mime/");
-
- filename.push(filename_orig);
- let classifier = MIMEClassifier::new();
-
- let mut file = File::open(&filename);
- let read_result = file.read_to_end();
- match read_result {
- Ok(data) => {
- match classifier.classify(false, false, &as_string_option(supplied_type), &data) {
- Some((parsed_type, parsed_subtp)) => {
- if (parsed_type.as_slice() != type_string) ||
- (parsed_subtp.as_slice() != subtype_string) {
- panic!("File {} parsed incorrectly should be {}/{}, parsed as {}/{}",
- filename.as_str().unwrap(), type_string, subtype_string,
- parsed_type, parsed_subtp);
- }
- }
- None => panic!("No classification found for {} with supplied type {:?}",
- filename.as_str().unwrap(), supplied_type),
- }
- }
- Err(e) => panic!("Couldn't read from file {} with error {}",
- filename.as_str().unwrap(), e),
- }
- }
-
- #[cfg(test)]
- fn test_sniff_classification(file: &str,type_string: &str,subtype_string: &str,
- supplied_type: Option<(&'static str,&'static str)>){
- let mut x = Path::new("./");
- x.push(type_string);
- x.push(subtype_string);
- x.push(file);
- test_sniff_full(&x,type_string,subtype_string,supplied_type);
- }
- #[cfg(test)]
- fn test_sniff_classification_sup(file: &str,type_string: &'static str,subtype_string: &str) {
- test_sniff_classification(file,type_string,subtype_string, None);
- let class_type = Some((type_string, ""));
- test_sniff_classification(file,type_string,subtype_string,class_type);
- }
-
- #[test]
- fn test_sniff_x_icon() {
- test_sniff_classification_sup("test.ico", "image", "x-icon");
- }
-
- #[test]
- fn test_sniff_x_icon_cursor() {
- test_sniff_classification_sup("test_cursor.ico", "image", "x-icon");
- }
-
- #[test]
- fn test_sniff_bmp() {
- test_sniff_classification_sup("test.bmp", "image", "bmp");
- }
-
- #[test]
- fn test_sniff_gif87a() {
- test_sniff_classification_sup("test87a", "image", "gif");
- }
-
- #[test]
- fn test_sniff_gif89a() {
- test_sniff_classification_sup("test89a.gif", "image", "gif");
- }
-
- #[test]
- fn test_sniff_webp() {
- test_sniff_classification_sup("test.webp", "image", "webp");
- }
-
- #[test]
- fn test_sniff_png() {
- test_sniff_classification_sup("test.png", "image", "png");
- }
-
- #[test]
- fn test_sniff_jpg() {
- test_sniff_classification_sup("test.jpg", "image", "jpeg");
- }
-
- #[test]
- fn test_sniff_webm() {
- test_sniff_classification_sup("test.webm", "video", "webm");
- }
-
- #[test]
- fn test_sniff_mp4() {
- test_sniff_classification_sup("test.mp4", "video", "mp4");
- }
-
- #[test]
- fn test_sniff_avi() {
- test_sniff_classification_sup("test.avi", "video", "avi");
- }
-
- #[test]
- fn test_sniff_basic() {
- test_sniff_classification_sup("test.au", "audio", "basic");
- }
-
- #[test]
- fn test_sniff_aiff() {
- test_sniff_classification_sup("test.aif", "audio", "aiff");
- }
-
- #[test]
- fn test_sniff_mpeg() {
- test_sniff_classification_sup("test.mp3", "audio", "mpeg");
- }
-
- #[test]
- fn test_sniff_midi() {
- test_sniff_classification_sup("test.mid", "audio", "midi");
- }
-
- #[test]
- fn test_sniff_wave() {
- test_sniff_classification_sup("test.wav", "audio", "wave");
- }
-
- #[test]
- fn test_sniff_ogg() {
- test_sniff_classification("small.ogg", "application", "ogg", None);
- test_sniff_classification("small.ogg", "application", "ogg", Some(("audio", "")));
- }
-
- #[test]
- #[should_fail]
- fn test_sniff_vsn_ms_fontobject() {
- test_sniff_classification_sup("vnd.ms-fontobject", "application", "vnd.ms-fontobject");
- }
-
- #[test]
- #[should_fail]
- fn test_sniff_true_type() {
- test_sniff_full(&Path::new("unknown/true_type.ttf"), "(TrueType)", "", None);
- }
-
- #[test]
- #[should_fail]
- fn test_sniff_open_type() {
- test_sniff_full(&Path::new("unknown/open_type"), "(OpenType)", "", None);
- }
-
- #[test]
- #[should_fail]
- fn test_sniff_true_type_collection() {
- test_sniff_full(&Path::new("unknown/true_type_collection.ttc"), "(TrueType Collection)", "", None);
- }
-
- #[test]
- #[should_fail]
- fn test_sniff_woff() {
- test_sniff_classification_sup("test.wof", "application", "font-woff");
- }
-
- #[test]
- fn test_sniff_gzip() {
- test_sniff_classification("test.gz", "application", "x-gzip", None);
- }
-
- #[test]
- fn test_sniff_zip() {
- test_sniff_classification("test.zip", "application", "zip", None);
- }
-
- #[test]
- fn test_sniff_rar() {
- test_sniff_classification("test.rar", "application", "x-rar-compressed", None);
- }
-
- #[test]
- fn test_sniff_text_html_doctype_20() {
- test_sniff_classification("text_html_doctype_20.html", "text", "html", None);
- test_sniff_classification("text_html_doctype_20_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_doctype_3e() {
- test_sniff_classification("text_html_doctype_3e.html", "text", "html", None);
- test_sniff_classification("text_html_doctype_3e_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_page_20() {
- test_sniff_classification("text_html_page_20.html", "text", "html", None);
- test_sniff_classification("text_html_page_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_page_3e() {
- test_sniff_classification("text_html_page_3e.html", "text", "html", None);
- test_sniff_classification("text_html_page_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_head_20() {
- test_sniff_classification("text_html_head_20.html", "text", "html", None);
- test_sniff_classification("text_html_head_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_head_3e() {
- test_sniff_classification("text_html_head_3e.html", "text", "html", None);
- test_sniff_classification("text_html_head_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_script_20() {
- test_sniff_classification("text_html_script_20.html", "text", "html", None);
- test_sniff_classification("text_html_script_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_script_3e() {
- test_sniff_classification("text_html_script_3e.html", "text", "html", None);
- test_sniff_classification("text_html_script_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_iframe_20() {
- test_sniff_classification("text_html_iframe_20.html", "text", "html", None);
- test_sniff_classification("text_html_iframe_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_iframe_3e() {
- test_sniff_classification("text_html_iframe_3e.html", "text", "html", None);
- test_sniff_classification("text_html_iframe_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_h1_20() {
- test_sniff_classification("text_html_h1_20.html", "text", "html", None);
- test_sniff_classification("text_html_h1_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_h1_3e() {
- test_sniff_classification("text_html_h1_3e.html", "text", "html", None);
- test_sniff_classification("text_html_h1_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_div_20() {
- test_sniff_classification("text_html_div_20.html", "text", "html", None);
- test_sniff_classification("text_html_div_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_div_3e() {
- test_sniff_classification("text_html_div_3e.html", "text", "html", None);
- test_sniff_classification("text_html_div_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_font_20() {
- test_sniff_classification("text_html_font_20.html", "text", "html", None);
- test_sniff_classification("text_html_font_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_font_3e() {
- test_sniff_classification("text_html_font_3e.html", "text", "html", None);
- test_sniff_classification("text_html_font_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_table_20() {
- test_sniff_classification("text_html_table_20.html", "text", "html", None);
- test_sniff_classification("text_html_table_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_table_3e() {
- test_sniff_classification("text_html_table_3e.html", "text", "html", None);
- test_sniff_classification("text_html_table_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_a_20() {
- test_sniff_classification("text_html_a_20.html", "text", "html", None);
- test_sniff_classification("text_html_a_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_a_3e() {
- test_sniff_classification("text_html_a_3e.html", "text", "html", None);
- test_sniff_classification("text_html_a_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_style_20() {
- test_sniff_classification("text_html_style_20.html", "text", "html", None);
- test_sniff_classification("text_html_style_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_style_3e() {
- test_sniff_classification("text_html_style_3e.html", "text", "html", None);
- test_sniff_classification("text_html_style_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_title_20() {
- test_sniff_classification("text_html_title_20.html", "text", "html", None);
- test_sniff_classification("text_html_title_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_title_3e() {
- test_sniff_classification("text_html_title_3e.html", "text", "html", None);
- test_sniff_classification("text_html_title_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_b_20() {
- test_sniff_classification("text_html_b_20.html", "text", "html", None);
- test_sniff_classification("text_html_b_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_b_3e() {
- test_sniff_classification("text_html_b_3e.html", "text", "html", None);
- test_sniff_classification("text_html_b_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_body_20() {
- test_sniff_classification("text_html_body_20.html", "text", "html", None);
- test_sniff_classification("text_html_body_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_body_3e() {
- test_sniff_classification("text_html_body_3e.html", "text", "html", None);
- test_sniff_classification("text_html_body_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_br_20() {
- test_sniff_classification("text_html_br_20.html", "text", "html", None);
- test_sniff_classification("text_html_br_20_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_br_3e() {
- test_sniff_classification("text_html_br_3e.html", "text", "html", None);
- test_sniff_classification("text_html_br_3e_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_p_20() {
- test_sniff_classification("text_html_p_20.html", "text", "html", None);
- test_sniff_classification("text_html_p_20_u.html", "text", "html", None);
- }
- #[test]
- fn test_sniff_text_html_p_3e() {
- test_sniff_classification("text_html_p_3e.html", "text", "html", None);
- test_sniff_classification("text_html_p_3e_u.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_comment_20() {
- test_sniff_classification("text_html_comment_20.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_text_html_comment_3e() {
- test_sniff_classification("text_html_comment_3e.html", "text", "html", None);
- }
-
- #[test]
- fn test_sniff_xml() {
- test_sniff_classification("test.xml", "text", "xml", None);
- }
-
- #[test]
- fn test_sniff_pdf() {
- test_sniff_classification("test.pdf", "application", "pdf", None);
- }
-
- #[test]
- fn test_sniff_postscript() {
- test_sniff_classification("test.ps", "application", "postscript", None);
- }
-
- #[test]
- fn test_sniff_utf_16be_bom() {
- test_sniff_classification("utf16bebom.txt", "text", "plain", None);
- }
-
- #[test]
- fn test_sniff_utf_16le_bom() {
- test_sniff_classification("utf16lebom.txt", "text", "plain", None);
- }
-
- #[test]
- fn test_sniff_utf_8_bom() {
- test_sniff_classification("utf8bom.txt", "text", "plain", None);
- }
-
- #[test]
- fn test_sniff_rss_feed() {
- test_sniff_full(&Path::new("text/xml/feed.rss"), "application", "rss+xml", Some(("text", "html")));
- }
-
- #[test]
- fn test_sniff_atom_feed() {
- test_sniff_full(&Path::new("text/xml/feed.atom"), "application", "atom+xml", Some(("text", "html")));
- }
-}
diff --git a/tests/unit/net/mime_classifier.rs b/tests/unit/net/mime_classifier.rs
new file mode 100644
index 00000000000..eb827b6fc15
--- /dev/null
+++ b/tests/unit/net/mime_classifier.rs
@@ -0,0 +1,433 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use std::old_io::File;
+use std::os;
+use net::mime_classifier::Mp4Matcher;
+use net::mime_classifier::MIMEClassifier;
+use net::mime_classifier::as_string_option;
+
+#[test]
+fn test_sniff_mp4_matcher() {
+ let matcher = Mp4Matcher;
+
+ let p = Path::new("../../tests/content/parsable_mime/video/mp4/test.mp4");
+ let mut file = File::open(&p);
+ let read_result = file.read_to_end();
+ match read_result {
+ Ok(data) => {
+ println!("Data Length {:?}",data.len());
+ if !matcher.matches(&data) {
+ panic!("Didn't read mime type")
+ }
+ },
+ Err(e) => panic!("Couldn't read from file with error {}",e)
+ }
+}
+
+#[cfg(test)]
+fn test_sniff_full(filename_orig: &Path,type_string: &str,subtype_string: &str,
+ supplied_type: Option<(&'static str,&'static str)>){
+ let current_working_directory = os::getcwd().unwrap();
+ println!("The current directory is {}", current_working_directory.display());
+
+ let mut filename = Path::new("../../tests/content/parsable_mime/");
+
+ filename.push(filename_orig);
+ let classifier = MIMEClassifier::new();
+
+ let mut file = File::open(&filename);
+ let read_result = file.read_to_end();
+ match read_result {
+ Ok(data) => {
+ match classifier.classify(false, false, &as_string_option(supplied_type), &data) {
+ Some((parsed_type, parsed_subtp)) => {
+ if (parsed_type.as_slice() != type_string) ||
+ (parsed_subtp.as_slice() != subtype_string) {
+ panic!("File {} parsed incorrectly should be {}/{}, parsed as {}/{}",
+ filename.as_str().unwrap(), type_string, subtype_string,
+ parsed_type, parsed_subtp);
+ }
+ }
+ None => panic!("No classification found for {} with supplied type {:?}",
+ filename.as_str().unwrap(), supplied_type),
+ }
+ }
+ Err(e) => panic!("Couldn't read from file {} with error {}",
+ filename.as_str().unwrap(), e),
+ }
+}
+
+#[cfg(test)]
+fn test_sniff_classification(file: &str,type_string: &str,subtype_string: &str,
+ supplied_type: Option<(&'static str,&'static str)>){
+ let mut x = Path::new("./");
+ x.push(type_string);
+ x.push(subtype_string);
+ x.push(file);
+ test_sniff_full(&x,type_string,subtype_string,supplied_type);
+}
+#[cfg(test)]
+fn test_sniff_classification_sup(file: &str,type_string: &'static str,subtype_string: &str) {
+ test_sniff_classification(file,type_string,subtype_string, None);
+ let class_type = Some((type_string, ""));
+ test_sniff_classification(file,type_string,subtype_string,class_type);
+}
+
+#[test]
+fn test_sniff_x_icon() {
+ test_sniff_classification_sup("test.ico", "image", "x-icon");
+}
+
+#[test]
+fn test_sniff_x_icon_cursor() {
+ test_sniff_classification_sup("test_cursor.ico", "image", "x-icon");
+}
+
+#[test]
+fn test_sniff_bmp() {
+ test_sniff_classification_sup("test.bmp", "image", "bmp");
+}
+
+#[test]
+fn test_sniff_gif87a() {
+ test_sniff_classification_sup("test87a", "image", "gif");
+}
+
+#[test]
+fn test_sniff_gif89a() {
+ test_sniff_classification_sup("test89a.gif", "image", "gif");
+}
+
+#[test]
+fn test_sniff_webp() {
+ test_sniff_classification_sup("test.webp", "image", "webp");
+}
+
+#[test]
+fn test_sniff_png() {
+ test_sniff_classification_sup("test.png", "image", "png");
+}
+
+#[test]
+fn test_sniff_jpg() {
+ test_sniff_classification_sup("test.jpg", "image", "jpeg");
+}
+
+#[test]
+fn test_sniff_webm() {
+ test_sniff_classification_sup("test.webm", "video", "webm");
+}
+
+#[test]
+fn test_sniff_mp4() {
+ test_sniff_classification_sup("test.mp4", "video", "mp4");
+}
+
+#[test]
+fn test_sniff_avi() {
+ test_sniff_classification_sup("test.avi", "video", "avi");
+}
+
+#[test]
+fn test_sniff_basic() {
+ test_sniff_classification_sup("test.au", "audio", "basic");
+}
+
+#[test]
+fn test_sniff_aiff() {
+ test_sniff_classification_sup("test.aif", "audio", "aiff");
+}
+
+#[test]
+fn test_sniff_mpeg() {
+ test_sniff_classification_sup("test.mp3", "audio", "mpeg");
+}
+
+#[test]
+fn test_sniff_midi() {
+ test_sniff_classification_sup("test.mid", "audio", "midi");
+}
+
+#[test]
+fn test_sniff_wave() {
+ test_sniff_classification_sup("test.wav", "audio", "wave");
+}
+
+#[test]
+fn test_sniff_ogg() {
+ test_sniff_classification("small.ogg", "application", "ogg", None);
+ test_sniff_classification("small.ogg", "application", "ogg", Some(("audio", "")));
+}
+
+#[test]
+#[should_panic]
+fn test_sniff_vsn_ms_fontobject() {
+ test_sniff_classification_sup("vnd.ms-fontobject", "application", "vnd.ms-fontobject");
+}
+
+#[test]
+#[should_panic]
+fn test_sniff_true_type() {
+ test_sniff_full(&Path::new("unknown/true_type.ttf"), "(TrueType)", "", None);
+}
+
+#[test]
+#[should_panic]
+fn test_sniff_open_type() {
+ test_sniff_full(&Path::new("unknown/open_type"), "(OpenType)", "", None);
+}
+
+#[test]
+#[should_panic]
+fn test_sniff_true_type_collection() {
+ test_sniff_full(&Path::new("unknown/true_type_collection.ttc"), "(TrueType Collection)", "", None);
+}
+
+#[test]
+#[should_panic]
+fn test_sniff_woff() {
+ test_sniff_classification_sup("test.wof", "application", "font-woff");
+}
+
+#[test]
+fn test_sniff_gzip() {
+ test_sniff_classification("test.gz", "application", "x-gzip", None);
+}
+
+#[test]
+fn test_sniff_zip() {
+ test_sniff_classification("test.zip", "application", "zip", None);
+}
+
+#[test]
+fn test_sniff_rar() {
+ test_sniff_classification("test.rar", "application", "x-rar-compressed", None);
+}
+
+#[test]
+fn test_sniff_text_html_doctype_20() {
+ test_sniff_classification("text_html_doctype_20.html", "text", "html", None);
+ test_sniff_classification("text_html_doctype_20_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_doctype_3e() {
+ test_sniff_classification("text_html_doctype_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_doctype_3e_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_page_20() {
+ test_sniff_classification("text_html_page_20.html", "text", "html", None);
+ test_sniff_classification("text_html_page_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_page_3e() {
+ test_sniff_classification("text_html_page_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_page_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_head_20() {
+ test_sniff_classification("text_html_head_20.html", "text", "html", None);
+ test_sniff_classification("text_html_head_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_head_3e() {
+ test_sniff_classification("text_html_head_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_head_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_script_20() {
+ test_sniff_classification("text_html_script_20.html", "text", "html", None);
+ test_sniff_classification("text_html_script_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_script_3e() {
+ test_sniff_classification("text_html_script_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_script_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_iframe_20() {
+ test_sniff_classification("text_html_iframe_20.html", "text", "html", None);
+ test_sniff_classification("text_html_iframe_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_iframe_3e() {
+ test_sniff_classification("text_html_iframe_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_iframe_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_h1_20() {
+ test_sniff_classification("text_html_h1_20.html", "text", "html", None);
+ test_sniff_classification("text_html_h1_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_h1_3e() {
+ test_sniff_classification("text_html_h1_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_h1_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_div_20() {
+ test_sniff_classification("text_html_div_20.html", "text", "html", None);
+ test_sniff_classification("text_html_div_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_div_3e() {
+ test_sniff_classification("text_html_div_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_div_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_font_20() {
+ test_sniff_classification("text_html_font_20.html", "text", "html", None);
+ test_sniff_classification("text_html_font_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_font_3e() {
+ test_sniff_classification("text_html_font_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_font_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_table_20() {
+ test_sniff_classification("text_html_table_20.html", "text", "html", None);
+ test_sniff_classification("text_html_table_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_table_3e() {
+ test_sniff_classification("text_html_table_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_table_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_a_20() {
+ test_sniff_classification("text_html_a_20.html", "text", "html", None);
+ test_sniff_classification("text_html_a_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_a_3e() {
+ test_sniff_classification("text_html_a_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_a_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_style_20() {
+ test_sniff_classification("text_html_style_20.html", "text", "html", None);
+ test_sniff_classification("text_html_style_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_style_3e() {
+ test_sniff_classification("text_html_style_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_style_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_title_20() {
+ test_sniff_classification("text_html_title_20.html", "text", "html", None);
+ test_sniff_classification("text_html_title_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_title_3e() {
+ test_sniff_classification("text_html_title_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_title_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_b_20() {
+ test_sniff_classification("text_html_b_20.html", "text", "html", None);
+ test_sniff_classification("text_html_b_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_b_3e() {
+ test_sniff_classification("text_html_b_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_b_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_body_20() {
+ test_sniff_classification("text_html_body_20.html", "text", "html", None);
+ test_sniff_classification("text_html_body_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_body_3e() {
+ test_sniff_classification("text_html_body_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_body_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_br_20() {
+ test_sniff_classification("text_html_br_20.html", "text", "html", None);
+ test_sniff_classification("text_html_br_20_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_br_3e() {
+ test_sniff_classification("text_html_br_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_br_3e_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_p_20() {
+ test_sniff_classification("text_html_p_20.html", "text", "html", None);
+ test_sniff_classification("text_html_p_20_u.html", "text", "html", None);
+}
+#[test]
+fn test_sniff_text_html_p_3e() {
+ test_sniff_classification("text_html_p_3e.html", "text", "html", None);
+ test_sniff_classification("text_html_p_3e_u.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_comment_20() {
+ test_sniff_classification("text_html_comment_20.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_text_html_comment_3e() {
+ test_sniff_classification("text_html_comment_3e.html", "text", "html", None);
+}
+
+#[test]
+fn test_sniff_xml() {
+ test_sniff_classification("test.xml", "text", "xml", None);
+}
+
+#[test]
+fn test_sniff_pdf() {
+ test_sniff_classification("test.pdf", "application", "pdf", None);
+}
+
+#[test]
+fn test_sniff_postscript() {
+ test_sniff_classification("test.ps", "application", "postscript", None);
+}
+
+#[test]
+fn test_sniff_utf_16be_bom() {
+ test_sniff_classification("utf16bebom.txt", "text", "plain", None);
+}
+
+#[test]
+fn test_sniff_utf_16le_bom() {
+ test_sniff_classification("utf16lebom.txt", "text", "plain", None);
+}
+
+#[test]
+fn test_sniff_utf_8_bom() {
+ test_sniff_classification("utf8bom.txt", "text", "plain", None);
+}
+
+#[test]
+fn test_sniff_rss_feed() {
+ test_sniff_full(&Path::new("text/xml/feed.rss"), "application", "rss+xml", Some(("text", "html")));
+}
+
+#[test]
+fn test_sniff_atom_feed() {
+ test_sniff_full(&Path::new("text/xml/feed.atom"), "application", "atom+xml", Some(("text", "html")));
+}
diff --git a/tests/unit/net/mod.rs b/tests/unit/net/mod.rs
index e4137759590..0d304270422 100644
--- a/tests/unit/net/mod.rs
+++ b/tests/unit/net/mod.rs
@@ -5,4 +5,5 @@
mod cookie;
mod data_loader;
mod image_cache_task;
+mod mime_classifier;
mod resource_task;