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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc

Issue 124183002: Implement delete methods for the various CannedBrowsingDataHelpers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" 5 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 net::CanonicalCookie cookie = cookie_list_[0]; 211 net::CanonicalCookie cookie = cookie_list_[0];
212 cookie_helper->DeleteCookie(cookie); 212 cookie_helper->DeleteCookie(cookie);
213 213
214 cookie_helper->StartFetching( 214 cookie_helper->StartFetching(
215 base::Bind(&BrowsingDataCookieHelperTest::DeleteCallback, 215 base::Bind(&BrowsingDataCookieHelperTest::DeleteCallback,
216 base::Unretained(this))); 216 base::Unretained(this)));
217 base::RunLoop().RunUntilIdle(); 217 base::RunLoop().RunUntilIdle();
218 } 218 }
219 219
220 TEST_F(BrowsingDataCookieHelperTest, CannedDeleteCookie) {
221 CreateCookiesForTest();
222 scoped_refptr<CannedBrowsingDataCookieHelper> helper(
223 new CannedBrowsingDataCookieHelper(
224 testing_profile_->GetRequestContext()));
225
226 ASSERT_TRUE(helper->empty());
227
228 const GURL origin1("http://www.google.com");
229 const GURL origin2("http://www.gmail.google.com");
230 helper->AddChangedCookie(origin1, origin1, "A=1", net::CookieOptions());
231 helper->AddChangedCookie(origin2, origin2, "B=1", net::CookieOptions());
232
233 helper->StartFetching(
234 base::Bind(&BrowsingDataCookieHelperTest::FetchCallback,
235 base::Unretained(this)));
236 base::RunLoop().RunUntilIdle();
237
238 EXPECT_EQ(2u, helper->GetCookieCount());
239
240 helper->DeleteCookie(cookie_list_[0]);
241
242 EXPECT_EQ(1u, helper->GetCookieCount());
243 helper->StartFetching(
244 base::Bind(&BrowsingDataCookieHelperTest::DeleteCallback,
245 base::Unretained(this)));
246 base::RunLoop().RunUntilIdle();
247 }
248
220 TEST_F(BrowsingDataCookieHelperTest, CannedDomainCookie) { 249 TEST_F(BrowsingDataCookieHelperTest, CannedDomainCookie) {
221 const GURL origin("http://www.google.com"); 250 const GURL origin("http://www.google.com");
222 net::CookieList cookie; 251 net::CookieList cookie;
223 252
224 scoped_refptr<CannedBrowsingDataCookieHelper> helper( 253 scoped_refptr<CannedBrowsingDataCookieHelper> helper(
225 new CannedBrowsingDataCookieHelper( 254 new CannedBrowsingDataCookieHelper(
226 testing_profile_->GetRequestContext())); 255 testing_profile_->GetRequestContext()));
227 256
228 ASSERT_TRUE(helper->empty()); 257 ASSERT_TRUE(helper->empty());
229 helper->AddChangedCookie(origin, origin, "A=1", net::CookieOptions()); 258 helper->AddChangedCookie(origin, origin, "A=1", net::CookieOptions());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // "A=1; 463 // "A=1;
435 // "A=3; Domain=www.google.com" 464 // "A=3; Domain=www.google.com"
436 // Add a domain cookie and check if it increases the cookie count. 465 // Add a domain cookie and check if it increases the cookie count.
437 helper->AddChangedCookie(frame2_url, frame1_url, 466 helper->AddChangedCookie(frame2_url, frame1_url,
438 cookie_pair4 + "; Domain=" + cookie_domain, 467 cookie_pair4 + "; Domain=" + cookie_domain,
439 net::CookieOptions()); 468 net::CookieOptions());
440 EXPECT_EQ(5U, helper->GetCookieCount()); 469 EXPECT_EQ(5U, helper->GetCookieCount());
441 } 470 }
442 471
443 } // namespace 472 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698