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

Unified Diff: url/url_parse_unittest.cc

Issue 19857005: Do not show translate bar for MHTML files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add and use GURL::ExtractFileExtension() Created 7 years, 5 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
« chrome/browser/translate/translate_manager.cc ('K') | « url/url_parse.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_parse_unittest.cc
diff --git a/url/url_parse_unittest.cc b/url/url_parse_unittest.cc
index a65ff858b460149fd5dba2271991c130b78a3a69..7cbccb67e3af01401ac8633716d23b3eed884cbe 100644
--- a/url/url_parse_unittest.cc
+++ b/url/url_parse_unittest.cc
@@ -459,6 +459,34 @@ TEST(URLParser, ExtractFileName) {
}
}
+TEST(URLParser, ExtractFileExtension) {
+ struct FileCase {
+ const char* input;
+ const char* expected;
+ } file_cases[] = {
+ {"http://www.google.com", NULL},
+ {"http://www.google.com/", NULL},
+ {"http://www.google.com/.foo", NULL},
+ {"http://www.google.com/foo.bar", "bar"},
+ {"http://www.google.com/foo.", ""},
+ {"http://www.google.com/.foo.bar", "bar"},
+ {"http://www.google.com/a.b.c", "c"},
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE(file_cases); i++) {
+ const char* url = file_cases[i].input;
+ int len = static_cast<int>(strlen(url));
+
+ url_parse::Parsed parsed;
+ url_parse::ParseStandardURL(url, len, &parsed);
+
+ url_parse::Component file_name;
+ url_parse::ExtractFileExtension(url, parsed.path, &file_name);
+
+ EXPECT_TRUE(ComponentMatches(url, file_cases[i].expected, file_name));
+ }
+}
+
// Returns true if the parameter with index |parameter| in the given URL's
// query string. The expected key can be NULL to indicate no such key index
// should exist. The parameter number is 1-based.
« chrome/browser/translate/translate_manager.cc ('K') | « url/url_parse.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698