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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 2971323002: Switch cookie async mechanism over to using callbacks. (Closed)
Patch Set: Incorporated comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cookies/cookie_monster_perftest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_monster_unittest.cc
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc
index 5dd66bad62b32721e6b16b36ead05aed778cb36b..34c4888f0b3cdf5c50ee320459bf2d0b3deb9ac2 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -165,6 +165,20 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
return callback.result();
}
+ bool SetCookieWithCreationTime(CookieMonster* cm,
+ const GURL& url,
+ const std::string& cookie_line,
+ base::Time creation_time) {
+ DCHECK(cm);
+ ResultSavingCookieCallback<bool> callback;
+ cm->SetCookieWithCreationTimeForTesting(
+ url, cookie_line, creation_time,
+ base::Bind(&ResultSavingCookieCallback<bool>::Run,
+ base::Unretained(&callback)));
+ callback.WaitUntilDone();
+ return callback.result();
+ }
+
uint32_t DeleteAllCreatedBetween(CookieMonster* cm,
const base::Time& delete_begin,
const base::Time& delete_end) {
@@ -1387,15 +1401,19 @@ TEST_F(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps) {
// Create 5 cookies with different creation dates.
EXPECT_TRUE(
- cm->SetCookieWithCreationTime(http_www_foo_.url(), "T-0=Now", now));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(
- http_www_foo_.url(), "T-1=Yesterday", now - TimeDelta::FromDays(1)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(
- http_www_foo_.url(), "T-2=DayBefore", now - TimeDelta::FromDays(2)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(
- http_www_foo_.url(), "T-3=ThreeDays", now - TimeDelta::FromDays(3)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(http_www_foo_.url(), "T-7=LastWeek",
- now - TimeDelta::FromDays(7)));
+ SetCookieWithCreationTime(cm.get(), http_www_foo_.url(), "T-0=Now", now));
+ EXPECT_TRUE(SetCookieWithCreationTime(cm.get(), http_www_foo_.url(),
+ "T-1=Yesterday",
+ now - TimeDelta::FromDays(1)));
+ EXPECT_TRUE(SetCookieWithCreationTime(cm.get(), http_www_foo_.url(),
+ "T-2=DayBefore",
+ now - TimeDelta::FromDays(2)));
+ EXPECT_TRUE(SetCookieWithCreationTime(cm.get(), http_www_foo_.url(),
+ "T-3=ThreeDays",
+ now - TimeDelta::FromDays(3)));
+ EXPECT_TRUE(SetCookieWithCreationTime(cm.get(), http_www_foo_.url(),
+ "T-7=LastWeek",
+ now - TimeDelta::FromDays(7)));
// Try to delete threedays and the daybefore.
EXPECT_EQ(2u, DeleteAllCreatedBetween(cm.get(), now - TimeDelta::FromDays(3),
@@ -1436,15 +1454,19 @@ TEST_F(CookieMonsterTest,
// Create 5 cookies with different creation dates.
EXPECT_TRUE(
- cm->SetCookieWithCreationTime(http_www_foo_.url(), "T-0=Now", now));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(
- http_www_foo_.url(), "T-1=Yesterday", now - TimeDelta::FromDays(1)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(
- http_www_foo_.url(), "T-2=DayBefore", now - TimeDelta::FromDays(2)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(
- http_www_foo_.url(), "T-3=ThreeDays", now - TimeDelta::FromDays(3)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(http_www_foo_.url(), "T-7=LastWeek",
- now - TimeDelta::FromDays(7)));
+ SetCookieWithCreationTime(cm.get(), http_www_foo_.url(), "T-0=Now", now));
+ EXPECT_TRUE(SetCookieWithCreationTime(cm.get(), http_www_foo_.url(),
+ "T-1=Yesterday",
+ now - TimeDelta::FromDays(1)));
+ EXPECT_TRUE(SetCookieWithCreationTime(cm.get(), http_www_foo_.url(),
+ "T-2=DayBefore",
+ now - TimeDelta::FromDays(2)));
+ EXPECT_TRUE(SetCookieWithCreationTime(cm.get(), http_www_foo_.url(),
+ "T-3=ThreeDays",
+ now - TimeDelta::FromDays(3)));
+ EXPECT_TRUE(SetCookieWithCreationTime(cm.get(), http_www_foo_.url(),
+ "T-7=LastWeek",
+ now - TimeDelta::FromDays(7)));
// Try to delete threedays and the daybefore, but we should do nothing due
// to the predicate.
« no previous file with comments | « net/cookies/cookie_monster_perftest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698