diff options
author | droger@google.com <droger@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-04 10:41:21 +0000 |
---|---|---|
committer | droger@google.com <droger@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-04 10:41:21 +0000 |
commit | 65e1332ddde91ec93011b84fa41f952d12807a62 (patch) | |
tree | 42354917282f77956bf2468b22069aba1237286f /net | |
parent | a272102cc39e090044160007d934100e420499e5 (diff) | |
download | chromium_src-65e1332ddde91ec93011b84fa41f952d12807a62.zip chromium_src-65e1332ddde91ec93011b84fa41f952d12807a62.tar.gz chromium_src-65e1332ddde91ec93011b84fa41f952d12807a62.tar.bz2 |
Moved the ThreadCheckDeleteSessionCookies from cookie_monster_unittest to cookie_store_unittest
This test was incorrectly in cookie_monster_unittest: the
DeleteSessionCookiesAsync() method is in CookieStore and should be tested in the
base test rather than the derived test.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/10315005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/cookies/cookie_monster_unittest.cc | 36 | ||||
-rw-r--r-- | net/cookies/cookie_store_unittest.h | 41 |
2 files changed, 40 insertions, 37 deletions
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc index e7e3582..fc570b9 100644 --- a/net/cookies/cookie_monster_unittest.cc +++ b/net/cookies/cookie_monster_unittest.cc @@ -476,16 +476,6 @@ 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) { @@ -2455,11 +2445,6 @@ 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(); @@ -2617,27 +2602,6 @@ 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); diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h index e1d23f8..33c1a37 100644 --- a/net/cookies/cookie_store_unittest.h +++ b/net/cookies/cookie_store_unittest.h @@ -182,6 +182,16 @@ class CookieStoreTest : public testing::Test { return callback.num_deleted(); } + int DeleteSessionCookies(CookieStore* cs) { + DCHECK(cs); + DeleteCallback callback; + cs->DeleteSessionCookiesAsync( + base::Bind(&DeleteCallback::Run, base::Unretained(&callback))); + RunFor(kTimeout); + EXPECT_TRUE(callback.did_run()); + return callback.num_deleted(); + } + void RunFor(int ms) { // Runs the test thread message loop for up to |ms| milliseconds. MessageLoop::current()->PostDelayedTask( @@ -933,6 +943,11 @@ class MultiThreadedCookieStoreTest : base::Bind(&DeleteCookieCallback::Run, base::Unretained(callback))); } + void DeleteSessionCookiesTask(CookieStore* cs, DeleteCallback* callback) { + cs->DeleteSessionCookiesAsync( + base::Bind(&DeleteCallback::Run, base::Unretained(callback))); + } + protected: void RunOnOtherThread(const base::Closure& task) { other_thread_.Start(); @@ -1045,10 +1060,34 @@ TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteCookie) { EXPECT_TRUE(callback.did_run()); } +TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) { + scoped_refptr<CookieStore> cs(this->GetCookieStore()); + CookieOptions options; + if (!TypeParam::supports_http_only) + options.set_include_httponly(); + EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, + "A=B", options)); + EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, + "B=C; expires=Mon, 18-Apr-22 22:50:13 GMT", options)); + EXPECT_EQ(1, this->DeleteSessionCookies(cs)); + EXPECT_EQ(0, this->DeleteSessionCookies(cs)); + + EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, + "A=B", options)); + DeleteCallback callback(&this->other_thread_); + base::Closure task = base::Bind( + &net::MultiThreadedCookieStoreTest<TypeParam>::DeleteSessionCookiesTask, + base::Unretained(this), + cs, &callback); + this->RunOnOtherThread(task); + EXPECT_TRUE(callback.did_run()); + EXPECT_EQ(1, callback.num_deleted()); +} + REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookies, ThreadCheckGetCookiesWithOptions, ThreadCheckGetCookiesWithInfo, ThreadCheckSetCookieWithOptions, - ThreadCheckDeleteCookie); + ThreadCheckDeleteCookie, ThreadCheckDeleteSessionCookies); } // namespace net |