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 #ifndef NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 5 #ifndef NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
6 #define NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 6 #define NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 // Helper methods for the asynchronous Cookie Store API that call the | 84 // Helper methods for the asynchronous Cookie Store API that call the |
85 // asynchronous method and then pump the loop until the callback is invoked, | 85 // asynchronous method and then pump the loop until the callback is invoked, |
86 // finally returning the value. | 86 // finally returning the value. |
87 | 87 |
88 std::string GetCookies(CookieStore* cs, const GURL& url) { | 88 std::string GetCookies(CookieStore* cs, const GURL& url) { |
89 DCHECK(cs); | 89 DCHECK(cs); |
90 CookieOptions options; | 90 CookieOptions options; |
91 if (!CookieStoreTestTraits::supports_http_only) | 91 if (!CookieStoreTestTraits::supports_http_only) |
92 options.set_include_httponly(); | 92 options.set_include_httponly(); |
93 GetCookieStringCallback callback; | 93 StringResultCookieCallback callback; |
94 cs->GetCookiesWithOptionsAsync( | 94 cs->GetCookiesWithOptionsAsync( |
95 url, options, | 95 url, options, |
96 base::Bind(&GetCookieStringCallback::Run, base::Unretained(&callback))); | 96 base::Bind(&StringResultCookieCallback::Run, |
| 97 base::Unretained(&callback))); |
97 RunFor(kTimeout); | 98 RunFor(kTimeout); |
98 EXPECT_TRUE(callback.did_run()); | 99 EXPECT_TRUE(callback.did_run()); |
99 return callback.cookie(); | 100 return callback.result(); |
100 } | 101 } |
101 | 102 |
102 std::string GetCookiesWithOptions(CookieStore* cs, | 103 std::string GetCookiesWithOptions(CookieStore* cs, |
103 const GURL& url, | 104 const GURL& url, |
104 const CookieOptions& options) { | 105 const CookieOptions& options) { |
105 DCHECK(cs); | 106 DCHECK(cs); |
106 GetCookieStringCallback callback; | 107 StringResultCookieCallback callback; |
107 cs->GetCookiesWithOptionsAsync( | 108 cs->GetCookiesWithOptionsAsync( |
108 url, options, base::Bind(&GetCookieStringCallback::Run, | 109 url, options, base::Bind(&StringResultCookieCallback::Run, |
109 base::Unretained(&callback))); | 110 base::Unretained(&callback))); |
110 RunFor(kTimeout); | 111 RunFor(kTimeout); |
111 EXPECT_TRUE(callback.did_run()); | 112 EXPECT_TRUE(callback.did_run()); |
112 return callback.cookie(); | 113 return callback.result(); |
113 } | 114 } |
114 | 115 |
115 bool SetCookieWithOptions(CookieStore* cs, | 116 bool SetCookieWithOptions(CookieStore* cs, |
116 const GURL& url, | 117 const GURL& url, |
117 const std::string& cookie_line, | 118 const std::string& cookie_line, |
118 const CookieOptions& options) { | 119 const CookieOptions& options) { |
119 DCHECK(cs); | 120 DCHECK(cs); |
120 SetCookieCallback callback; | 121 BoolResultCookieCallback callback; |
121 cs->SetCookieWithOptionsAsync( | 122 cs->SetCookieWithOptionsAsync( |
122 url, cookie_line, options, | 123 url, cookie_line, options, |
123 base::Bind(&SetCookieCallback::Run, base::Unretained(&callback))); | 124 base::Bind(&BoolResultCookieCallback::Run, |
| 125 base::Unretained(&callback))); |
124 RunFor(kTimeout); | 126 RunFor(kTimeout); |
125 EXPECT_TRUE(callback.did_run()); | 127 EXPECT_TRUE(callback.did_run()); |
126 return callback.result(); | 128 return callback.result(); |
127 } | 129 } |
128 | 130 |
129 bool SetCookieWithServerTime(CookieStore* cs, | 131 bool SetCookieWithServerTime(CookieStore* cs, |
130 const GURL& url, | 132 const GURL& url, |
131 const std::string& cookie_line, | 133 const std::string& cookie_line, |
132 const base::Time& server_time) { | 134 const base::Time& server_time) { |
133 CookieOptions options; | 135 CookieOptions options; |
134 if (!CookieStoreTestTraits::supports_http_only) | 136 if (!CookieStoreTestTraits::supports_http_only) |
135 options.set_include_httponly(); | 137 options.set_include_httponly(); |
136 options.set_server_time(server_time); | 138 options.set_server_time(server_time); |
137 return SetCookieWithOptions(cs, url, cookie_line, options); | 139 return SetCookieWithOptions(cs, url, cookie_line, options); |
138 } | 140 } |
139 | 141 |
140 bool SetCookie(CookieStore* cs, | 142 bool SetCookie(CookieStore* cs, |
141 const GURL& url, | 143 const GURL& url, |
142 const std::string& cookie_line) { | 144 const std::string& cookie_line) { |
143 CookieOptions options; | 145 CookieOptions options; |
144 if (!CookieStoreTestTraits::supports_http_only) | 146 if (!CookieStoreTestTraits::supports_http_only) |
145 options.set_include_httponly(); | 147 options.set_include_httponly(); |
146 return SetCookieWithOptions(cs, url, cookie_line, options); | 148 return SetCookieWithOptions(cs, url, cookie_line, options); |
147 } | 149 } |
148 | 150 |
149 void DeleteCookie(CookieStore* cs, | 151 void DeleteCookie(CookieStore* cs, |
150 const GURL& url, | 152 const GURL& url, |
151 const std::string& cookie_name) { | 153 const std::string& cookie_name) { |
152 DCHECK(cs); | 154 DCHECK(cs); |
153 DeleteCookieCallback callback; | 155 NoResultCookieCallback callback; |
154 cs->DeleteCookieAsync( | 156 cs->DeleteCookieAsync( |
155 url, cookie_name, | 157 url, cookie_name, |
156 base::Bind(&DeleteCookieCallback::Run, base::Unretained(&callback))); | 158 base::Bind(&NoResultCookieCallback::Run, base::Unretained(&callback))); |
157 RunFor(kTimeout); | 159 RunFor(kTimeout); |
158 EXPECT_TRUE(callback.did_run()); | 160 EXPECT_TRUE(callback.did_run()); |
159 } | 161 } |
160 | 162 |
161 int DeleteCreatedBetween(CookieStore* cs, | 163 int DeleteCreatedBetween(CookieStore* cs, |
162 const base::Time& delete_begin, | 164 const base::Time& delete_begin, |
163 const base::Time& delete_end) { | 165 const base::Time& delete_end) { |
164 DCHECK(cs); | 166 DCHECK(cs); |
165 DeleteCallback callback; | 167 IntResultCookieCallback callback; |
166 cs->DeleteAllCreatedBetweenAsync( | 168 cs->DeleteAllCreatedBetweenAsync( |
167 delete_begin, delete_end, | 169 delete_begin, delete_end, |
168 base::Bind(&DeleteCallback::Run, base::Unretained(&callback))); | 170 base::Bind(&IntResultCookieCallback::Run, base::Unretained(&callback))); |
169 RunFor(kTimeout); | 171 RunFor(kTimeout); |
170 EXPECT_TRUE(callback.did_run()); | 172 EXPECT_TRUE(callback.did_run()); |
171 return callback.num_deleted(); | 173 return callback.result(); |
172 } | 174 } |
173 | 175 |
174 int DeleteSessionCookies(CookieStore* cs) { | 176 int DeleteSessionCookies(CookieStore* cs) { |
175 DCHECK(cs); | 177 DCHECK(cs); |
176 DeleteCallback callback; | 178 IntResultCookieCallback callback; |
177 cs->DeleteSessionCookiesAsync( | 179 cs->DeleteSessionCookiesAsync( |
178 base::Bind(&DeleteCallback::Run, base::Unretained(&callback))); | 180 base::Bind(&IntResultCookieCallback::Run, base::Unretained(&callback))); |
179 RunFor(kTimeout); | 181 RunFor(kTimeout); |
180 EXPECT_TRUE(callback.did_run()); | 182 EXPECT_TRUE(callback.did_run()); |
181 return callback.num_deleted(); | 183 return callback.result(); |
182 } | 184 } |
183 | 185 |
184 void RunFor(int ms) { | 186 void RunFor(int ms) { |
185 // Runs the test thread message loop for up to |ms| milliseconds. | 187 // Runs the test thread message loop for up to |ms| milliseconds. |
186 MessageLoop::current()->PostDelayedTask( | 188 MessageLoop::current()->PostDelayedTask( |
187 FROM_HERE, base::Bind(&MessageLoop::Quit, weak_factory_->GetWeakPtr()), | 189 FROM_HERE, base::Bind(&MessageLoop::Quit, weak_factory_->GetWeakPtr()), |
188 base::TimeDelta::FromMilliseconds(ms)); | 190 base::TimeDelta::FromMilliseconds(ms)); |
189 MessageLoop::current()->Run(); | 191 MessageLoop::current()->Run(); |
190 weak_factory_->InvalidateWeakPtrs(); | 192 weak_factory_->InvalidateWeakPtrs(); |
191 } | 193 } |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 class MultiThreadedCookieStoreTest : | 937 class MultiThreadedCookieStoreTest : |
936 public CookieStoreTest<CookieStoreTestTraits> { | 938 public CookieStoreTest<CookieStoreTestTraits> { |
937 public: | 939 public: |
938 MultiThreadedCookieStoreTest() : other_thread_("CMTthread") {} | 940 MultiThreadedCookieStoreTest() : other_thread_("CMTthread") {} |
939 | 941 |
940 // Helper methods for calling the asynchronous CookieStore methods | 942 // Helper methods for calling the asynchronous CookieStore methods |
941 // from a different thread. | 943 // from a different thread. |
942 | 944 |
943 void GetCookiesTask(CookieStore* cs, | 945 void GetCookiesTask(CookieStore* cs, |
944 const GURL& url, | 946 const GURL& url, |
945 GetCookieStringCallback* callback) { | 947 StringResultCookieCallback* callback) { |
946 CookieOptions options; | 948 CookieOptions options; |
947 if (!CookieStoreTestTraits::supports_http_only) | 949 if (!CookieStoreTestTraits::supports_http_only) |
948 options.set_include_httponly(); | 950 options.set_include_httponly(); |
949 cs->GetCookiesWithOptionsAsync( | 951 cs->GetCookiesWithOptionsAsync( |
950 url, options, | 952 url, options, |
951 base::Bind(&GetCookieStringCallback::Run, base::Unretained(callback))); | 953 base::Bind(&StringResultCookieCallback::Run, |
| 954 base::Unretained(callback))); |
952 } | 955 } |
953 | 956 |
954 void GetCookiesWithOptionsTask(CookieStore* cs, | 957 void GetCookiesWithOptionsTask(CookieStore* cs, |
955 const GURL& url, | 958 const GURL& url, |
956 const CookieOptions& options, | 959 const CookieOptions& options, |
957 GetCookieStringCallback* callback) { | 960 StringResultCookieCallback* callback) { |
958 cs->GetCookiesWithOptionsAsync( | 961 cs->GetCookiesWithOptionsAsync( |
959 url, options, | 962 url, options, |
960 base::Bind(&GetCookieStringCallback::Run, base::Unretained(callback))); | 963 base::Bind(&StringResultCookieCallback::Run, |
| 964 base::Unretained(callback))); |
961 } | 965 } |
962 | 966 |
963 void SetCookieWithOptionsTask(CookieStore* cs, | 967 void SetCookieWithOptionsTask(CookieStore* cs, |
964 const GURL& url, | 968 const GURL& url, |
965 const std::string& cookie_line, | 969 const std::string& cookie_line, |
966 const CookieOptions& options, | 970 const CookieOptions& options, |
967 SetCookieCallback* callback) { | 971 BoolResultCookieCallback* callback) { |
968 cs->SetCookieWithOptionsAsync( | 972 cs->SetCookieWithOptionsAsync( |
969 url, cookie_line, options, | 973 url, cookie_line, options, |
970 base::Bind(&SetCookieCallback::Run, base::Unretained(callback))); | 974 base::Bind(&BoolResultCookieCallback::Run, base::Unretained(callback))); |
971 } | 975 } |
972 | 976 |
973 void DeleteCookieTask(CookieStore* cs, | 977 void DeleteCookieTask(CookieStore* cs, |
974 const GURL& url, | 978 const GURL& url, |
975 const std::string& cookie_name, | 979 const std::string& cookie_name, |
976 DeleteCookieCallback* callback) { | 980 NoResultCookieCallback* callback) { |
977 cs->DeleteCookieAsync( | 981 cs->DeleteCookieAsync( |
978 url, cookie_name, | 982 url, cookie_name, |
979 base::Bind(&DeleteCookieCallback::Run, base::Unretained(callback))); | 983 base::Bind(&NoResultCookieCallback::Run, base::Unretained(callback))); |
980 } | 984 } |
981 | 985 |
982 void DeleteSessionCookiesTask(CookieStore* cs, DeleteCallback* callback) { | 986 void DeleteSessionCookiesTask(CookieStore* cs, |
| 987 IntResultCookieCallback* callback) { |
983 cs->DeleteSessionCookiesAsync( | 988 cs->DeleteSessionCookiesAsync( |
984 base::Bind(&DeleteCallback::Run, base::Unretained(callback))); | 989 base::Bind(&IntResultCookieCallback::Run, base::Unretained(callback))); |
985 } | 990 } |
986 | 991 |
987 protected: | 992 protected: |
988 void RunOnOtherThread(const base::Closure& task) { | 993 void RunOnOtherThread(const base::Closure& task) { |
989 other_thread_.Start(); | 994 other_thread_.Start(); |
990 other_thread_.message_loop()->PostTask(FROM_HERE, task); | 995 other_thread_.message_loop()->PostTask(FROM_HERE, task); |
991 CookieStoreTest<CookieStoreTestTraits>::RunFor(kTimeout); | 996 CookieStoreTest<CookieStoreTestTraits>::RunFor(kTimeout); |
992 other_thread_.Stop(); | 997 other_thread_.Stop(); |
993 } | 998 } |
994 | 999 |
995 Thread other_thread_; | 1000 Thread other_thread_; |
996 }; | 1001 }; |
997 | 1002 |
998 TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest); | 1003 TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest); |
999 | 1004 |
1000 // TODO(ycxiao): Eventually, we will need to create a separate thread, create | 1005 // TODO(ycxiao): Eventually, we will need to create a separate thread, create |
1001 // the cookie store on that thread (or at least its store, i.e., the DB | 1006 // the cookie store on that thread (or at least its store, i.e., the DB |
1002 // thread). | 1007 // thread). |
1003 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookies) { | 1008 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookies) { |
1004 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1009 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
1005 EXPECT_TRUE(this->SetCookie(cs, this->url_google_, "A=B")); | 1010 EXPECT_TRUE(this->SetCookie(cs, this->url_google_, "A=B")); |
1006 this->MatchCookieLines("A=B", this->GetCookies(cs, this->url_google_)); | 1011 this->MatchCookieLines("A=B", this->GetCookies(cs, this->url_google_)); |
1007 GetCookieStringCallback callback(&this->other_thread_); | 1012 StringResultCookieCallback callback(&this->other_thread_); |
1008 base::Closure task = base::Bind( | 1013 base::Closure task = base::Bind( |
1009 &net::MultiThreadedCookieStoreTest<TypeParam>::GetCookiesTask, | 1014 &net::MultiThreadedCookieStoreTest<TypeParam>::GetCookiesTask, |
1010 base::Unretained(this), | 1015 base::Unretained(this), |
1011 cs, this->url_google_, &callback); | 1016 cs, this->url_google_, &callback); |
1012 this->RunOnOtherThread(task); | 1017 this->RunOnOtherThread(task); |
1013 EXPECT_TRUE(callback.did_run()); | 1018 EXPECT_TRUE(callback.did_run()); |
1014 EXPECT_EQ("A=B", callback.cookie()); | 1019 EXPECT_EQ("A=B", callback.result()); |
1015 } | 1020 } |
1016 | 1021 |
1017 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookiesWithOptions) { | 1022 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookiesWithOptions) { |
1018 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1023 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
1019 CookieOptions options; | 1024 CookieOptions options; |
1020 if (!TypeParam::supports_http_only) | 1025 if (!TypeParam::supports_http_only) |
1021 options.set_include_httponly(); | 1026 options.set_include_httponly(); |
1022 EXPECT_TRUE(this->SetCookie(cs, this->url_google_, "A=B")); | 1027 EXPECT_TRUE(this->SetCookie(cs, this->url_google_, "A=B")); |
1023 this->MatchCookieLines("A=B", | 1028 this->MatchCookieLines("A=B", |
1024 this->GetCookiesWithOptions(cs, this->url_google_, options)); | 1029 this->GetCookiesWithOptions(cs, this->url_google_, options)); |
1025 GetCookieStringCallback callback(&this->other_thread_); | 1030 StringResultCookieCallback callback(&this->other_thread_); |
1026 base::Closure task = base::Bind( | 1031 base::Closure task = base::Bind( |
1027 &net::MultiThreadedCookieStoreTest<TypeParam>::GetCookiesWithOptionsTask, | 1032 &net::MultiThreadedCookieStoreTest<TypeParam>::GetCookiesWithOptionsTask, |
1028 base::Unretained(this), | 1033 base::Unretained(this), |
1029 cs, this->url_google_, options, &callback); | 1034 cs, this->url_google_, options, &callback); |
1030 this->RunOnOtherThread(task); | 1035 this->RunOnOtherThread(task); |
1031 EXPECT_TRUE(callback.did_run()); | 1036 EXPECT_TRUE(callback.did_run()); |
1032 EXPECT_EQ("A=B", callback.cookie()); | 1037 EXPECT_EQ("A=B", callback.result()); |
1033 } | 1038 } |
1034 | 1039 |
1035 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckSetCookieWithOptions) { | 1040 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckSetCookieWithOptions) { |
1036 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1041 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
1037 CookieOptions options; | 1042 CookieOptions options; |
1038 if (!TypeParam::supports_http_only) | 1043 if (!TypeParam::supports_http_only) |
1039 options.set_include_httponly(); | 1044 options.set_include_httponly(); |
1040 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, "A=B", | 1045 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, "A=B", |
1041 options)); | 1046 options)); |
1042 SetCookieCallback callback(&this->other_thread_); | 1047 BoolResultCookieCallback callback(&this->other_thread_); |
1043 base::Closure task = base::Bind( | 1048 base::Closure task = base::Bind( |
1044 &net::MultiThreadedCookieStoreTest<TypeParam>::SetCookieWithOptionsTask, | 1049 &net::MultiThreadedCookieStoreTest<TypeParam>::SetCookieWithOptionsTask, |
1045 base::Unretained(this), | 1050 base::Unretained(this), |
1046 cs, this->url_google_, "A=B", options, &callback); | 1051 cs, this->url_google_, "A=B", options, &callback); |
1047 this->RunOnOtherThread(task); | 1052 this->RunOnOtherThread(task); |
1048 EXPECT_TRUE(callback.did_run()); | 1053 EXPECT_TRUE(callback.did_run()); |
1049 EXPECT_TRUE(callback.result()); | 1054 EXPECT_TRUE(callback.result()); |
1050 } | 1055 } |
1051 | 1056 |
1052 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteCookie) { | 1057 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteCookie) { |
1053 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1058 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
1054 CookieOptions options; | 1059 CookieOptions options; |
1055 if (!TypeParam::supports_http_only) | 1060 if (!TypeParam::supports_http_only) |
1056 options.set_include_httponly(); | 1061 options.set_include_httponly(); |
1057 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, "A=B", | 1062 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, "A=B", |
1058 options)); | 1063 options)); |
1059 this->DeleteCookie(cs, this->url_google_, "A"); | 1064 this->DeleteCookie(cs, this->url_google_, "A"); |
1060 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, "A=B", | 1065 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, "A=B", |
1061 options)); | 1066 options)); |
1062 DeleteCookieCallback callback(&this->other_thread_); | 1067 NoResultCookieCallback callback(&this->other_thread_); |
1063 base::Closure task = base::Bind( | 1068 base::Closure task = base::Bind( |
1064 &net::MultiThreadedCookieStoreTest<TypeParam>::DeleteCookieTask, | 1069 &net::MultiThreadedCookieStoreTest<TypeParam>::DeleteCookieTask, |
1065 base::Unretained(this), | 1070 base::Unretained(this), |
1066 cs, this->url_google_, "A", &callback); | 1071 cs, this->url_google_, "A", &callback); |
1067 this->RunOnOtherThread(task); | 1072 this->RunOnOtherThread(task); |
1068 EXPECT_TRUE(callback.did_run()); | 1073 EXPECT_TRUE(callback.did_run()); |
1069 } | 1074 } |
1070 | 1075 |
1071 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) { | 1076 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) { |
1072 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1077 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
1073 CookieOptions options; | 1078 CookieOptions options; |
1074 if (!TypeParam::supports_http_only) | 1079 if (!TypeParam::supports_http_only) |
1075 options.set_include_httponly(); | 1080 options.set_include_httponly(); |
1076 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, | 1081 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, |
1077 "A=B", options)); | 1082 "A=B", options)); |
1078 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, | 1083 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, |
1079 "B=C; expires=Mon, 18-Apr-22 22:50:13 GMT", options)); | 1084 "B=C; expires=Mon, 18-Apr-22 22:50:13 GMT", options)); |
1080 EXPECT_EQ(1, this->DeleteSessionCookies(cs)); | 1085 EXPECT_EQ(1, this->DeleteSessionCookies(cs)); |
1081 EXPECT_EQ(0, this->DeleteSessionCookies(cs)); | 1086 EXPECT_EQ(0, this->DeleteSessionCookies(cs)); |
1082 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, | 1087 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, |
1083 "A=B", options)); | 1088 "A=B", options)); |
1084 DeleteCallback callback(&this->other_thread_); | 1089 IntResultCookieCallback callback(&this->other_thread_); |
1085 base::Closure task = base::Bind( | 1090 base::Closure task = base::Bind( |
1086 &net::MultiThreadedCookieStoreTest<TypeParam>::DeleteSessionCookiesTask, | 1091 &net::MultiThreadedCookieStoreTest<TypeParam>::DeleteSessionCookiesTask, |
1087 base::Unretained(this), | 1092 base::Unretained(this), |
1088 cs, &callback); | 1093 cs, &callback); |
1089 this->RunOnOtherThread(task); | 1094 this->RunOnOtherThread(task); |
1090 EXPECT_TRUE(callback.did_run()); | 1095 EXPECT_TRUE(callback.did_run()); |
1091 EXPECT_EQ(1, callback.num_deleted()); | 1096 EXPECT_EQ(1, callback.result()); |
1092 } | 1097 } |
1093 | 1098 |
1094 REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, | 1099 REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, |
1095 ThreadCheckGetCookies, | 1100 ThreadCheckGetCookies, |
1096 ThreadCheckGetCookiesWithOptions, | 1101 ThreadCheckGetCookiesWithOptions, |
1097 ThreadCheckSetCookieWithOptions, | 1102 ThreadCheckSetCookieWithOptions, |
1098 ThreadCheckDeleteCookie, | 1103 ThreadCheckDeleteCookie, |
1099 ThreadCheckDeleteSessionCookies); | 1104 ThreadCheckDeleteSessionCookies); |
1100 | 1105 |
1101 } // namespace net | 1106 } // namespace net |
1102 | 1107 |
1103 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 1108 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
OLD | NEW |