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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "url/url_parse.h" 5 #include "url/url_parse.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "url/url_parse.h" 9 #include "url/url_parse.h"
10 10
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 url_parse::Parsed parsed; 452 url_parse::Parsed parsed;
453 url_parse::ParseStandardURL(url, len, &parsed); 453 url_parse::ParseStandardURL(url, len, &parsed);
454 454
455 url_parse::Component file_name; 455 url_parse::Component file_name;
456 url_parse::ExtractFileName(url, parsed.path, &file_name); 456 url_parse::ExtractFileName(url, parsed.path, &file_name);
457 457
458 EXPECT_TRUE(ComponentMatches(url, file_cases[i].expected, file_name)); 458 EXPECT_TRUE(ComponentMatches(url, file_cases[i].expected, file_name));
459 } 459 }
460 } 460 }
461 461
462 TEST(URLParser, ExtractFileExtension) {
463 struct FileCase {
464 const char* input;
465 const char* expected;
466 } file_cases[] = {
467 {"http://www.google.com", NULL},
468 {"http://www.google.com/", NULL},
469 {"http://www.google.com/.foo", NULL},
470 {"http://www.google.com/foo.bar", "bar"},
471 {"http://www.google.com/foo.", ""},
472 {"http://www.google.com/.foo.bar", "bar"},
473 {"http://www.google.com/a.b.c", "c"},
474 };
475
476 for (size_t i = 0; i < ARRAYSIZE(file_cases); i++) {
477 const char* url = file_cases[i].input;
478 int len = static_cast<int>(strlen(url));
479
480 url_parse::Parsed parsed;
481 url_parse::ParseStandardURL(url, len, &parsed);
482
483 url_parse::Component file_name;
484 url_parse::ExtractFileExtension(url, parsed.path, &file_name);
485
486 EXPECT_TRUE(ComponentMatches(url, file_cases[i].expected, file_name));
487 }
488 }
489
462 // Returns true if the parameter with index |parameter| in the given URL's 490 // Returns true if the parameter with index |parameter| in the given URL's
463 // query string. The expected key can be NULL to indicate no such key index 491 // query string. The expected key can be NULL to indicate no such key index
464 // should exist. The parameter number is 1-based. 492 // should exist. The parameter number is 1-based.
465 static bool NthParameterIs(const char* url, 493 static bool NthParameterIs(const char* url,
466 int parameter, 494 int parameter,
467 const char* expected_key, 495 const char* expected_key,
468 const char* expected_value) { 496 const char* expected_value) {
469 url_parse::Parsed parsed; 497 url_parse::Parsed parsed;
470 url_parse::ParseStandardURL(url, static_cast<int>(strlen(url)), &parsed); 498 url_parse::ParseStandardURL(url, static_cast<int>(strlen(url)), &parsed);
471 499
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 // The remaining components are never used for filesystem urls. 645 // The remaining components are never used for filesystem urls.
618 ExpectInvalidComponent(parsed.username); 646 ExpectInvalidComponent(parsed.username);
619 ExpectInvalidComponent(parsed.password); 647 ExpectInvalidComponent(parsed.password);
620 ExpectInvalidComponent(parsed.host); 648 ExpectInvalidComponent(parsed.host);
621 ExpectInvalidComponent(parsed.port); 649 ExpectInvalidComponent(parsed.port);
622 } 650 }
623 } 651 }
624 652
625 } // namespace 653 } // namespace
626 } // namespace url_parse 654 } // namespace url_parse
OLDNEW
« 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