Index: chrome/browser/browsing_data_cookie_helper_unittest.cc |
diff --git a/chrome/browser/browsing_data_cookie_helper_unittest.cc b/chrome/browser/browsing_data_cookie_helper_unittest.cc |
index ef652cb0afc96c4e5c0c7618158510a440a2bc48..98843d5517ec74203851362087b61b7d958a4576 100644 |
--- a/chrome/browser/browsing_data_cookie_helper_unittest.cc |
+++ b/chrome/browser/browsing_data_cookie_helper_unittest.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -67,7 +67,6 @@ class BrowsingDataCookieHelperTest : public testing::Test { |
} |
void FetchCallback(const net::CookieList& cookies) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
ASSERT_EQ(2UL, cookies.size()); |
cookie_list_ = cookies; |
net::CookieList::const_iterator it = cookies.begin(); |
@@ -86,7 +85,6 @@ class BrowsingDataCookieHelperTest : public testing::Test { |
} |
void DeleteCallback(const net::CookieList& cookies) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
ASSERT_EQ(1UL, cookies.size()); |
net::CookieList::const_iterator it = cookies.begin(); |
@@ -99,7 +97,6 @@ class BrowsingDataCookieHelperTest : public testing::Test { |
} |
void CannedUniqueCallback(const net::CookieList& cookies) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
ASSERT_EQ(1UL, cookies.size()); |
cookie_list_ = cookies; |
net::CookieList::const_iterator it = cookies.begin(); |
@@ -111,6 +108,10 @@ class BrowsingDataCookieHelperTest : public testing::Test { |
ASSERT_TRUE(++it == cookies.end()); |
} |
+ void CannedDifferentFramesCallback(const net::CookieList& cookie_list) { |
+ ASSERT_EQ(3U, cookie_list.size()); |
+ } |
+ |
protected: |
MessageLoop message_loop_; |
scoped_ptr<content::TestBrowserThread> ui_thread_; |
@@ -162,8 +163,8 @@ TEST_F(BrowsingDataCookieHelperTest, CannedUnique) { |
new CannedBrowsingDataCookieHelper(testing_profile_.get())); |
ASSERT_TRUE(helper->empty()); |
- helper->AddChangedCookie(origin, "A=1", net::CookieOptions()); |
- helper->AddChangedCookie(origin, "A=1", net::CookieOptions()); |
+ helper->AddChangedCookie(origin, origin, "A=1", net::CookieOptions()); |
+ helper->AddChangedCookie(origin, origin, "A=1", net::CookieOptions()); |
helper->StartFetching( |
base::Bind(&BrowsingDataCookieHelperTest::CannedUniqueCallback, |
base::Unretained(this))); |
@@ -171,8 +172,8 @@ TEST_F(BrowsingDataCookieHelperTest, CannedUnique) { |
helper->Reset(); |
ASSERT_TRUE(helper->empty()); |
- helper->AddReadCookies(origin, cookie); |
- helper->AddReadCookies(origin, cookie); |
+ helper->AddReadCookies(origin, origin, cookie); |
+ helper->AddReadCookies(origin, origin, cookie); |
helper->StartFetching( |
base::Bind(&BrowsingDataCookieHelperTest::CannedUniqueCallback, |
base::Unretained(this))); |
@@ -185,7 +186,7 @@ TEST_F(BrowsingDataCookieHelperTest, CannedEmpty) { |
new CannedBrowsingDataCookieHelper(testing_profile_.get())); |
ASSERT_TRUE(helper->empty()); |
- helper->AddChangedCookie(url_google, "a=1", |
+ helper->AddChangedCookie(url_google, url_google, "a=1", |
net::CookieOptions()); |
ASSERT_FALSE(helper->empty()); |
helper->Reset(); |
@@ -197,10 +198,31 @@ TEST_F(BrowsingDataCookieHelperTest, CannedEmpty) { |
new net::CookieMonster::CanonicalCookie(url_google, pc)); |
cookies.push_back(*cookie); |
- helper->AddReadCookies(url_google, cookies); |
+ helper->AddReadCookies(url_google, url_google, cookies); |
ASSERT_FALSE(helper->empty()); |
helper->Reset(); |
ASSERT_TRUE(helper->empty()); |
} |
+TEST_F(BrowsingDataCookieHelperTest, CannedDifferentFrames) { |
+ GURL frame1_url("http://www.google.com"); |
+ GURL frame2_url("http://www.google.de"); |
+ GURL request_url("http://www.google.com"); |
+ |
+ scoped_refptr<CannedBrowsingDataCookieHelper> helper( |
+ new CannedBrowsingDataCookieHelper(testing_profile_.get())); |
+ |
+ ASSERT_TRUE(helper->empty()); |
+ helper->AddChangedCookie(frame1_url, request_url, "a=1", |
+ net::CookieOptions()); |
+ helper->AddChangedCookie(frame1_url, request_url, "b=1", |
+ net::CookieOptions()); |
+ helper->AddChangedCookie(frame2_url, request_url, "c=1", |
+ net::CookieOptions()); |
+ |
+ helper->StartFetching( |
+ base::Bind(&BrowsingDataCookieHelperTest::CannedDifferentFramesCallback, |
+ base::Unretained(this))); |
+} |
+ |
} // namespace |