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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 SetupReplacement(&GURL::Replacements::SetPath, &repl, cur.path); | 301 SetupReplacement(&GURL::Replacements::SetPath, &repl, cur.path); |
302 SetupReplacement(&GURL::Replacements::SetQuery, &repl, cur.query); | 302 SetupReplacement(&GURL::Replacements::SetQuery, &repl, cur.query); |
303 SetupReplacement(&GURL::Replacements::SetRef, &repl, cur.ref); | 303 SetupReplacement(&GURL::Replacements::SetRef, &repl, cur.ref); |
304 GURL output = url.ReplaceComponents(repl); | 304 GURL output = url.ReplaceComponents(repl); |
305 | 305 |
306 EXPECT_EQ(replace_cases[i].expected, output.spec()); | 306 EXPECT_EQ(replace_cases[i].expected, output.spec()); |
307 EXPECT_EQ(output.SchemeIsFileSystem(), output.inner_url() != NULL); | 307 EXPECT_EQ(output.SchemeIsFileSystem(), output.inner_url() != NULL); |
308 } | 308 } |
309 } | 309 } |
310 | 310 |
| 311 TEST(GURLTest, ClearReplacements) { |
| 312 GURL url(" data: one ? two # three "); |
| 313 GURL::Replacements repl; |
| 314 repl.ClearRef(); |
| 315 GURL output = url.ReplaceComponents(repl); |
| 316 |
| 317 EXPECT_EQ("data: one ? two ", output.spec()); |
| 318 |
| 319 GURL importurl(output.spec(), output.parsed_for_possibly_invalid_spec(), |
| 320 output.is_valid()); |
| 321 EXPECT_EQ(importurl, output); |
| 322 } |
| 323 |
311 TEST(GURLTest, PathForRequest) { | 324 TEST(GURLTest, PathForRequest) { |
312 struct TestCase { | 325 struct TestCase { |
313 const char* input; | 326 const char* input; |
314 const char* expected; | 327 const char* expected; |
315 const char* inner_expected; | 328 const char* inner_expected; |
316 } cases[] = { | 329 } cases[] = { |
317 {"http://www.google.com", "/", NULL}, | 330 {"http://www.google.com", "/", NULL}, |
318 {"http://www.google.com/", "/", NULL}, | 331 {"http://www.google.com/", "/", NULL}, |
319 {"http://www.google.com/foo/bar.html?baz=22", "/foo/bar.html?baz=22", NULL}, | 332 {"http://www.google.com/foo/bar.html?baz=22", "/foo/bar.html?baz=22", NULL}, |
320 {"http://www.google.com/foo/bar.html#ref", "/foo/bar.html", NULL}, | 333 {"http://www.google.com/foo/bar.html#ref", "/foo/bar.html", NULL}, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 TEST(GURLTest, IsStandard) { | 493 TEST(GURLTest, IsStandard) { |
481 GURL a("http:foo/bar"); | 494 GURL a("http:foo/bar"); |
482 EXPECT_TRUE(a.IsStandard()); | 495 EXPECT_TRUE(a.IsStandard()); |
483 | 496 |
484 GURL b("foo:bar/baz"); | 497 GURL b("foo:bar/baz"); |
485 EXPECT_FALSE(b.IsStandard()); | 498 EXPECT_FALSE(b.IsStandard()); |
486 | 499 |
487 GURL c("foo://bar/baz"); | 500 GURL c("foo://bar/baz"); |
488 EXPECT_FALSE(c.IsStandard()); | 501 EXPECT_FALSE(c.IsStandard()); |
489 } | 502 } |
OLD | NEW |