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 | 7 |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "net/cookies/cookie_util.h" | 9 #include "net/cookies/cookie_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 void CheckSerialize(const base::StringPairs& parsed, | 38 void CheckSerialize(const base::StringPairs& parsed, |
39 const std::string& str_expected) { | 39 const std::string& str_expected) { |
40 cookie_util::ParsedRequestCookies prc = MakeParsedRequestCookies(parsed); | 40 cookie_util::ParsedRequestCookies prc = MakeParsedRequestCookies(parsed); |
41 EXPECT_EQ(str_expected, cookie_util::SerializeRequestCookieLine(prc)); | 41 EXPECT_EQ(str_expected, cookie_util::SerializeRequestCookieLine(prc)); |
42 } | 42 } |
43 | 43 |
44 TEST(CookieUtilTest, TestDomainIsHostOnly) { | 44 TEST(CookieUtilTest, TestDomainIsHostOnly) { |
45 const struct { | 45 const struct { |
46 const char* str; | 46 const char* str; |
47 const bool is_host_only; | 47 const bool is_host_only; |
48 } tests[] = { | 48 } tests[] = {{"", true}, {"www.foo.com", true}, {".foo.com", false}}; |
49 { "", true }, | |
50 { "www.google.com", true }, | |
51 { ".google.com", false } | |
52 }; | |
53 | 49 |
54 for (size_t i = 0; i < arraysize(tests); ++i) { | 50 for (size_t i = 0; i < arraysize(tests); ++i) { |
55 EXPECT_EQ(tests[i].is_host_only, | 51 EXPECT_EQ(tests[i].is_host_only, |
56 cookie_util::DomainIsHostOnly(tests[i].str)); | 52 cookie_util::DomainIsHostOnly(tests[i].str)); |
57 } | 53 } |
58 } | 54 } |
59 | 55 |
60 TEST(CookieUtilTest, TestCookieDateParsing) { | 56 TEST(CookieUtilTest, TestCookieDateParsing) { |
61 const struct { | 57 const struct { |
62 const char* str; | 58 const char* str; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 cookie_util::GetEffectiveDomain("ws", "www.example.com")); | 246 cookie_util::GetEffectiveDomain("ws", "www.example.com")); |
251 EXPECT_EQ("example.com", | 247 EXPECT_EQ("example.com", |
252 cookie_util::GetEffectiveDomain("wss", "www.example.com")); | 248 cookie_util::GetEffectiveDomain("wss", "www.example.com")); |
253 EXPECT_EQ("www.example.com", | 249 EXPECT_EQ("www.example.com", |
254 cookie_util::GetEffectiveDomain("ftp", "www.example.com")); | 250 cookie_util::GetEffectiveDomain("ftp", "www.example.com")); |
255 } | 251 } |
256 | 252 |
257 } // namespace | 253 } // namespace |
258 | 254 |
259 } // namespace net | 255 } // namespace net |
OLD | NEW |