| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 std::string GetCookies(CookieStore* cs, const GURL& url) { | 102 std::string GetCookies(CookieStore* cs, const GURL& url) { |
| 103 DCHECK(cs); | 103 DCHECK(cs); |
| 104 CookieOptions options; | 104 CookieOptions options; |
| 105 if (!CookieStoreTestTraits::supports_http_only) | 105 if (!CookieStoreTestTraits::supports_http_only) |
| 106 options.set_include_httponly(); | 106 options.set_include_httponly(); |
| 107 StringResultCookieCallback callback; | 107 StringResultCookieCallback callback; |
| 108 cs->GetCookiesWithOptionsAsync( | 108 cs->GetCookiesWithOptionsAsync( |
| 109 url, options, | 109 url, options, |
| 110 base::Bind(&StringResultCookieCallback::Run, | 110 base::Bind(&StringResultCookieCallback::Run, |
| 111 base::Unretained(&callback))); | 111 base::Unretained(&callback))); |
| 112 RunFor(kTimeout); | 112 callback.WaitUntilDone(); |
| 113 EXPECT_TRUE(callback.did_run()); | 113 EXPECT_TRUE(callback.did_run()); |
| 114 return callback.result(); | 114 return callback.result(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 std::string GetCookiesWithOptions(CookieStore* cs, | 117 std::string GetCookiesWithOptions(CookieStore* cs, |
| 118 const GURL& url, | 118 const GURL& url, |
| 119 const CookieOptions& options) { | 119 const CookieOptions& options) { |
| 120 DCHECK(cs); | 120 DCHECK(cs); |
| 121 StringResultCookieCallback callback; | 121 StringResultCookieCallback callback; |
| 122 cs->GetCookiesWithOptionsAsync( | 122 cs->GetCookiesWithOptionsAsync( |
| 123 url, options, base::Bind(&StringResultCookieCallback::Run, | 123 url, options, base::Bind(&StringResultCookieCallback::Run, |
| 124 base::Unretained(&callback))); | 124 base::Unretained(&callback))); |
| 125 RunFor(kTimeout); | 125 callback.WaitUntilDone(); |
| 126 EXPECT_TRUE(callback.did_run()); | 126 EXPECT_TRUE(callback.did_run()); |
| 127 return callback.result(); | 127 return callback.result(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 CookieList GetAllCookies(CookieStore* cs) { | 130 CookieList GetAllCookies(CookieStore* cs) { |
| 131 DCHECK(cs); | 131 DCHECK(cs); |
| 132 GetCookieListCallback callback; | 132 GetCookieListCallback callback; |
| 133 cs->GetAllCookiesAsync( | 133 cs->GetAllCookiesAsync( |
| 134 base::Bind(&GetCookieListCallback::Run, base::Unretained(&callback))); | 134 base::Bind(&GetCookieListCallback::Run, base::Unretained(&callback))); |
| 135 RunFor(kTimeout); | 135 callback.WaitUntilDone(); |
| 136 EXPECT_TRUE(callback.did_run()); | 136 EXPECT_TRUE(callback.did_run()); |
| 137 return callback.cookies(); | 137 return callback.cookies(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool SetCookieWithOptions(CookieStore* cs, | 140 bool SetCookieWithOptions(CookieStore* cs, |
| 141 const GURL& url, | 141 const GURL& url, |
| 142 const std::string& cookie_line, | 142 const std::string& cookie_line, |
| 143 const CookieOptions& options) { | 143 const CookieOptions& options) { |
| 144 DCHECK(cs); | 144 DCHECK(cs); |
| 145 ResultSavingCookieCallback<bool> callback; | 145 ResultSavingCookieCallback<bool> callback; |
| 146 cs->SetCookieWithOptionsAsync( | 146 cs->SetCookieWithOptionsAsync( |
| 147 url, cookie_line, options, | 147 url, cookie_line, options, |
| 148 base::Bind( | 148 base::Bind( |
| 149 &ResultSavingCookieCallback<bool>::Run, | 149 &ResultSavingCookieCallback<bool>::Run, |
| 150 base::Unretained(&callback))); | 150 base::Unretained(&callback))); |
| 151 RunFor(kTimeout); | 151 callback.WaitUntilDone(); |
| 152 EXPECT_TRUE(callback.did_run()); | 152 EXPECT_TRUE(callback.did_run()); |
| 153 return callback.result(); | 153 return callback.result(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool SetCookieWithServerTime(CookieStore* cs, | 156 bool SetCookieWithServerTime(CookieStore* cs, |
| 157 const GURL& url, | 157 const GURL& url, |
| 158 const std::string& cookie_line, | 158 const std::string& cookie_line, |
| 159 const base::Time& server_time) { | 159 const base::Time& server_time) { |
| 160 CookieOptions options; | 160 CookieOptions options; |
| 161 if (!CookieStoreTestTraits::supports_http_only) | 161 if (!CookieStoreTestTraits::supports_http_only) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 176 } | 176 } |
| 177 | 177 |
| 178 void DeleteCookie(CookieStore* cs, | 178 void DeleteCookie(CookieStore* cs, |
| 179 const GURL& url, | 179 const GURL& url, |
| 180 const std::string& cookie_name) { | 180 const std::string& cookie_name) { |
| 181 DCHECK(cs); | 181 DCHECK(cs); |
| 182 NoResultCookieCallback callback; | 182 NoResultCookieCallback callback; |
| 183 cs->DeleteCookieAsync( | 183 cs->DeleteCookieAsync( |
| 184 url, cookie_name, | 184 url, cookie_name, |
| 185 base::Bind(&NoResultCookieCallback::Run, base::Unretained(&callback))); | 185 base::Bind(&NoResultCookieCallback::Run, base::Unretained(&callback))); |
| 186 RunFor(kTimeout); | 186 callback.WaitUntilDone(); |
| 187 EXPECT_TRUE(callback.did_run()); | 187 EXPECT_TRUE(callback.did_run()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 int DeleteCreatedBetween(CookieStore* cs, | 190 int DeleteCreatedBetween(CookieStore* cs, |
| 191 const base::Time& delete_begin, | 191 const base::Time& delete_begin, |
| 192 const base::Time& delete_end) { | 192 const base::Time& delete_end) { |
| 193 DCHECK(cs); | 193 DCHECK(cs); |
| 194 ResultSavingCookieCallback<int> callback; | 194 ResultSavingCookieCallback<int> callback; |
| 195 cs->DeleteAllCreatedBetweenAsync( | 195 cs->DeleteAllCreatedBetweenAsync( |
| 196 delete_begin, delete_end, | 196 delete_begin, delete_end, |
| 197 base::Bind( | 197 base::Bind( |
| 198 &ResultSavingCookieCallback<int>::Run, | 198 &ResultSavingCookieCallback<int>::Run, |
| 199 base::Unretained(&callback))); | 199 base::Unretained(&callback))); |
| 200 RunFor(kTimeout); | 200 callback.WaitUntilDone(); |
| 201 EXPECT_TRUE(callback.did_run()); | 201 EXPECT_TRUE(callback.did_run()); |
| 202 return callback.result(); | 202 return callback.result(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 int DeleteAllCreatedBetweenForHost(CookieStore* cs, | 205 int DeleteAllCreatedBetweenForHost(CookieStore* cs, |
| 206 const base::Time delete_begin, | 206 const base::Time delete_begin, |
| 207 const base::Time delete_end, | 207 const base::Time delete_end, |
| 208 const GURL& url) { | 208 const GURL& url) { |
| 209 DCHECK(cs); | 209 DCHECK(cs); |
| 210 ResultSavingCookieCallback<int> callback; | 210 ResultSavingCookieCallback<int> callback; |
| 211 cs->DeleteAllCreatedBetweenForHostAsync( | 211 cs->DeleteAllCreatedBetweenForHostAsync( |
| 212 delete_begin, delete_end, url, | 212 delete_begin, delete_end, url, |
| 213 base::Bind( | 213 base::Bind( |
| 214 &ResultSavingCookieCallback<int>::Run, | 214 &ResultSavingCookieCallback<int>::Run, |
| 215 base::Unretained(&callback))); | 215 base::Unretained(&callback))); |
| 216 RunFor(kTimeout); | 216 callback.WaitUntilDone(); |
| 217 EXPECT_TRUE(callback.did_run()); | 217 EXPECT_TRUE(callback.did_run()); |
| 218 return callback.result(); | 218 return callback.result(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 int DeleteSessionCookies(CookieStore* cs) { | 221 int DeleteSessionCookies(CookieStore* cs) { |
| 222 DCHECK(cs); | 222 DCHECK(cs); |
| 223 ResultSavingCookieCallback<int> callback; | 223 ResultSavingCookieCallback<int> callback; |
| 224 cs->DeleteSessionCookiesAsync( | 224 cs->DeleteSessionCookiesAsync( |
| 225 base::Bind( | 225 base::Bind( |
| 226 &ResultSavingCookieCallback<int>::Run, | 226 &ResultSavingCookieCallback<int>::Run, |
| 227 base::Unretained(&callback))); | 227 base::Unretained(&callback))); |
| 228 RunFor(kTimeout); | 228 callback.WaitUntilDone(); |
| 229 EXPECT_TRUE(callback.did_run()); | 229 EXPECT_TRUE(callback.did_run()); |
| 230 return callback.result(); | 230 return callback.result(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void RunFor(int ms) { | |
| 234 // Runs the test thread message loop for up to |ms| milliseconds. | |
| 235 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 236 FROM_HERE, base::Bind(&base::MessageLoop::QuitWhenIdle, | |
| 237 weak_factory_->GetWeakPtr()), | |
| 238 base::TimeDelta::FromMilliseconds(ms)); | |
| 239 base::MessageLoop::current()->Run(); | |
| 240 weak_factory_->InvalidateWeakPtrs(); | |
| 241 } | |
| 242 | |
| 243 scoped_refptr<CookieStore> GetCookieStore() { | 233 scoped_refptr<CookieStore> GetCookieStore() { |
| 244 return CookieStoreTestTraits::Create(); | 234 return CookieStoreTestTraits::Create(); |
| 245 } | 235 } |
| 246 | 236 |
| 247 // Compares two cookie lines. | 237 // Compares two cookie lines. |
| 248 void MatchCookieLines(const std::string& line1, const std::string& line2) { | 238 void MatchCookieLines(const std::string& line1, const std::string& line2) { |
| 249 EXPECT_EQ(TokenizeCookieLine(line1), TokenizeCookieLine(line2)); | 239 EXPECT_EQ(TokenizeCookieLine(line1), TokenizeCookieLine(line2)); |
| 250 } | 240 } |
| 251 | 241 |
| 252 // Check the cookie line by polling until equality or a timeout is reached. | 242 // Check the cookie line by polling until equality or a timeout is reached. |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 cs->DeleteSessionCookiesAsync( | 1201 cs->DeleteSessionCookiesAsync( |
| 1212 base::Bind( | 1202 base::Bind( |
| 1213 &ResultSavingCookieCallback<int>::Run, | 1203 &ResultSavingCookieCallback<int>::Run, |
| 1214 base::Unretained(callback))); | 1204 base::Unretained(callback))); |
| 1215 } | 1205 } |
| 1216 | 1206 |
| 1217 protected: | 1207 protected: |
| 1218 void RunOnOtherThread(const base::Closure& task) { | 1208 void RunOnOtherThread(const base::Closure& task) { |
| 1219 other_thread_.Start(); | 1209 other_thread_.Start(); |
| 1220 other_thread_.task_runner()->PostTask(FROM_HERE, task); | 1210 other_thread_.task_runner()->PostTask(FROM_HERE, task); |
| 1221 CookieStoreTest<CookieStoreTestTraits>::RunFor(kTimeout); | |
| 1222 other_thread_.Stop(); | 1211 other_thread_.Stop(); |
| 1223 } | 1212 } |
| 1224 | 1213 |
| 1225 Thread other_thread_; | 1214 Thread other_thread_; |
| 1226 }; | 1215 }; |
| 1227 | 1216 |
| 1228 TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest); | 1217 TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest); |
| 1229 | 1218 |
| 1230 // TODO(ycxiao): Eventually, we will need to create a separate thread, create | 1219 // TODO(ycxiao): Eventually, we will need to create a separate thread, create |
| 1231 // the cookie store on that thread (or at least its store, i.e., the DB | 1220 // the cookie store on that thread (or at least its store, i.e., the DB |
| 1232 // thread). | 1221 // thread). |
| 1233 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookies) { | 1222 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookies) { |
| 1234 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1223 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
| 1235 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B")); | 1224 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B")); |
| 1236 this->MatchCookieLines( | 1225 this->MatchCookieLines( |
| 1237 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 1226 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); |
| 1238 StringResultCookieCallback callback(&this->other_thread_); | 1227 StringResultCookieCallback callback(&this->other_thread_); |
| 1239 base::Closure task = base::Bind( | 1228 base::Closure task = base::Bind( |
| 1240 &MultiThreadedCookieStoreTest<TypeParam>::GetCookiesTask, | 1229 &MultiThreadedCookieStoreTest<TypeParam>::GetCookiesTask, |
| 1241 base::Unretained(this), cs, this->http_www_google_.url(), &callback); | 1230 base::Unretained(this), cs, this->http_www_google_.url(), &callback); |
| 1242 this->RunOnOtherThread(task); | 1231 this->RunOnOtherThread(task); |
| 1232 callback.WaitUntilDone(); |
| 1243 EXPECT_TRUE(callback.did_run()); | 1233 EXPECT_TRUE(callback.did_run()); |
| 1244 EXPECT_EQ("A=B", callback.result()); | 1234 EXPECT_EQ("A=B", callback.result()); |
| 1245 } | 1235 } |
| 1246 | 1236 |
| 1247 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookiesWithOptions) { | 1237 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookiesWithOptions) { |
| 1248 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1238 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
| 1249 CookieOptions options; | 1239 CookieOptions options; |
| 1250 if (!TypeParam::supports_http_only) | 1240 if (!TypeParam::supports_http_only) |
| 1251 options.set_include_httponly(); | 1241 options.set_include_httponly(); |
| 1252 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B")); | 1242 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B")); |
| 1253 this->MatchCookieLines( | 1243 this->MatchCookieLines( |
| 1254 "A=B", this->GetCookiesWithOptions(cs.get(), this->http_www_google_.url(), | 1244 "A=B", this->GetCookiesWithOptions(cs.get(), this->http_www_google_.url(), |
| 1255 options)); | 1245 options)); |
| 1256 StringResultCookieCallback callback(&this->other_thread_); | 1246 StringResultCookieCallback callback(&this->other_thread_); |
| 1257 base::Closure task = base::Bind( | 1247 base::Closure task = base::Bind( |
| 1258 &MultiThreadedCookieStoreTest<TypeParam>::GetCookiesWithOptionsTask, | 1248 &MultiThreadedCookieStoreTest<TypeParam>::GetCookiesWithOptionsTask, |
| 1259 base::Unretained(this), cs, this->http_www_google_.url(), options, | 1249 base::Unretained(this), cs, this->http_www_google_.url(), options, |
| 1260 &callback); | 1250 &callback); |
| 1261 this->RunOnOtherThread(task); | 1251 this->RunOnOtherThread(task); |
| 1252 callback.WaitUntilDone(); |
| 1262 EXPECT_TRUE(callback.did_run()); | 1253 EXPECT_TRUE(callback.did_run()); |
| 1263 EXPECT_EQ("A=B", callback.result()); | 1254 EXPECT_EQ("A=B", callback.result()); |
| 1264 } | 1255 } |
| 1265 | 1256 |
| 1266 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckSetCookieWithOptions) { | 1257 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckSetCookieWithOptions) { |
| 1267 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1258 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
| 1268 CookieOptions options; | 1259 CookieOptions options; |
| 1269 if (!TypeParam::supports_http_only) | 1260 if (!TypeParam::supports_http_only) |
| 1270 options.set_include_httponly(); | 1261 options.set_include_httponly(); |
| 1271 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), | 1262 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), |
| 1272 "A=B", options)); | 1263 "A=B", options)); |
| 1273 ResultSavingCookieCallback<bool> callback(&this->other_thread_); | 1264 ResultSavingCookieCallback<bool> callback(&this->other_thread_); |
| 1274 base::Closure task = base::Bind( | 1265 base::Closure task = base::Bind( |
| 1275 &MultiThreadedCookieStoreTest<TypeParam>::SetCookieWithOptionsTask, | 1266 &MultiThreadedCookieStoreTest<TypeParam>::SetCookieWithOptionsTask, |
| 1276 base::Unretained(this), cs, this->http_www_google_.url(), "A=B", options, | 1267 base::Unretained(this), cs, this->http_www_google_.url(), "A=B", options, |
| 1277 &callback); | 1268 &callback); |
| 1278 this->RunOnOtherThread(task); | 1269 this->RunOnOtherThread(task); |
| 1270 callback.WaitUntilDone(); |
| 1279 EXPECT_TRUE(callback.did_run()); | 1271 EXPECT_TRUE(callback.did_run()); |
| 1280 EXPECT_TRUE(callback.result()); | 1272 EXPECT_TRUE(callback.result()); |
| 1281 } | 1273 } |
| 1282 | 1274 |
| 1283 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteCookie) { | 1275 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteCookie) { |
| 1284 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1276 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
| 1285 CookieOptions options; | 1277 CookieOptions options; |
| 1286 if (!TypeParam::supports_http_only) | 1278 if (!TypeParam::supports_http_only) |
| 1287 options.set_include_httponly(); | 1279 options.set_include_httponly(); |
| 1288 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), | 1280 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), |
| 1289 "A=B", options)); | 1281 "A=B", options)); |
| 1290 this->DeleteCookie(cs.get(), this->http_www_google_.url(), "A"); | 1282 this->DeleteCookie(cs.get(), this->http_www_google_.url(), "A"); |
| 1291 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), | 1283 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), |
| 1292 "A=B", options)); | 1284 "A=B", options)); |
| 1293 NoResultCookieCallback callback(&this->other_thread_); | 1285 NoResultCookieCallback callback(&this->other_thread_); |
| 1294 base::Closure task = base::Bind( | 1286 base::Closure task = base::Bind( |
| 1295 &MultiThreadedCookieStoreTest<TypeParam>::DeleteCookieTask, | 1287 &MultiThreadedCookieStoreTest<TypeParam>::DeleteCookieTask, |
| 1296 base::Unretained(this), cs, this->http_www_google_.url(), "A", &callback); | 1288 base::Unretained(this), cs, this->http_www_google_.url(), "A", &callback); |
| 1297 this->RunOnOtherThread(task); | 1289 this->RunOnOtherThread(task); |
| 1290 callback.WaitUntilDone(); |
| 1298 EXPECT_TRUE(callback.did_run()); | 1291 EXPECT_TRUE(callback.did_run()); |
| 1299 } | 1292 } |
| 1300 | 1293 |
| 1301 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) { | 1294 TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) { |
| 1302 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1295 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
| 1303 CookieOptions options; | 1296 CookieOptions options; |
| 1304 if (!TypeParam::supports_http_only) | 1297 if (!TypeParam::supports_http_only) |
| 1305 options.set_include_httponly(); | 1298 options.set_include_httponly(); |
| 1306 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), | 1299 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), |
| 1307 "A=B", options)); | 1300 "A=B", options)); |
| 1308 EXPECT_TRUE(this->SetCookieWithOptions( | 1301 EXPECT_TRUE(this->SetCookieWithOptions( |
| 1309 cs.get(), this->http_www_google_.url(), | 1302 cs.get(), this->http_www_google_.url(), |
| 1310 "B=C; expires=Mon, 18-Apr-22 22:50:13 GMT", options)); | 1303 "B=C; expires=Mon, 18-Apr-22 22:50:13 GMT", options)); |
| 1311 EXPECT_EQ(1, this->DeleteSessionCookies(cs.get())); | 1304 EXPECT_EQ(1, this->DeleteSessionCookies(cs.get())); |
| 1312 EXPECT_EQ(0, this->DeleteSessionCookies(cs.get())); | 1305 EXPECT_EQ(0, this->DeleteSessionCookies(cs.get())); |
| 1313 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), | 1306 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), |
| 1314 "A=B", options)); | 1307 "A=B", options)); |
| 1315 ResultSavingCookieCallback<int> callback(&this->other_thread_); | 1308 ResultSavingCookieCallback<int> callback(&this->other_thread_); |
| 1316 base::Closure task = base::Bind( | 1309 base::Closure task = base::Bind( |
| 1317 &MultiThreadedCookieStoreTest<TypeParam>::DeleteSessionCookiesTask, | 1310 &MultiThreadedCookieStoreTest<TypeParam>::DeleteSessionCookiesTask, |
| 1318 base::Unretained(this), cs, &callback); | 1311 base::Unretained(this), cs, &callback); |
| 1319 this->RunOnOtherThread(task); | 1312 this->RunOnOtherThread(task); |
| 1313 callback.WaitUntilDone(); |
| 1320 EXPECT_TRUE(callback.did_run()); | 1314 EXPECT_TRUE(callback.did_run()); |
| 1321 EXPECT_EQ(1, callback.result()); | 1315 EXPECT_EQ(1, callback.result()); |
| 1322 } | 1316 } |
| 1323 | 1317 |
| 1324 REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, | 1318 REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, |
| 1325 ThreadCheckGetCookies, | 1319 ThreadCheckGetCookies, |
| 1326 ThreadCheckGetCookiesWithOptions, | 1320 ThreadCheckGetCookiesWithOptions, |
| 1327 ThreadCheckSetCookieWithOptions, | 1321 ThreadCheckSetCookieWithOptions, |
| 1328 ThreadCheckDeleteCookie, | 1322 ThreadCheckDeleteCookie, |
| 1329 ThreadCheckDeleteSessionCookies); | 1323 ThreadCheckDeleteSessionCookies); |
| 1330 | 1324 |
| 1331 } // namespace net | 1325 } // namespace net |
| 1332 | 1326 |
| 1333 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 1327 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
| OLD | NEW |