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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "url/gurl.h" | 7 #include "url/gurl.h" |
8 #include "url/url_canon.h" | 8 #include "url/url_canon.h" |
9 #include "url/url_test_utils.h" | 9 #include "url/url_test_utils.h" |
10 | 10 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 struct TestCase { | 336 struct TestCase { |
337 const char* input; | 337 const char* input; |
338 const char* expected; | 338 const char* expected; |
339 } cases[] = { | 339 } cases[] = { |
340 {"http://www.google.com", "http://www.google.com/"}, | 340 {"http://www.google.com", "http://www.google.com/"}, |
341 {"http://user:pass@www.google.com:21/blah#baz", "http://www.google.com:21/bl
ah"}, | 341 {"http://user:pass@www.google.com:21/blah#baz", "http://www.google.com:21/bl
ah"}, |
342 {"http://user@www.google.com", "http://www.google.com/"}, | 342 {"http://user@www.google.com", "http://www.google.com/"}, |
343 {"http://:pass@www.google.com", "http://www.google.com/"}, | 343 {"http://:pass@www.google.com", "http://www.google.com/"}, |
344 {"http://:@www.google.com", "http://www.google.com/"}, | 344 {"http://:@www.google.com", "http://www.google.com/"}, |
345 {"http://www.google.com/temp/foo?q#b", "http://www.google.com/temp/foo?q"}, | 345 {"http://www.google.com/temp/foo?q#b", "http://www.google.com/temp/foo?q"}, |
| 346 {"not a url", ""}, |
| 347 {"unknown-scheme://foo.html", ""}, |
| 348 {"file:///tmp/test.html", ""}, |
| 349 {"https://www.google.com", "https://www.google.com/"}, |
346 }; | 350 }; |
347 for (size_t i = 0; i < arraysize(cases); i++) { | 351 for (size_t i = 0; i < arraysize(cases); i++) { |
348 GURL url(cases[i].input); | 352 GURL url(cases[i].input); |
349 GURL origin = url.GetAsReferrer(); | 353 GURL origin = url.GetAsReferrer(); |
350 EXPECT_EQ(cases[i].expected, origin.spec()); | 354 EXPECT_EQ(cases[i].expected, origin.spec()); |
351 } | 355 } |
352 } | 356 } |
353 | 357 |
354 TEST(GURLTest, GetWithEmptyPath) { | 358 TEST(GURLTest, GetWithEmptyPath) { |
355 struct TestCase { | 359 struct TestCase { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); | 633 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); |
630 } | 634 } |
631 | 635 |
632 TEST(GURLTest, SchemeIsBlob) { | 636 TEST(GURLTest, SchemeIsBlob) { |
633 EXPECT_TRUE(GURL("BLOB://BAR/").SchemeIsBlob()); | 637 EXPECT_TRUE(GURL("BLOB://BAR/").SchemeIsBlob()); |
634 EXPECT_TRUE(GURL("blob://bar/").SchemeIsBlob()); | 638 EXPECT_TRUE(GURL("blob://bar/").SchemeIsBlob()); |
635 EXPECT_FALSE(GURL("http://bar/").SchemeIsBlob()); | 639 EXPECT_FALSE(GURL("http://bar/").SchemeIsBlob()); |
636 } | 640 } |
637 | 641 |
638 } // namespace url | 642 } // namespace url |
OLD | NEW |