| 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::Create(url, name, value, std::string(), url.path(), | 20 return *CanonicalCookie::Create(url, name, value, std::string(), url.path(), |
| 21 base::Time(), base::Time(), false, false, | 21 base::Time(), base::Time(), false, false, |
| 22 net::CookieSameSite::DEFAULT_MODE, false, | 22 net::CookieSameSite::DEFAULT_MODE, |
| 23 net::COOKIE_PRIORITY_DEFAULT); | 23 net::COOKIE_PRIORITY_DEFAULT); |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 TEST(CookieCacheTest, UpdateAddsCookieAllowsnullptr) { | 28 TEST(CookieCacheTest, UpdateAddsCookieAllowsnullptr) { |
| 29 CookieCache cache; | 29 CookieCache cache; |
| 30 const GURL test_url("http://www.google.com"); | 30 const GURL test_url("http://www.google.com"); |
| 31 std::vector<CanonicalCookie> cookies; | 31 std::vector<CanonicalCookie> cookies; |
| 32 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... |
| 160 EXPECT_TRUE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); | 160 EXPECT_TRUE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); |
| 161 EXPECT_FALSE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); | 161 EXPECT_FALSE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); |
| 162 cookies[0] = MakeCookie(cookieurl, "def", "def"); | 162 cookies[0] = MakeCookie(cookieurl, "def", "def"); |
| 163 EXPECT_TRUE(cache.Update(cookieurl, "def", cookies, nullptr, nullptr)); | 163 EXPECT_TRUE(cache.Update(cookieurl, "def", cookies, nullptr, nullptr)); |
| 164 EXPECT_FALSE(cache.Update(cookieurl, "def", cookies, nullptr, nullptr)); | 164 EXPECT_FALSE(cache.Update(cookieurl, "def", cookies, nullptr, nullptr)); |
| 165 cookies[0] = MakeCookie(cookieurl, "abc", "def"); | 165 cookies[0] = MakeCookie(cookieurl, "abc", "def"); |
| 166 EXPECT_FALSE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); | 166 EXPECT_FALSE(cache.Update(cookieurl, "abc", cookies, nullptr, nullptr)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace net | 169 } // namespace net |
| OLD | NEW |