OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 #include <utility> | 6 #include <utility> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "net/cookies/cookie_util.h" | 10 #include "net/cookies/cookie_util.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 void CheckSerialize( | 38 void CheckSerialize( |
39 const std::vector<std::pair<std::string, std::string> >& parsed, | 39 const std::vector<std::pair<std::string, std::string> >& parsed, |
40 const std::string& str_expected) { | 40 const std::string& str_expected) { |
41 net::cookie_util::ParsedRequestCookies prc = | 41 net::cookie_util::ParsedRequestCookies prc = |
42 MakeParsedRequestCookies(parsed); | 42 MakeParsedRequestCookies(parsed); |
43 EXPECT_EQ(str_expected, net::cookie_util::SerializeRequestCookieLine(prc)); | 43 EXPECT_EQ(str_expected, net::cookie_util::SerializeRequestCookieLine(prc)); |
44 } | 44 } |
45 | 45 |
46 } // namespace | |
47 | |
48 TEST(CookieUtilTest, TestDomainIsHostOnly) { | 46 TEST(CookieUtilTest, TestDomainIsHostOnly) { |
49 const struct { | 47 const struct { |
50 const char* str; | 48 const char* str; |
51 const bool is_host_only; | 49 const bool is_host_only; |
52 } tests[] = { | 50 } tests[] = { |
53 { "", true }, | 51 { "", true }, |
54 { "www.google.com", true }, | 52 { "www.google.com", true }, |
55 { ".google.com", false } | 53 { ".google.com", false } |
56 }; | 54 }; |
57 | 55 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 std::string("\"abcdef\""))); | 185 std::string("\"abcdef\""))); |
188 tests.back().parsed.push_back(std::make_pair(std::string("otherkey"), | 186 tests.back().parsed.push_back(std::make_pair(std::string("otherkey"), |
189 std::string("1234"))); | 187 std::string("1234"))); |
190 | 188 |
191 for (size_t i = 0; i < tests.size(); i++) { | 189 for (size_t i = 0; i < tests.size(); i++) { |
192 SCOPED_TRACE(testing::Message() << "Test " << i); | 190 SCOPED_TRACE(testing::Message() << "Test " << i); |
193 CheckParse(tests[i].str, tests[i].parsed); | 191 CheckParse(tests[i].str, tests[i].parsed); |
194 CheckSerialize(tests[i].parsed, tests[i].str); | 192 CheckSerialize(tests[i].parsed, tests[i].str); |
195 } | 193 } |
196 } | 194 } |
| 195 |
| 196 TEST(CookieUtilTest, TestGetEffectiveDomain) { |
| 197 // Note: registry_controlled_domains::GetDomainAndRegistry is tested in its |
| 198 // own unittests. |
| 199 EXPECT_EQ("example.com", |
| 200 net::cookie_util::GetEffectiveDomain("http", "www.example.com")); |
| 201 EXPECT_EQ("example.com", |
| 202 net::cookie_util::GetEffectiveDomain("https", "www.example.com")); |
| 203 EXPECT_EQ("example.com", |
| 204 net::cookie_util::GetEffectiveDomain("ws", "www.example.com")); |
| 205 EXPECT_EQ("example.com", |
| 206 net::cookie_util::GetEffectiveDomain("wss", "www.example.com")); |
| 207 EXPECT_EQ("www.example.com", |
| 208 net::cookie_util::GetEffectiveDomain("ftp", "www.example.com")); |
| 209 } |
| 210 |
| 211 } // namespace |
OLD | NEW |