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/url_canon.h" | 10 #include "url/url_canon.h" |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 EXPECT_TRUE(GURL("HTTPS://BAR").SchemeIsHTTPOrHTTPS()); | 670 EXPECT_TRUE(GURL("HTTPS://BAR").SchemeIsHTTPOrHTTPS()); |
671 EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS()); | 671 EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS()); |
672 } | 672 } |
673 | 673 |
674 TEST(GURLTest, SchemeIsWSOrWSS) { | 674 TEST(GURLTest, SchemeIsWSOrWSS) { |
675 EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS()); | 675 EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS()); |
676 EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS()); | 676 EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS()); |
677 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); | 677 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); |
678 } | 678 } |
679 | 679 |
680 TEST(GURLTest, SchemeIsCryptographic) { | |
681 EXPECT_TRUE(GURL("https://foo.bar.com/").SchemeIsCryptographic()); | |
682 EXPECT_TRUE(GURL("HTTPS://foo.bar.com/").SchemeIsCryptographic()); | |
683 | |
684 EXPECT_TRUE(GURL("wss://foo.bar.com/").SchemeIsCryptographic()); | |
685 EXPECT_TRUE(GURL("WSS://foo.bar.com/").SchemeIsCryptographic()); | |
686 | |
687 EXPECT_TRUE(GURL("https-so://foo.bar.com/").SchemeIsCryptographic()); | |
688 EXPECT_TRUE(GURL("HTTPS-SO://foo.bar.com/").SchemeIsCryptographic()); | |
nasko
2016/10/13 22:16:45
nit: I'd add mixed case instead of/in addition to
jww
2016/10/14 01:08:58
Done.
| |
689 | |
690 EXPECT_FALSE(GURL("http://foo.bar.com/").SchemeIsCryptographic()); | |
691 EXPECT_FALSE(GURL("ws://foo.bar.com/").SchemeIsCryptographic()); | |
692 EXPECT_FALSE(GURL("http-so://foo.bar.com/").SchemeIsCryptographic()); | |
693 } | |
694 | |
680 TEST(GURLTest, SchemeIsBlob) { | 695 TEST(GURLTest, SchemeIsBlob) { |
681 EXPECT_TRUE(GURL("BLOB://BAR/").SchemeIsBlob()); | 696 EXPECT_TRUE(GURL("BLOB://BAR/").SchemeIsBlob()); |
682 EXPECT_TRUE(GURL("blob://bar/").SchemeIsBlob()); | 697 EXPECT_TRUE(GURL("blob://bar/").SchemeIsBlob()); |
683 EXPECT_FALSE(GURL("http://bar/").SchemeIsBlob()); | 698 EXPECT_FALSE(GURL("http://bar/").SchemeIsBlob()); |
684 } | 699 } |
685 | 700 |
701 TEST(GURLTest, SchemeIsSuborigin) { | |
702 EXPECT_TRUE(GURL("http-so://foo.bar.com/").SchemeIsSuborigin()); | |
703 EXPECT_TRUE(GURL("HTTP-SO://foo.bar.com/").SchemeIsSuborigin()); | |
704 EXPECT_FALSE(GURL("http://foo.bar.com/").SchemeIsSuborigin()); | |
705 | |
706 EXPECT_TRUE(GURL("https-so://foo.bar.com/").SchemeIsSuborigin()); | |
707 EXPECT_TRUE(GURL("HTTPS-SO://foo.bar.com/").SchemeIsSuborigin()); | |
708 EXPECT_FALSE(GURL("https://foo.bar.com/").SchemeIsSuborigin()); | |
709 } | |
710 | |
686 TEST(GURLTest, ContentAndPathForNonStandardURLs) { | 711 TEST(GURLTest, ContentAndPathForNonStandardURLs) { |
687 struct TestCase { | 712 struct TestCase { |
688 const char* url; | 713 const char* url; |
689 const char* expected; | 714 const char* expected; |
690 } cases[] = { | 715 } cases[] = { |
691 {"null", ""}, | 716 {"null", ""}, |
692 {"not-a-standard-scheme:this is arbitrary content", | 717 {"not-a-standard-scheme:this is arbitrary content", |
693 "this is arbitrary content"}, | 718 "this is arbitrary content"}, |
694 {"view-source:http://example.com/path", "http://example.com/path"}, | 719 {"view-source:http://example.com/path", "http://example.com/path"}, |
695 {"blob:http://example.com/GUID", "http://example.com/GUID"}, | 720 {"blob:http://example.com/GUID", "http://example.com/GUID"}, |
696 {"blob://http://example.com/GUID", "//http://example.com/GUID"}, | 721 {"blob://http://example.com/GUID", "//http://example.com/GUID"}, |
697 {"blob:http://user:password@example.com/GUID", | 722 {"blob:http://user:password@example.com/GUID", |
698 "http://user:password@example.com/GUID"}, | 723 "http://user:password@example.com/GUID"}, |
699 | 724 |
700 // TODO(mkwst): This seems like a bug. https://crbug.com/513600 | 725 // TODO(mkwst): This seems like a bug. https://crbug.com/513600 |
701 {"filesystem:http://example.com/path", "/"}, | 726 {"filesystem:http://example.com/path", "/"}, |
702 }; | 727 }; |
703 | 728 |
704 for (const auto& test : cases) { | 729 for (const auto& test : cases) { |
705 GURL url(test.url); | 730 GURL url(test.url); |
706 EXPECT_EQ(test.expected, url.path()) << test.url; | 731 EXPECT_EQ(test.expected, url.path()) << test.url; |
707 EXPECT_EQ(test.expected, url.GetContent()) << test.url; | 732 EXPECT_EQ(test.expected, url.GetContent()) << test.url; |
708 } | 733 } |
709 } | 734 } |
710 | 735 |
711 } // namespace url | 736 } // namespace url |
OLD | NEW |