| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 EXPECT_EQ("", invalid2.username()); | 129 EXPECT_EQ("", invalid2.username()); |
| 130 EXPECT_EQ("", invalid2.password()); | 130 EXPECT_EQ("", invalid2.password()); |
| 131 EXPECT_EQ("", invalid2.host()); | 131 EXPECT_EQ("", invalid2.host()); |
| 132 EXPECT_EQ("", invalid2.port()); | 132 EXPECT_EQ("", invalid2.port()); |
| 133 EXPECT_EQ(url_parse::PORT_UNSPECIFIED, invalid2.IntPort()); | 133 EXPECT_EQ(url_parse::PORT_UNSPECIFIED, invalid2.IntPort()); |
| 134 EXPECT_EQ("", invalid2.path()); | 134 EXPECT_EQ("", invalid2.path()); |
| 135 EXPECT_EQ("", invalid2.query()); | 135 EXPECT_EQ("", invalid2.query()); |
| 136 EXPECT_EQ("", invalid2.ref()); | 136 EXPECT_EQ("", invalid2.ref()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST(GURLTest, Assign) { |
| 140 GURL url(WStringToUTF16(L"http://user:pass@google.com:99/foo;bar?q=a#ref")); |
| 141 |
| 142 GURL url2; |
| 143 url2 = url; |
| 144 EXPECT_TRUE(url2.is_valid()); |
| 145 |
| 146 EXPECT_EQ("http://user:pass@google.com:99/foo;bar?q=a#ref", url2.spec()); |
| 147 EXPECT_EQ("http", url2.scheme()); |
| 148 EXPECT_EQ("user", url2.username()); |
| 149 EXPECT_EQ("pass", url2.password()); |
| 150 EXPECT_EQ("google.com", url2.host()); |
| 151 EXPECT_EQ("99", url2.port()); |
| 152 EXPECT_EQ(99, url2.IntPort()); |
| 153 EXPECT_EQ("/foo;bar", url2.path()); |
| 154 EXPECT_EQ("q=a", url2.query()); |
| 155 EXPECT_EQ("ref", url2.ref()); |
| 156 |
| 157 // Assignment of invalid URL should be invalid |
| 158 GURL invalid; |
| 159 GURL invalid2; |
| 160 invalid2 = invalid; |
| 161 EXPECT_FALSE(invalid2.is_valid()); |
| 162 EXPECT_EQ("", invalid2.spec()); |
| 163 EXPECT_EQ("", invalid2.scheme()); |
| 164 EXPECT_EQ("", invalid2.username()); |
| 165 EXPECT_EQ("", invalid2.password()); |
| 166 EXPECT_EQ("", invalid2.host()); |
| 167 EXPECT_EQ("", invalid2.port()); |
| 168 EXPECT_EQ(url_parse::PORT_UNSPECIFIED, invalid2.IntPort()); |
| 169 EXPECT_EQ("", invalid2.path()); |
| 170 EXPECT_EQ("", invalid2.query()); |
| 171 EXPECT_EQ("", invalid2.ref()); |
| 172 } |
| 173 |
| 174 // This is a regression test for http://crbug.com/309975 . |
| 175 TEST(GURLTest, SelfAssign) { |
| 176 GURL a("filesystem:http://example.com/temporary/"); |
| 177 // This should not crash. |
| 178 a = a; |
| 179 } |
| 180 |
| 139 TEST(GURLTest, CopyFileSystem) { | 181 TEST(GURLTest, CopyFileSystem) { |
| 140 GURL url(WStringToUTF16(L"filesystem:https://user:pass@google.com:99/t/foo;bar
?q=a#ref")); | 182 GURL url(WStringToUTF16(L"filesystem:https://user:pass@google.com:99/t/foo;bar
?q=a#ref")); |
| 141 | 183 |
| 142 GURL url2(url); | 184 GURL url2(url); |
| 143 EXPECT_TRUE(url2.is_valid()); | 185 EXPECT_TRUE(url2.is_valid()); |
| 144 | 186 |
| 145 EXPECT_EQ("filesystem:https://user:pass@google.com:99/t/foo;bar?q=a#ref", url2
.spec()); | 187 EXPECT_EQ("filesystem:https://user:pass@google.com:99/t/foo;bar?q=a#ref", url2
.spec()); |
| 146 EXPECT_EQ("filesystem", url2.scheme()); | 188 EXPECT_EQ("filesystem", url2.scheme()); |
| 147 EXPECT_EQ("", url2.username()); | 189 EXPECT_EQ("", url2.username()); |
| 148 EXPECT_EQ("", url2.password()); | 190 EXPECT_EQ("", url2.password()); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 TEST(GURLTest, IsStandard) { | 522 TEST(GURLTest, IsStandard) { |
| 481 GURL a("http:foo/bar"); | 523 GURL a("http:foo/bar"); |
| 482 EXPECT_TRUE(a.IsStandard()); | 524 EXPECT_TRUE(a.IsStandard()); |
| 483 | 525 |
| 484 GURL b("foo:bar/baz"); | 526 GURL b("foo:bar/baz"); |
| 485 EXPECT_FALSE(b.IsStandard()); | 527 EXPECT_FALSE(b.IsStandard()); |
| 486 | 528 |
| 487 GURL c("foo://bar/baz"); | 529 GURL c("foo://bar/baz"); |
| 488 EXPECT_FALSE(c.IsStandard()); | 530 EXPECT_FALSE(c.IsStandard()); |
| 489 } | 531 } |
| 490 | |
| 491 // This is a regression test for http://crbug.com/309975 . | |
| 492 TEST(GURLTest, SelfAssignment) { | |
| 493 GURL a("filesystem:http://example.com/temporary/"); | |
| 494 // This should not crash. | |
| 495 a = a; | |
| 496 } | |
| OLD | NEW |