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

Side by Side Diff: url/url_canon_unittest.cc

Issue 23526048: Support URL fragment resolution againt non-hierarchical schemes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clea Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « url/url_canon_relative.cc ('k') | url/url_parse_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <errno.h> 5 #include <errno.h>
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/icu/source/common/unicode/ucnv.h" 8 #include "third_party/icu/source/common/unicode/ucnv.h"
9 #include "url/url_canon.h" 9 #include "url/url_canon.h"
10 #include "url/url_canon_icu.h" 10 #include "url/url_canon_icu.h"
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 1693
1694 TEST(URLCanonTest, CanonicalizePathURL) { 1694 TEST(URLCanonTest, CanonicalizePathURL) {
1695 // Path URLs should get canonicalized schemes but nothing else. 1695 // Path URLs should get canonicalized schemes but nothing else.
1696 struct PathCase { 1696 struct PathCase {
1697 const char* input; 1697 const char* input;
1698 const char* expected; 1698 const char* expected;
1699 } path_cases[] = { 1699 } path_cases[] = {
1700 {"javascript:", "javascript:"}, 1700 {"javascript:", "javascript:"},
1701 {"JavaScript:Foo", "javascript:Foo"}, 1701 {"JavaScript:Foo", "javascript:Foo"},
1702 {":\":This /is interesting;?#", ":\":This /is interesting;?#"}, 1702 {":\":This /is interesting;?#", ":\":This /is interesting;?#"},
1703 {"data:text/html, one ? two # ", "data:text/html, one ? two #"},
1703 }; 1704 };
1704 1705
1705 for (size_t i = 0; i < ARRAYSIZE(path_cases); i++) { 1706 for (size_t i = 0; i < ARRAYSIZE(path_cases); i++) {
1706 int url_len = static_cast<int>(strlen(path_cases[i].input)); 1707 int url_len = static_cast<int>(strlen(path_cases[i].input));
1707 url_parse::Parsed parsed; 1708 url_parse::Parsed parsed;
1708 url_parse::ParsePathURL(path_cases[i].input, url_len, &parsed); 1709 url_parse::ParsePathURL(path_cases[i].input, url_len, &parsed);
1709 1710
1710 url_parse::Parsed out_parsed; 1711 url_parse::Parsed out_parsed;
1711 std::string out_str; 1712 std::string out_str;
1712 url_canon::StdStringCanonOutput output(&out_str); 1713 url_canon::StdStringCanonOutput output(&out_str);
1713 bool success = url_canon::CanonicalizePathURL(path_cases[i].input, url_len, 1714 bool success = url_canon::CanonicalizePathURL(path_cases[i].input, url_len,
1714 parsed, &output, 1715 parsed, &output,
1715 &out_parsed); 1716 &out_parsed);
1716 output.Complete(); 1717 output.Complete();
1717 1718
1718 EXPECT_TRUE(success); 1719 EXPECT_TRUE(success);
1719 EXPECT_EQ(path_cases[i].expected, out_str); 1720 EXPECT_EQ(path_cases[i].expected, out_str);
1720 1721
1721 EXPECT_EQ(0, out_parsed.host.begin); 1722 EXPECT_EQ(0, out_parsed.host.begin);
1722 EXPECT_EQ(-1, out_parsed.host.len); 1723 EXPECT_EQ(-1, out_parsed.host.len);
1723 1724
1724 // When we end with a colon at the end, there should be no path. 1725 // When we end with a colon at the end, there should be no path.
1725 if (path_cases[i].input[url_len - 1] == ':') { 1726 if (path_cases[i].input[url_len - 1] == ':') {
1726 EXPECT_EQ(0, out_parsed.path.begin); 1727 EXPECT_EQ(0, out_parsed.Content().begin);
1727 EXPECT_EQ(-1, out_parsed.path.len); 1728 EXPECT_EQ(-1, out_parsed.Content().len);
1728 } 1729 }
1729 } 1730 }
1730 } 1731 }
1731 1732
1732 TEST(URLCanonTest, CanonicalizeMailtoURL) { 1733 TEST(URLCanonTest, CanonicalizeMailtoURL) {
1733 struct URLCase { 1734 struct URLCase {
1734 const char* input; 1735 const char* input;
1735 const char* expected; 1736 const char* expected;
1736 bool expected_success; 1737 bool expected_success;
1737 url_parse::Component expected_path; 1738 url_parse::Component expected_path;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 url_canon::StdStringCanonOutput repl_output(&repl_str); 2100 url_canon::StdStringCanonOutput repl_output(&repl_str);
2100 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed) ; 2101 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed) ;
2101 repl_output.Complete(); 2102 repl_output.Complete();
2102 2103
2103 // Generate the expected string and check. 2104 // Generate the expected string and check.
2104 std::string expected("file:///foo?"); 2105 std::string expected("file:///foo?");
2105 for (size_t i = 0; i < new_query.length(); i++) 2106 for (size_t i = 0; i < new_query.length(); i++)
2106 expected.push_back('a'); 2107 expected.push_back('a');
2107 EXPECT_TRUE(expected == repl_str); 2108 EXPECT_TRUE(expected == repl_str);
2108 } 2109 }
OLDNEW
« no previous file with comments | « url/url_canon_relative.cc ('k') | url/url_parse_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698