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 "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 #include "url/third_party/mozilla/url_parse.h" | 10 #include "url/third_party/mozilla/url_parse.h" |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 EXPECT_TRUE(IsAboutBlank(GURL(url))); | 426 EXPECT_TRUE(IsAboutBlank(GURL(url))); |
427 | 427 |
428 const std::string kNotAboutBlankUrls[] = { | 428 const std::string kNotAboutBlankUrls[] = { |
429 "http:blank", "about:blan", "about://blank", | 429 "http:blank", "about:blan", "about://blank", |
430 "about:blank/foo", "about://:8000/blank", "about://foo:foo@/blank", | 430 "about:blank/foo", "about://:8000/blank", "about://foo:foo@/blank", |
431 "foo@about:blank", "foo:bar@about:blank", "about:blank:8000"}; | 431 "foo@about:blank", "foo:bar@about:blank", "about:blank:8000"}; |
432 for (const auto& url : kNotAboutBlankUrls) | 432 for (const auto& url : kNotAboutBlankUrls) |
433 EXPECT_FALSE(IsAboutBlank(GURL(url))); | 433 EXPECT_FALSE(IsAboutBlank(GURL(url))); |
434 } | 434 } |
435 | 435 |
436 TEST(URLUtilTest, EqualsIgnoringRef) { | |
437 const struct { | |
438 const char* url_a; | |
439 const char* url_b; | |
440 bool are_equals; | |
441 } kTestCases[] = { | |
442 // No ref. | |
443 {"http://a.com", "http://a.com", true}, | |
444 {"http://a.com", "http://b.com", false}, | |
445 | |
446 // Same Ref. | |
447 {"http://a.com#foo", "http://a.com#foo", true}, | |
448 {"http://a.com#foo", "http://b.com#foo", false}, | |
449 | |
450 // Different Refs. | |
451 {"http://a.com#foo", "http://a.com#bar", true}, | |
452 {"http://a.com#foo", "http://b.com#bar", false}, | |
brettw
2017/02/07 06:37:48
Can you add a case below this of one with URL with
arthursonzogni
2017/02/07 12:04:50
What do you mean by "text"?
I will do as if you sa
| |
453 | |
454 // Empty refs. | |
455 {"http://a.com#", "http://a.com#", true}, | |
456 {"http://a.com#", "http://a.com", true}, | |
457 {"http://a.com", "http://a.com#", true}, | |
458 | |
459 // URLs that differ only by their last character. | |
460 {"http://aaa", "http://aab", false}, | |
461 {"http://aaa#foo", "http://aab#foo", false}, | |
462 | |
463 // Different size of the part before the ref. | |
464 {"http://123#a", "http://123456#a", false}, | |
465 {"http://123456#a", "http://123#a", false}, | |
466 | |
467 // Blob urls | |
468 {"blob:http://a.com#foo", "blob:http://a.com#foo", true}, | |
469 {"blob:http://a.com#foo", "blob:http://a.com#bar", true}, | |
470 {"blob:http://a.com#foo", "blob:http://b.com#bar", false}, | |
471 | |
472 // Filesystem url | |
473 {"filesystem:http://a.com#foo", "filesystem:http://a.com#foo", true}, | |
474 {"filesystem:http://a.com#foo", "filesystem:http://a.com#bar", true}, | |
475 {"filesystem:http://a.com#foo", "filesystem:http://b.com#bar", false}, | |
476 }; | |
477 | |
478 for (const auto& test_case : kTestCases) { | |
479 SCOPED_TRACE(testing::Message() | |
480 << std::endl | |
481 << "url_a = " << test_case.url_a << std::endl | |
482 << "url_b = " << test_case.url_b << std::endl); | |
483 | |
484 EXPECT_EQ( | |
485 test_case.are_equals, | |
486 GURL::EqualsIgnoringRef(GURL(test_case.url_a), GURL(test_case.url_b))); | |
487 } | |
488 } | |
489 | |
436 } // namespace url | 490 } // namespace url |
OLD | NEW |