OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 const char* base; | 287 const char* base; |
288 const char* relative; | 288 const char* relative; |
289 bool expected_valid; | 289 bool expected_valid; |
290 const char* expected; | 290 const char* expected; |
291 } resolve_cases[] = { | 291 } resolve_cases[] = { |
292 {"http://www.google.com/", "foo.html", true, "http://www.google.com/foo.html
"}, | 292 {"http://www.google.com/", "foo.html", true, "http://www.google.com/foo.html
"}, |
293 {"http://www.google.com/foo/", "bar", true, "http://www.google.com/foo/bar"}
, | 293 {"http://www.google.com/foo/", "bar", true, "http://www.google.com/foo/bar"}
, |
294 {"http://www.google.com/foo/", "/bar", true, "http://www.google.com/bar"}, | 294 {"http://www.google.com/foo/", "/bar", true, "http://www.google.com/bar"}, |
295 {"http://www.google.com/foo", "bar", true, "http://www.google.com/bar"}, | 295 {"http://www.google.com/foo", "bar", true, "http://www.google.com/bar"}, |
296 {"http://www.google.com/", "http://images.google.com/foo.html", true, "http:
//images.google.com/foo.html"}, | 296 {"http://www.google.com/", "http://images.google.com/foo.html", true, "http:
//images.google.com/foo.html"}, |
| 297 {"http://www.google.com/", "http://images.\tgoogle.\ncom/\rfoo.html", true,
"http://images.google.com/foo.html"}, |
297 {"http://www.google.com/blah/bloo?c#d", "../../../hello/./world.html?a#b", t
rue, "http://www.google.com/hello/world.html?a#b"}, | 298 {"http://www.google.com/blah/bloo?c#d", "../../../hello/./world.html?a#b", t
rue, "http://www.google.com/hello/world.html?a#b"}, |
298 {"http://www.google.com/foo#bar", "#com", true, "http://www.google.com/foo#c
om"}, | 299 {"http://www.google.com/foo#bar", "#com", true, "http://www.google.com/foo#c
om"}, |
299 {"http://www.google.com/", "Https:images.google.com", true, "https://images.
google.com/"}, | 300 {"http://www.google.com/", "Https:images.google.com", true, "https://images.
google.com/"}, |
300 // A non-standard base can be replaced with a standard absolute URL. | 301 // A non-standard base can be replaced with a standard absolute URL. |
301 {"data:blahblah", "http://google.com/", true, "http://google.com/"}, | 302 {"data:blahblah", "http://google.com/", true, "http://google.com/"}, |
302 {"data:blahblah", "http:google.com", true, "http://google.com/"}, | 303 {"data:blahblah", "http:google.com", true, "http://google.com/"}, |
303 // Filesystem URLs have different paths to test. | 304 // Filesystem URLs have different paths to test. |
304 {"filesystem:http://www.google.com/type/", "foo.html", true, "filesystem:htt
p://www.google.com/type/foo.html"}, | 305 {"filesystem:http://www.google.com/type/", "foo.html", true, "filesystem:htt
p://www.google.com/type/foo.html"}, |
305 {"filesystem:http://www.google.com/type/", "../foo.html", true, "filesystem:
http://www.google.com/type/foo.html"}, | 306 {"filesystem:http://www.google.com/type/", "../foo.html", true, "filesystem:
http://www.google.com/type/foo.html"}, |
306 }; | 307 }; |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 }; | 734 }; |
734 | 735 |
735 for (const auto& test : cases) { | 736 for (const auto& test : cases) { |
736 GURL url(test.url); | 737 GURL url(test.url); |
737 EXPECT_EQ(test.expected, url.path()) << test.url; | 738 EXPECT_EQ(test.expected, url.path()) << test.url; |
738 EXPECT_EQ(test.expected, url.GetContent()) << test.url; | 739 EXPECT_EQ(test.expected, url.GetContent()) << test.url; |
739 } | 740 } |
740 } | 741 } |
741 | 742 |
742 } // namespace url | 743 } // namespace url |
OLD | NEW |