Index: net/cookies/cookie_monster_unittest.cc |
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc |
index 633bca59493b4fff654e8b875cbf1e22446d4e3a..32466ec4bcbe91bd68cb68d63350a05ad1435ff4 100644 |
--- a/net/cookies/cookie_monster_unittest.cc |
+++ b/net/cookies/cookie_monster_unittest.cc |
@@ -2611,6 +2611,72 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteCanonicalCookie) { |
EXPECT_TRUE(callback.result()); |
} |
+TEST_F(MultiThreadedCookieMonsterTest, GetAllCookiesForURLEffectiveDomain) { |
+ std::vector<CanonicalCookie*> cookies; |
+ // This cookie is freed by the CookieMonster. |
Ryan Sleevi
2015/01/22 01:43:41
is? or will be?
yhirano
2015/01/23 03:34:36
Done.
|
+ cookies.push_back(CanonicalCookie::Create(url_google_, kValidCookieLine, |
+ Time::Now(), CookieOptions())); |
+ CanonicalCookie cookie = *cookies[0]; |
Ryan Sleevi
2015/01/22 01:43:41
Did you mean to copy? If so, why?
yhirano
2015/01/23 03:34:36
I want to have a cookie to verify the result below
|
+ scoped_refptr<NewMockPersistentCookieStore> store( |
+ new NewMockPersistentCookieStore); |
+ scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); |
+ |
+ CookieMonster::PersistentCookieStore::LoadedCallback loaded_callback; |
+ ::testing::StrictMock<::testing::MockFunction<void(int)>> checkpoint; |
Ryan Sleevi
2015/01/22 01:43:41
This seems unnecessary/overkill. The relation of c
yhirano
2015/01/23 03:34:36
I want to check that all monitored calls happens b
|
+ const std::string key = "google.izzle"; |
Ryan Sleevi
2015/01/22 01:43:41
What is this magic string and why are you using it
yhirano
2015/01/23 03:34:36
Done.
|
+ |
+ { |
+ ::testing::InSequence s; |
+ EXPECT_CALL(checkpoint, Call(0)); |
+ EXPECT_CALL(*store, Load(::testing::_)); |
+ EXPECT_CALL(*store, LoadCookiesForKey(key, ::testing::_)) |
+ .WillOnce(::testing::SaveArg<1>(&loaded_callback)); |
+ EXPECT_CALL(checkpoint, Call(1)); |
+ // LoadCookiesForKey will never be called, because they share the same key. |
+ } |
+ |
+ checkpoint.Call(0); |
+ { |
+ GetCookieListCallback callback; |
+ GetAllCookiesForURLTask(cm.get(), url_google_, &callback); |
+ checkpoint.Call(1); |
+ EXPECT_FALSE(callback.did_run()); |
+ loaded_callback.Run(cookies); |
Ryan Sleevi
2015/01/22 01:43:41
This is a bit surprising and non-obvious. Needs be
yhirano
2015/01/23 03:34:36
It is necessary. By calling loaded_callback, we no
|
+ EXPECT_TRUE(callback.did_run()); |
+ ASSERT_EQ(1u, callback.cookies().size()); |
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0])); |
+ } |
+ { |
+ GetCookieListCallback callback; |
+ GetAllCookiesForURLTask(cm.get(), url_google_, &callback); |
+ EXPECT_TRUE(callback.did_run()); |
+ ASSERT_EQ(1u, callback.cookies().size()); |
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0])); |
+ } |
+ { |
+ GetCookieListCallback callback; |
+ GetAllCookiesForURLTask(cm.get(), url_google_secure_, &callback); |
+ EXPECT_TRUE(callback.did_run()); |
+ ASSERT_EQ(1u, callback.cookies().size()); |
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0])); |
+ } |
+ { |
+ GetCookieListCallback callback; |
+ GetAllCookiesForURLTask(cm.get(), GURL(kUrlGoogleWebSocket), &callback); |
+ EXPECT_TRUE(callback.did_run()); |
+ ASSERT_EQ(1u, callback.cookies().size()); |
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0])); |
+ } |
+ { |
+ GetCookieListCallback callback; |
+ GetAllCookiesForURLTask(cm.get(), GURL(kUrlGoogleWebSocketSecure), |
+ &callback); |
+ EXPECT_TRUE(callback.did_run()); |
+ ASSERT_EQ(1u, callback.cookies().size()); |
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0])); |
+ } |
Ryan Sleevi
2015/01/22 01:43:41
The documentation for each of these assertions is
yhirano
2015/01/23 03:34:36
Done.
|
+} |
+ |
TEST_F(CookieMonsterTest, InvalidExpiryTime) { |
std::string cookie_line = |
std::string(kValidCookieLine) + "; expires=Blarg arg arg"; |