Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: net/cookies/cookie_store_unittest.h

Issue 2971733002: Change CookieStore::DeleteCallback to take uint32_t. (Closed)
Patch Set: Got rid of rest of <cstdint> stuff. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cookies/cookie_store.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h>
9
8 #include <set> 10 #include <set>
9 #include <string> 11 #include <string>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/bind.h" 14 #include "base/bind.h"
13 #include "base/location.h" 15 #include "base/location.h"
14 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
15 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_tokenizer.h" 18 #include "base/strings/string_tokenizer.h"
17 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 const GURL& url, 221 const GURL& url,
220 const std::string& cookie_name) { 222 const std::string& cookie_name) {
221 DCHECK(cs); 223 DCHECK(cs);
222 NoResultCookieCallback callback; 224 NoResultCookieCallback callback;
223 cs->DeleteCookieAsync( 225 cs->DeleteCookieAsync(
224 url, cookie_name, 226 url, cookie_name,
225 base::Bind(&NoResultCookieCallback::Run, base::Unretained(&callback))); 227 base::Bind(&NoResultCookieCallback::Run, base::Unretained(&callback)));
226 callback.WaitUntilDone(); 228 callback.WaitUntilDone();
227 } 229 }
228 230
229 int DeleteCanonicalCookie(CookieStore* cs, const CanonicalCookie& cookie) { 231 uint32_t DeleteCanonicalCookie(CookieStore* cs,
232 const CanonicalCookie& cookie) {
230 DCHECK(cs); 233 DCHECK(cs);
231 ResultSavingCookieCallback<int> callback; 234 ResultSavingCookieCallback<uint32_t> callback;
232 cs->DeleteCanonicalCookieAsync( 235 cs->DeleteCanonicalCookieAsync(
233 cookie, base::Bind(&ResultSavingCookieCallback<int>::Run, 236 cookie, base::Bind(&ResultSavingCookieCallback<uint32_t>::Run,
234 base::Unretained(&callback))); 237 base::Unretained(&callback)));
235 callback.WaitUntilDone(); 238 callback.WaitUntilDone();
236 return callback.result(); 239 return callback.result();
237 } 240 }
238 241
239 int DeleteCreatedBetween(CookieStore* cs, 242 uint32_t DeleteCreatedBetween(CookieStore* cs,
240 const base::Time& delete_begin, 243 const base::Time& delete_begin,
241 const base::Time& delete_end) { 244 const base::Time& delete_end) {
242 DCHECK(cs); 245 DCHECK(cs);
243 ResultSavingCookieCallback<int> callback; 246 ResultSavingCookieCallback<uint32_t> callback;
244 cs->DeleteAllCreatedBetweenAsync( 247 cs->DeleteAllCreatedBetweenAsync(
245 delete_begin, delete_end, 248 delete_begin, delete_end,
246 base::Bind( 249 base::Bind(&ResultSavingCookieCallback<uint32_t>::Run,
247 &ResultSavingCookieCallback<int>::Run, 250 base::Unretained(&callback)));
248 base::Unretained(&callback)));
249 callback.WaitUntilDone(); 251 callback.WaitUntilDone();
250 return callback.result(); 252 return callback.result();
251 } 253 }
252 254
253 int DeleteAllCreatedBetweenWithPredicate( 255 uint32_t DeleteAllCreatedBetweenWithPredicate(
254 CookieStore* cs, 256 CookieStore* cs,
255 const base::Time delete_begin, 257 const base::Time delete_begin,
256 const base::Time delete_end, 258 const base::Time delete_end,
257 const CookieStore::CookiePredicate& predicate) { 259 const CookieStore::CookiePredicate& predicate) {
258 DCHECK(cs); 260 DCHECK(cs);
259 ResultSavingCookieCallback<int> callback; 261 ResultSavingCookieCallback<uint32_t> callback;
260 cs->DeleteAllCreatedBetweenWithPredicateAsync( 262 cs->DeleteAllCreatedBetweenWithPredicateAsync(
261 delete_begin, delete_end, predicate, 263 delete_begin, delete_end, predicate,
262 base::Bind(&ResultSavingCookieCallback<int>::Run, 264 base::Bind(&ResultSavingCookieCallback<uint32_t>::Run,
263 base::Unretained(&callback))); 265 base::Unretained(&callback)));
264 callback.WaitUntilDone(); 266 callback.WaitUntilDone();
265 return callback.result(); 267 return callback.result();
266 } 268 }
267 269
268 int DeleteSessionCookies(CookieStore* cs) { 270 uint32_t DeleteSessionCookies(CookieStore* cs) {
269 DCHECK(cs); 271 DCHECK(cs);
270 ResultSavingCookieCallback<int> callback; 272 ResultSavingCookieCallback<uint32_t> callback;
271 cs->DeleteSessionCookiesAsync( 273 cs->DeleteSessionCookiesAsync(
272 base::Bind( 274 base::Bind(&ResultSavingCookieCallback<uint32_t>::Run,
273 &ResultSavingCookieCallback<int>::Run, 275 base::Unretained(&callback)));
274 base::Unretained(&callback)));
275 callback.WaitUntilDone(); 276 callback.WaitUntilDone();
276 return callback.result(); 277 return callback.result();
277 } 278 }
278 279
279 int DeleteAll(CookieStore* cs) { 280 uint32_t DeleteAll(CookieStore* cs) {
280 DCHECK(cs); 281 DCHECK(cs);
281 ResultSavingCookieCallback<int> callback; 282 ResultSavingCookieCallback<uint32_t> callback;
282 cs->DeleteAllAsync(base::Bind(&ResultSavingCookieCallback<int>::Run, 283 cs->DeleteAllAsync(base::Bind(&ResultSavingCookieCallback<uint32_t>::Run,
283 base::Unretained(&callback))); 284 base::Unretained(&callback)));
284 callback.WaitUntilDone(); 285 callback.WaitUntilDone();
285 return callback.result(); 286 return callback.result();
286 } 287 }
287 288
288 // Returns the CookieStore for the test - each test only uses one CookieStore. 289 // Returns the CookieStore for the test - each test only uses one CookieStore.
289 CookieStore* GetCookieStore() { 290 CookieStore* GetCookieStore() {
290 if (!cookie_store_) 291 if (!cookie_store_)
291 cookie_store_ = CookieStoreTestTraits::Create(); 292 cookie_store_ = CookieStoreTestTraits::Create();
292 return cookie_store_.get(); 293 return cookie_store_.get();
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), kValidCookieLine)); 1210 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), kValidCookieLine));
1210 EXPECT_EQ("A=B", this->GetCookies(cs, this->http_www_foo_.url())); 1211 EXPECT_EQ("A=B", this->GetCookies(cs, this->http_www_foo_.url()));
1211 1212
1212 // Set a persistent cookie. 1213 // Set a persistent cookie.
1213 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), 1214 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(),
1214 "C=D; expires=Mon, 18-Apr-22 22:50:13 GMT")); 1215 "C=D; expires=Mon, 18-Apr-22 22:50:13 GMT"));
1215 1216
1216 EXPECT_EQ(2u, this->GetAllCookies(cs).size()); 1217 EXPECT_EQ(2u, this->GetAllCookies(cs).size());
1217 1218
1218 // Delete both, and make sure it works 1219 // Delete both, and make sure it works
1219 EXPECT_EQ(2, this->DeleteAll(cs)); 1220 EXPECT_EQ(2u, this->DeleteAll(cs));
1220 EXPECT_EQ(0u, this->GetAllCookies(cs).size()); 1221 EXPECT_EQ(0u, this->GetAllCookies(cs).size());
1221 } 1222 }
1222 1223
1223 TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetween) { 1224 TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetween) {
1224 CookieStore* cs = this->GetCookieStore(); 1225 CookieStore* cs = this->GetCookieStore();
1225 const base::Time last_month = base::Time::Now() - 1226 const base::Time last_month = base::Time::Now() -
1226 base::TimeDelta::FromDays(30); 1227 base::TimeDelta::FromDays(30);
1227 const base::Time last_minute = base::Time::Now() - 1228 const base::Time last_minute = base::Time::Now() -
1228 base::TimeDelta::FromMinutes(1); 1229 base::TimeDelta::FromMinutes(1);
1229 const base::Time next_minute = base::Time::Now() + 1230 const base::Time next_minute = base::Time::Now() +
1230 base::TimeDelta::FromMinutes(1); 1231 base::TimeDelta::FromMinutes(1);
1231 const base::Time next_month = base::Time::Now() + 1232 const base::Time next_month = base::Time::Now() +
1232 base::TimeDelta::FromDays(30); 1233 base::TimeDelta::FromDays(30);
1233 1234
1234 // Add a cookie. 1235 // Add a cookie.
1235 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=B")); 1236 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=B"));
1236 // Check that the cookie is in the store. 1237 // Check that the cookie is in the store.
1237 this->MatchCookieLines("A=B", 1238 this->MatchCookieLines("A=B",
1238 this->GetCookies(cs, this->http_www_foo_.url())); 1239 this->GetCookies(cs, this->http_www_foo_.url()));
1239 1240
1240 // Remove cookies in empty intervals. 1241 // Remove cookies in empty intervals.
1241 EXPECT_EQ(0, this->DeleteCreatedBetween(cs, last_month, last_minute)); 1242 EXPECT_EQ(0u, this->DeleteCreatedBetween(cs, last_month, last_minute));
1242 EXPECT_EQ(0, this->DeleteCreatedBetween(cs, next_minute, next_month)); 1243 EXPECT_EQ(0u, this->DeleteCreatedBetween(cs, next_minute, next_month));
1243 // Check that the cookie is still there. 1244 // Check that the cookie is still there.
1244 this->MatchCookieLines("A=B", 1245 this->MatchCookieLines("A=B",
1245 this->GetCookies(cs, this->http_www_foo_.url())); 1246 this->GetCookies(cs, this->http_www_foo_.url()));
1246 1247
1247 // Remove the cookie with an interval defined by two dates. 1248 // Remove the cookie with an interval defined by two dates.
1248 EXPECT_EQ(1, this->DeleteCreatedBetween(cs, last_minute, next_minute)); 1249 EXPECT_EQ(1u, this->DeleteCreatedBetween(cs, last_minute, next_minute));
1249 // Check that the cookie disappeared. 1250 // Check that the cookie disappeared.
1250 this->MatchCookieLines(std::string(), 1251 this->MatchCookieLines(std::string(),
1251 this->GetCookies(cs, this->http_www_foo_.url())); 1252 this->GetCookies(cs, this->http_www_foo_.url()));
1252 1253
1253 // Add another cookie. 1254 // Add another cookie.
1254 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "C=D")); 1255 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "C=D"));
1255 // Check that the cookie is in the store. 1256 // Check that the cookie is in the store.
1256 this->MatchCookieLines("C=D", 1257 this->MatchCookieLines("C=D",
1257 this->GetCookies(cs, this->http_www_foo_.url())); 1258 this->GetCookies(cs, this->http_www_foo_.url()));
1258 1259
1259 // Remove the cookie with a null ending time. 1260 // Remove the cookie with a null ending time.
1260 EXPECT_EQ(1, this->DeleteCreatedBetween(cs, last_minute, base::Time())); 1261 EXPECT_EQ(1u, this->DeleteCreatedBetween(cs, last_minute, base::Time()));
1261 // Check that the cookie disappeared. 1262 // Check that the cookie disappeared.
1262 this->MatchCookieLines(std::string(), 1263 this->MatchCookieLines(std::string(),
1263 this->GetCookies(cs, this->http_www_foo_.url())); 1264 this->GetCookies(cs, this->http_www_foo_.url()));
1264 } 1265 }
1265 1266
1266 namespace { 1267 namespace {
1267 static bool CookieHasValue(const std::string& value, 1268 static bool CookieHasValue(const std::string& value,
1268 const CanonicalCookie& cookie) { 1269 const CanonicalCookie& cookie) {
1269 return cookie.Value() == value; 1270 return cookie.Value() == value;
1270 } 1271 }
1271 } 1272 }
1272 1273
1273 TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetweenWithPredicate) { 1274 TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetweenWithPredicate) {
1274 CookieStore* cs = this->GetCookieStore(); 1275 CookieStore* cs = this->GetCookieStore();
1275 base::Time now = base::Time::Now(); 1276 base::Time now = base::Time::Now();
1276 base::Time last_month = base::Time::Now() - base::TimeDelta::FromDays(30); 1277 base::Time last_month = base::Time::Now() - base::TimeDelta::FromDays(30);
1277 base::Time last_minute = base::Time::Now() - base::TimeDelta::FromMinutes(1); 1278 base::Time last_minute = base::Time::Now() - base::TimeDelta::FromMinutes(1);
1278 std::string desired_value("B"); 1279 std::string desired_value("B");
1279 1280
1280 // These 3 cookies match the time range and host. 1281 // These 3 cookies match the time range and host.
1281 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=B")); 1282 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=B"));
1282 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "C=D")); 1283 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "C=D"));
1283 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "Y=Z")); 1284 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "Y=Z"));
1284 EXPECT_TRUE(this->SetCookie(cs, this->https_www_foo_.url(), "E=B")); 1285 EXPECT_TRUE(this->SetCookie(cs, this->https_www_foo_.url(), "E=B"));
1285 1286
1286 // Delete cookies. 1287 // Delete cookies.
1287 EXPECT_EQ(2, // Deletes A=B, E=B 1288 EXPECT_EQ(2u, // Deletes A=B, E=B
1288 this->DeleteAllCreatedBetweenWithPredicate( 1289 this->DeleteAllCreatedBetweenWithPredicate(
1289 cs, now, base::Time::Max(), 1290 cs, now, base::Time::Max(),
1290 base::Bind(&CookieHasValue, desired_value))); 1291 base::Bind(&CookieHasValue, desired_value)));
1291 1292
1292 // Check that we deleted the right ones. 1293 // Check that we deleted the right ones.
1293 this->MatchCookieLines("C=D;Y=Z", 1294 this->MatchCookieLines("C=D;Y=Z",
1294 this->GetCookies(cs, this->https_www_foo_.url())); 1295 this->GetCookies(cs, this->https_www_foo_.url()));
1295 1296
1296 // Now check that using a null predicate will do nothing. 1297 // Now check that using a null predicate will do nothing.
1297 EXPECT_EQ(0, this->DeleteAllCreatedBetweenWithPredicate( 1298 EXPECT_EQ(0u,
1298 cs, now, base::Time::Max(), CookieStore::CookiePredicate())); 1299 this->DeleteAllCreatedBetweenWithPredicate(
1300 cs, now, base::Time::Max(), CookieStore::CookiePredicate()));
1299 1301
1300 // Finally, check that we don't delete cookies when our time range is off. 1302 // Finally, check that we don't delete cookies when our time range is off.
1301 desired_value = "D"; 1303 desired_value = "D";
1302 EXPECT_EQ(0, this->DeleteAllCreatedBetweenWithPredicate( 1304 EXPECT_EQ(0u, this->DeleteAllCreatedBetweenWithPredicate(
1303 cs, last_month, last_minute, 1305 cs, last_month, last_minute,
1304 base::Bind(&CookieHasValue, desired_value))); 1306 base::Bind(&CookieHasValue, desired_value)));
1305 this->MatchCookieLines("C=D;Y=Z", 1307 this->MatchCookieLines("C=D;Y=Z",
1306 this->GetCookies(cs, this->https_www_foo_.url())); 1308 this->GetCookies(cs, this->https_www_foo_.url()));
1307 // Same thing, but with a good time range. 1309 // Same thing, but with a good time range.
1308 EXPECT_EQ(1, this->DeleteAllCreatedBetweenWithPredicate( 1310 EXPECT_EQ(1u, this->DeleteAllCreatedBetweenWithPredicate(
1309 cs, now, base::Time::Max(), 1311 cs, now, base::Time::Max(),
1310 base::Bind(&CookieHasValue, desired_value))); 1312 base::Bind(&CookieHasValue, desired_value)));
1311 this->MatchCookieLines("Y=Z", 1313 this->MatchCookieLines("Y=Z",
1312 this->GetCookies(cs, this->https_www_foo_.url())); 1314 this->GetCookies(cs, this->https_www_foo_.url()));
1313 } 1315 }
1314 1316
1315 TYPED_TEST_P(CookieStoreTest, TestSecure) { 1317 TYPED_TEST_P(CookieStoreTest, TestSecure) {
1316 CookieStore* cs = this->GetCookieStore(); 1318 CookieStore* cs = this->GetCookieStore();
1317 1319
1318 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=B")); 1320 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=B"));
1319 this->MatchCookieLines("A=B", 1321 this->MatchCookieLines("A=B",
1320 this->GetCookies(cs, this->http_www_foo_.url())); 1322 this->GetCookies(cs, this->http_www_foo_.url()));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 CookieStore* cs = this->GetCookieStore(); 1435 CookieStore* cs = this->GetCookieStore();
1434 1436
1435 CookieOptions options; 1437 CookieOptions options;
1436 if (!TypeParam::supports_http_only) 1438 if (!TypeParam::supports_http_only)
1437 options.set_include_httponly(); 1439 options.set_include_httponly();
1438 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_foo, "a", options)); 1440 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_foo, "a", options));
1439 CookieList list = this->GetAllCookiesForURL(cs, url_foo); 1441 CookieList list = this->GetAllCookiesForURL(cs, url_foo);
1440 EXPECT_EQ(1u, list.size()); 1442 EXPECT_EQ(1u, list.size());
1441 EXPECT_EQ("", list[0].Name()); 1443 EXPECT_EQ("", list[0].Name());
1442 EXPECT_EQ("a", list[0].Value()); 1444 EXPECT_EQ("a", list[0].Value());
1443 EXPECT_EQ(1, this->DeleteAll(cs)); 1445 EXPECT_EQ(1u, this->DeleteAll(cs));
1444 1446
1445 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_foo, "=b", options)); 1447 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_foo, "=b", options));
1446 list = this->GetAllCookiesForURL(cs, url_foo); 1448 list = this->GetAllCookiesForURL(cs, url_foo);
1447 EXPECT_EQ(1u, list.size()); 1449 EXPECT_EQ(1u, list.size());
1448 EXPECT_EQ("", list[0].Name()); 1450 EXPECT_EQ("", list[0].Name());
1449 EXPECT_EQ("b", list[0].Value()); 1451 EXPECT_EQ("b", list[0].Value());
1450 EXPECT_EQ(1, this->DeleteAll(cs)); 1452 EXPECT_EQ(1u, this->DeleteAll(cs));
1451 } 1453 }
1452 1454
1453 TYPED_TEST_P(CookieStoreTest, CookieOrdering) { 1455 TYPED_TEST_P(CookieStoreTest, CookieOrdering) {
1454 // Put a random set of cookies into a store and make sure they're returned in 1456 // Put a random set of cookies into a store and make sure they're returned in
1455 // the right order. 1457 // the right order.
1456 // Cookies should be sorted by path length and creation time, as per RFC6265. 1458 // Cookies should be sorted by path length and creation time, as per RFC6265.
1457 CookieStore* cs = this->GetCookieStore(); 1459 CookieStore* cs = this->GetCookieStore();
1458 EXPECT_TRUE( 1460 EXPECT_TRUE(
1459 this->SetCookie(cs, GURL("http://d.c.b.a.foo.com/aa/x.html"), "c=1")); 1461 this->SetCookie(cs, GURL("http://d.c.b.a.foo.com/aa/x.html"), "c=1"));
1460 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.foo.com/aa/bb/cc/x.html"), 1462 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.foo.com/aa/bb/cc/x.html"),
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=B;Path=/foo")); 1565 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=B;Path=/foo"));
1564 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=C;Path=/bar")); 1566 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=C;Path=/bar"));
1565 EXPECT_EQ(2u, this->GetAllCookies(cs).size()); 1567 EXPECT_EQ(2u, this->GetAllCookies(cs).size());
1566 EXPECT_EQ("A=B", this->GetCookies(cs, this->www_foo_foo_.url())); 1568 EXPECT_EQ("A=B", this->GetCookies(cs, this->www_foo_foo_.url()));
1567 EXPECT_EQ("A=C", this->GetCookies(cs, this->www_foo_bar_.url())); 1569 EXPECT_EQ("A=C", this->GetCookies(cs, this->www_foo_bar_.url()));
1568 1570
1569 // Delete the "/foo" cookie, and make sure only it was deleted. 1571 // Delete the "/foo" cookie, and make sure only it was deleted.
1570 CookieList cookies = this->GetCookieListWithOptions( 1572 CookieList cookies = this->GetCookieListWithOptions(
1571 cs, this->www_foo_foo_.url(), CookieOptions()); 1573 cs, this->www_foo_foo_.url(), CookieOptions());
1572 ASSERT_EQ(1u, cookies.size()); 1574 ASSERT_EQ(1u, cookies.size());
1573 EXPECT_EQ(1, this->DeleteCanonicalCookie(cs, cookies[0])); 1575 EXPECT_EQ(1u, this->DeleteCanonicalCookie(cs, cookies[0]));
1574 EXPECT_EQ(1u, this->GetAllCookies(cs).size()); 1576 EXPECT_EQ(1u, this->GetAllCookies(cs).size());
1575 EXPECT_EQ("", this->GetCookies(cs, this->www_foo_foo_.url())); 1577 EXPECT_EQ("", this->GetCookies(cs, this->www_foo_foo_.url()));
1576 EXPECT_EQ("A=C", this->GetCookies(cs, this->www_foo_bar_.url())); 1578 EXPECT_EQ("A=C", this->GetCookies(cs, this->www_foo_bar_.url()));
1577 1579
1578 // Deleting the "/foo" cookie again should fail. 1580 // Deleting the "/foo" cookie again should fail.
1579 EXPECT_EQ(0, this->DeleteCanonicalCookie(cs, cookies[0])); 1581 EXPECT_EQ(0u, this->DeleteCanonicalCookie(cs, cookies[0]));
1580 1582
1581 // Try to delete the "/bar" cookie after overwriting it with a new cookie. 1583 // Try to delete the "/bar" cookie after overwriting it with a new cookie.
1582 cookies = this->GetCookieListWithOptions(cs, this->www_foo_bar_.url(), 1584 cookies = this->GetCookieListWithOptions(cs, this->www_foo_bar_.url(),
1583 CookieOptions()); 1585 CookieOptions());
1584 ASSERT_EQ(1u, cookies.size()); 1586 ASSERT_EQ(1u, cookies.size());
1585 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=D;Path=/bar")); 1587 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), "A=D;Path=/bar"));
1586 EXPECT_EQ(0, this->DeleteCanonicalCookie(cs, cookies[0])); 1588 EXPECT_EQ(0u, this->DeleteCanonicalCookie(cs, cookies[0]));
1587 EXPECT_EQ(1u, this->GetAllCookies(cs).size()); 1589 EXPECT_EQ(1u, this->GetAllCookies(cs).size());
1588 EXPECT_EQ("A=D", this->GetCookies(cs, this->www_foo_bar_.url())); 1590 EXPECT_EQ("A=D", this->GetCookies(cs, this->www_foo_bar_.url()));
1589 1591
1590 // Delete the new "/bar" cookie. 1592 // Delete the new "/bar" cookie.
1591 cookies = this->GetCookieListWithOptions(cs, this->www_foo_bar_.url(), 1593 cookies = this->GetCookieListWithOptions(cs, this->www_foo_bar_.url(),
1592 CookieOptions()); 1594 CookieOptions());
1593 ASSERT_EQ(1u, cookies.size()); 1595 ASSERT_EQ(1u, cookies.size());
1594 EXPECT_EQ(1, this->DeleteCanonicalCookie(cs, cookies[0])); 1596 EXPECT_EQ(1u, this->DeleteCanonicalCookie(cs, cookies[0]));
1595 EXPECT_EQ(0u, this->GetAllCookies(cs).size()); 1597 EXPECT_EQ(0u, this->GetAllCookies(cs).size());
1596 EXPECT_EQ("", this->GetCookies(cs, this->www_foo_bar_.url())); 1598 EXPECT_EQ("", this->GetCookies(cs, this->www_foo_bar_.url()));
1597 } 1599 }
1598 1600
1599 TYPED_TEST_P(CookieStoreTest, DeleteSessionCookie) { 1601 TYPED_TEST_P(CookieStoreTest, DeleteSessionCookie) {
1600 CookieStore* cs = this->GetCookieStore(); 1602 CookieStore* cs = this->GetCookieStore();
1601 // Create a session cookie and a persistent cookie. 1603 // Create a session cookie and a persistent cookie.
1602 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(), 1604 EXPECT_TRUE(this->SetCookie(cs, this->http_www_foo_.url(),
1603 std::string(kValidCookieLine))); 1605 std::string(kValidCookieLine)));
1604 EXPECT_TRUE(this->SetCookie( 1606 EXPECT_TRUE(this->SetCookie(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 EmptyName, 1653 EmptyName,
1652 CookieOrdering, 1654 CookieOrdering,
1653 GetAllCookiesAsync, 1655 GetAllCookiesAsync,
1654 DeleteCookieAsync, 1656 DeleteCookieAsync,
1655 DeleteCanonicalCookieAsync, 1657 DeleteCanonicalCookieAsync,
1656 DeleteSessionCookie); 1658 DeleteSessionCookie);
1657 1659
1658 } // namespace net 1660 } // namespace net
1659 1661
1660 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ 1662 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_
OLDNEW
« no previous file with comments | « net/cookies/cookie_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698