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 | |
139 TEST(GURLTest, CopyFileSystem) { | 174 TEST(GURLTest, CopyFileSystem) { |
140 GURL url(WStringToUTF16(L"filesystem:https://user:pass@google.com:99/t/foo;bar ?q=a#ref")); | 175 GURL url(WStringToUTF16(L"filesystem:https://user:pass@google.com:99/t/foo;bar ?q=a#ref")); |
141 | 176 |
142 GURL url2(url); | 177 GURL url2(url); |
143 EXPECT_TRUE(url2.is_valid()); | 178 EXPECT_TRUE(url2.is_valid()); |
144 | 179 |
145 EXPECT_EQ("filesystem:https://user:pass@google.com:99/t/foo;bar?q=a#ref", url2 .spec()); | 180 EXPECT_EQ("filesystem:https://user:pass@google.com:99/t/foo;bar?q=a#ref", url2 .spec()); |
146 EXPECT_EQ("filesystem", url2.scheme()); | 181 EXPECT_EQ("filesystem", url2.scheme()); |
147 EXPECT_EQ("", url2.username()); | 182 EXPECT_EQ("", url2.username()); |
148 EXPECT_EQ("", url2.password()); | 183 EXPECT_EQ("", url2.password()); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 EXPECT_TRUE(a.IsStandard()); | 517 EXPECT_TRUE(a.IsStandard()); |
483 | 518 |
484 GURL b("foo:bar/baz"); | 519 GURL b("foo:bar/baz"); |
485 EXPECT_FALSE(b.IsStandard()); | 520 EXPECT_FALSE(b.IsStandard()); |
486 | 521 |
487 GURL c("foo://bar/baz"); | 522 GURL c("foo://bar/baz"); |
488 EXPECT_FALSE(c.IsStandard()); | 523 EXPECT_FALSE(c.IsStandard()); |
489 } | 524 } |
490 | 525 |
491 // This is a regression test for http://crbug.com/309975 . | 526 // This is a regression test for http://crbug.com/309975 . |
492 TEST(GURLTest, SelfAssignment) { | 527 TEST(GURLTest, SelfAssignment) { |
akalin
2013/10/22 17:56:41
Perhaps move this to be right next to the Assign t
cjhopman
2013/10/22 19:03:44
Done.
| |
493 GURL a("filesystem:http://example.com/temporary/"); | 528 GURL a("filesystem:http://example.com/temporary/"); |
494 // This should not crash. | 529 // This should not crash. |
495 a = a; | 530 a = a; |
496 } | 531 } |
OLD | NEW |