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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 9959011: Add CookieStore::DeleteSessionCookiesAsync method. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased again Created 8 years, 8 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.cc ('k') | net/cookies/cookie_store.h » ('j') | 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 24390bc8dc6eff2ac355ff15468b178b8a9cd168..a6b59d01f69eda94f0dc60c668d6f80eec28c46c 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -473,6 +473,16 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
return callback.result();
}
+ int DeleteSessionCookies(CookieMonster*cm) {
+ DCHECK(cm);
+ DeleteCallback callback;
+ cm->DeleteSessionCookiesAsync(
+ base::Bind(&DeleteCallback::Run, base::Unretained(&callback)));
+ RunFor(kTimeout);
+ EXPECT_TRUE(callback.did_run());
+ return callback.num_deleted();
+ }
+
// Helper for DeleteAllForHost test; repopulates CM with same layout
// each time.
void PopulateCmForDeleteAllForHost(scoped_refptr<CookieMonster> cm) {
@@ -757,6 +767,10 @@ ACTION_P(PushCallbackAction, callback_vector) {
callback_vector->push(arg1);
}
+ACTION_P2(DeleteSessionCookiesAction, cookie_monster, callback) {
+ cookie_monster->DeleteSessionCookiesAsync(callback->AsCallback());
+}
+
} // namespace
// This test suite verifies the task deferral behaviour of the CookieMonster.
@@ -1096,6 +1110,22 @@ TEST_F(DeferredCookieTaskTest, DeferredDeleteCanonicalCookie) {
CompleteLoadingAndWait();
}
+TEST_F(DeferredCookieTaskTest, DeferredDeleteSessionCookies) {
+ MockDeleteCallback delete_callback;
+
+ BeginWith(DeleteSessionCookiesAction(
+ &cookie_monster(), &delete_callback));
+
+ WaitForLoadCall();
+
+ EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
+ DeleteSessionCookiesAction(&cookie_monster(), &delete_callback));
+ EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
+ QuitCurrentMessageLoop());
+
+ CompleteLoadingAndWait();
+}
+
// Verify that a series of queued tasks are executed in order upon loading of
// the backing store and that new tasks received while the queued tasks are
// being dispatched go to the end of the queue.
@@ -2410,6 +2440,11 @@ class MultiThreadedCookieMonsterTest : public CookieMonsterTest {
base::Bind(&SetCookieCallback::Run, base::Unretained(callback)));
}
+ void DeleteSessionCookiesTask(CookieMonster* cm, DeleteCallback* callback) {
+ cm->DeleteSessionCookiesAsync(
+ base::Bind(&DeleteCallback::Run, base::Unretained(callback)));
+ }
+
protected:
void RunOnOtherThread(const base::Closure& task) {
other_thread_.Start();
@@ -2567,6 +2602,27 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteCanonicalCookie) {
EXPECT_TRUE(callback.result());
}
+TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteSessionCookies) {
+ scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ CookieOptions options;
+ EXPECT_TRUE(SetCookieWithOptions(cm, url_google_, "A=B", options));
+ EXPECT_TRUE(SetCookieWithOptions(cm, url_google_,
+ "B=C; expires=Mon, 18-Apr-22 22:50:13 GMT",
+ options));
+ EXPECT_EQ(1, DeleteSessionCookies(cm));
+ EXPECT_EQ(0, DeleteSessionCookies(cm));
+
+ EXPECT_TRUE(SetCookieWithOptions(cm, url_google_, "A=B", options));
+ DeleteCallback callback(&other_thread_);
+ base::Closure task = base::Bind(
+ &net::MultiThreadedCookieMonsterTest::DeleteSessionCookiesTask,
+ base::Unretained(this),
+ cm, &callback);
+ RunOnOtherThread(task);
+ EXPECT_TRUE(callback.did_run());
+ EXPECT_EQ(1, callback.num_deleted());
+}
+
TEST_F(CookieMonsterTest, ShortLivedSessionCookies) {
scoped_refptr<MockPersistentCookieStore> store(
new MockPersistentCookieStore);
« no previous file with comments | « net/cookies/cookie_monster.cc ('k') | net/cookies/cookie_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698