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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "url/gurl.h" | 6 #include "url/gurl.h" |
7 #include "url/url_canon.h" | 7 #include "url/url_canon.h" |
8 #include "url/url_test_utils.h" | 8 #include "url/url_test_utils.h" |
9 | 9 |
10 // Some implementations of base/basictypes.h may define ARRAYSIZE. | 10 // Some implementations of base/basictypes.h may define ARRAYSIZE. |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // Returns the canonicalized string for the given URL string for the | 37 // Returns the canonicalized string for the given URL string for the |
38 // GURLTest.Types test. | 38 // GURLTest.Types test. |
39 std::string TypesTestCase(const char* src) { | 39 std::string TypesTestCase(const char* src) { |
40 GURL gurl(src); | 40 GURL gurl(src); |
41 return gurl.possibly_invalid_spec(); | 41 return gurl.possibly_invalid_spec(); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 // Different types of URLs should be handled differently by url_util, and | 46 // Different types of URLs should be handled differently, and handed off to |
47 // handed off to different canonicalizers. | 47 // different canonicalizers. |
48 TEST(GURLTest, Types) { | 48 TEST(GURLTest, Types) { |
49 // URLs with unknown schemes should be treated as path URLs, even when they | 49 // URLs with unknown schemes should be treated as path URLs, even when they |
50 // have things like "://". | 50 // have things like "://". |
51 EXPECT_EQ("something:///HOSTNAME.com/", | 51 EXPECT_EQ("something:///HOSTNAME.com/", |
52 TypesTestCase("something:///HOSTNAME.com/")); | 52 TypesTestCase("something:///HOSTNAME.com/")); |
53 | 53 |
54 // In the reverse, known schemes should always trigger standard URL handling. | 54 // In the reverse, known schemes should always trigger standard URL handling. |
55 EXPECT_EQ("http://hostname.com/", TypesTestCase("http:HOSTNAME.com")); | 55 EXPECT_EQ("http://hostname.com/", TypesTestCase("http:HOSTNAME.com")); |
56 EXPECT_EQ("http://hostname.com/", TypesTestCase("http:/HOSTNAME.com")); | 56 EXPECT_EQ("http://hostname.com/", TypesTestCase("http:/HOSTNAME.com")); |
57 EXPECT_EQ("http://hostname.com/", TypesTestCase("http://HOSTNAME.com")); | 57 EXPECT_EQ("http://hostname.com/", TypesTestCase("http://HOSTNAME.com")); |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS()); | 629 EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS()); |
630 } | 630 } |
631 | 631 |
632 TEST(GURLTest, SchemeIsWSOrWSS) { | 632 TEST(GURLTest, SchemeIsWSOrWSS) { |
633 EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS()); | 633 EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS()); |
634 EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS()); | 634 EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS()); |
635 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); | 635 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); |
636 } | 636 } |
637 | 637 |
638 } // namespace url | 638 } // namespace url |
OLD | NEW |