OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_store_ios_test_util.h" | 5 #include "ios/net/cookies/cookie_store_ios_test_util.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
| 9 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
10 #import "ios/net/cookies/cookie_store_ios.h" | 11 #import "ios/net/cookies/cookie_store_ios.h" |
11 #include "net/cookies/canonical_cookie.h" | 12 #include "net/cookies/canonical_cookie.h" |
12 #include "net/cookies/cookie_options.h" | 13 #include "net/cookies/cookie_options.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
(...skipping 15 matching lines...) Expand all Loading... |
34 void TestPersistentCookieStore::RunLoadedCallback() { | 35 void TestPersistentCookieStore::RunLoadedCallback() { |
35 std::vector<std::unique_ptr<net::CanonicalCookie>> cookies; | 36 std::vector<std::unique_ptr<net::CanonicalCookie>> cookies; |
36 net::CookieOptions options; | 37 net::CookieOptions options; |
37 options.set_include_httponly(); | 38 options.set_include_httponly(); |
38 | 39 |
39 std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( | 40 std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( |
40 kTestCookieURL, "a=b", base::Time::Now(), options)); | 41 kTestCookieURL, "a=b", base::Time::Now(), options)); |
41 cookies.push_back(std::move(cookie)); | 42 cookies.push_back(std::move(cookie)); |
42 | 43 |
43 std::unique_ptr<net::CanonicalCookie> bad_canonical_cookie( | 44 std::unique_ptr<net::CanonicalCookie> bad_canonical_cookie( |
44 net::CanonicalCookie::Create( | 45 base::MakeUnique<net::CanonicalCookie>( |
45 "name", "\x81r\xe4\xbd\xa0\xe5\xa5\xbd", "domain", "/path/", | 46 "name", "\x81r\xe4\xbd\xa0\xe5\xa5\xbd", "domain", "/path/", |
46 base::Time(), // creation | 47 base::Time(), // creation |
47 base::Time(), // expires | 48 base::Time(), // expires |
48 base::Time(), // last accessed | 49 base::Time(), // last accessed |
49 false, // secure | 50 false, // secure |
50 false, // httponly | 51 false, // httponly |
51 net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT)); | 52 net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT)); |
52 cookies.push_back(std::move(bad_canonical_cookie)); | 53 cookies.push_back(std::move(bad_canonical_cookie)); |
53 loaded_callback_.Run(std::move(cookies)); | 54 loaded_callback_.Run(std::move(cookies)); |
54 } | 55 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 void ClearCookies() { | 133 void ClearCookies() { |
133 NSHTTPCookieStorage* store = [NSHTTPCookieStorage sharedHTTPCookieStorage]; | 134 NSHTTPCookieStorage* store = [NSHTTPCookieStorage sharedHTTPCookieStorage]; |
134 [store setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; | 135 [store setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; |
135 NSArray* cookies = [store cookies]; | 136 NSArray* cookies = [store cookies]; |
136 for (NSHTTPCookie* cookie in cookies) | 137 for (NSHTTPCookie* cookie in cookies) |
137 [store deleteCookie:cookie]; | 138 [store deleteCookie:cookie]; |
138 EXPECT_EQ(0u, [[store cookies] count]); | 139 EXPECT_EQ(0u, [[store cookies] count]); |
139 } | 140 } |
140 | 141 |
141 } // namespace net | 142 } // namespace net |
OLD | NEW |