OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/net/cookies/cookie_cache.h" | 5 #include "ios/net/cookies/cookie_cache.h" |
6 | 6 |
7 #include "net/cookies/canonical_cookie.h" | 7 #include "net/cookies/canonical_cookie.h" |
8 #include "net/cookies/cookie_constants.h" | 8 #include "net/cookies/cookie_constants.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 using net::CanonicalCookie; | 13 using net::CanonicalCookie; |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 CanonicalCookie MakeCookie(const GURL& url, | 17 CanonicalCookie MakeCookie(const GURL& url, |
18 const std::string& name, | 18 const std::string& name, |
19 const std::string& value) { | 19 const std::string& value) { |
20 return CanonicalCookie(url, name, value, url.host(), url.path(), base::Time(), | 20 return CanonicalCookie(url, name, value, url.host(), url.path(), base::Time(), |
21 base::Time(), base::Time(), false, false, false, | 21 base::Time(), base::Time(), false, false, |
| 22 net::CookieSameSite::DEFAULT_MODE, |
22 net::COOKIE_PRIORITY_DEFAULT); | 23 net::COOKIE_PRIORITY_DEFAULT); |
23 } | 24 } |
24 | 25 |
25 } // namespace | 26 } // namespace |
26 | 27 |
27 TEST(CookieCacheTest, UpdateAddsCookieAllowsnullptr) { | 28 TEST(CookieCacheTest, UpdateAddsCookieAllowsnullptr) { |
28 CookieCache cache; | 29 CookieCache cache; |
29 const GURL test_url("http://www.google.com"); | 30 const GURL test_url("http://www.google.com"); |
30 std::vector<CanonicalCookie> cookies; | 31 std::vector<CanonicalCookie> cookies; |
31 cookies.push_back(MakeCookie(test_url, "abc", "def")); | 32 cookies.push_back(MakeCookie(test_url, "abc", "def")); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 EXPECT_TRUE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); | 160 EXPECT_TRUE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); |
160 EXPECT_FALSE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); | 161 EXPECT_FALSE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); |
161 cookies[0] = MakeCookie(cookieurl, "def", "def"); | 162 cookies[0] = MakeCookie(cookieurl, "def", "def"); |
162 EXPECT_TRUE(cache.Update(cookieurl, "def", cookies, nullptr, nullptr)); | 163 EXPECT_TRUE(cache.Update(cookieurl, "def", cookies, nullptr, nullptr)); |
163 EXPECT_FALSE(cache.Update(cookieurl, "def", cookies, nullptr, nullptr)); | 164 EXPECT_FALSE(cache.Update(cookieurl, "def", cookies, nullptr, nullptr)); |
164 cookies[0] = MakeCookie(cookieurl, "abc", "def"); | 165 cookies[0] = MakeCookie(cookieurl, "abc", "def"); |
165 EXPECT_FALSE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); | 166 EXPECT_FALSE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); |
166 } | 167 } |
167 | 168 |
168 } // namespace net | 169 } // namespace net |
OLD | NEW |