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

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

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: most unittests pass Created 7 years, 4 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/browser/cookie_store_map.h"
11 #include "content/public/browser/storage_partition.h"
12 #include "content/public/common/url_constants.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 13 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "net/cookies/canonical_cookie.h" 14 #include "net/cookies/canonical_cookie.h"
12 #include "net/cookies/parsed_cookie.h" 15 #include "net/cookies/parsed_cookie.h"
13 #include "net/url_request/url_request_context_getter.h" 16 #include "net/url_request/url_request_context_getter.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 18
16 namespace { 19 namespace {
17 20
18 class BrowsingDataCookieHelperTest : public testing::Test { 21 class BrowsingDataCookieHelperTest : public testing::Test {
19 public: 22 public:
20 BrowsingDataCookieHelperTest() 23 BrowsingDataCookieHelperTest()
21 : testing_profile_(new TestingProfile()) { 24 : testing_profile_(new TestingProfile()) {
22 } 25 }
23 26
27 net::CookieMonster* GetHttpCookieMonster() {
28 using content::BrowserContext;
29 // Since it's a unittest, assume default StoragePartition.
30 const content::CookieStoreMap& cookie_store_map =
31 BrowserContext::GetDefaultStoragePartition(testing_profile_.get())->
32 GetCookieStoreMap();
33 return cookie_store_map.GetForScheme(chrome::kHttpScheme)->
34 GetCookieMonster();
35 }
36
24 void CreateCookiesForTest() { 37 void CreateCookiesForTest() {
25 scoped_refptr<net::CookieMonster> cookie_monster = 38 scoped_refptr<net::CookieMonster> cookie_monster = GetHttpCookieMonster();
26 testing_profile_->GetCookieMonster();
27 cookie_monster->SetCookieWithOptionsAsync( 39 cookie_monster->SetCookieWithOptionsAsync(
28 GURL("http://www.google.com"), "A=1", net::CookieOptions(), 40 GURL("http://www.google.com"), "A=1", net::CookieOptions(),
29 net::CookieMonster::SetCookiesCallback()); 41 net::CookieMonster::SetCookiesCallback());
30 cookie_monster->SetCookieWithOptionsAsync( 42 cookie_monster->SetCookieWithOptionsAsync(
31 GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(), 43 GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(),
32 net::CookieMonster::SetCookiesCallback()); 44 net::CookieMonster::SetCookiesCallback());
33 } 45 }
34 46
35 void CreateCookiesForDomainCookieTest() { 47 void CreateCookiesForDomainCookieTest() {
36 scoped_refptr<net::CookieMonster> cookie_monster = 48 scoped_refptr<net::CookieMonster> cookie_monster = GetHttpCookieMonster();
37 testing_profile_->GetCookieMonster();
38 cookie_monster->SetCookieWithOptionsAsync( 49 cookie_monster->SetCookieWithOptionsAsync(
39 GURL("http://www.google.com"), "A=1", net::CookieOptions(), 50 GURL("http://www.google.com"), "A=1", net::CookieOptions(),
40 net::CookieMonster::SetCookiesCallback()); 51 net::CookieMonster::SetCookiesCallback());
41 cookie_monster->SetCookieWithOptionsAsync( 52 cookie_monster->SetCookieWithOptionsAsync(
42 GURL("http://www.google.com"), "A=2; Domain=.www.google.com ", 53 GURL("http://www.google.com"), "A=2; Domain=.www.google.com ",
43 net::CookieOptions(), net::CookieMonster::SetCookiesCallback()); 54 net::CookieOptions(), net::CookieMonster::SetCookiesCallback());
44 } 55 }
45 56
46 void FetchCallback(const net::CookieList& cookies) { 57 void FetchCallback(const net::CookieList& cookies) {
47 ASSERT_EQ(2UL, cookies.size()); 58 ASSERT_EQ(2UL, cookies.size());
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // "A=1; 445 // "A=1;
435 // "A=3; Domain=www.google.com" 446 // "A=3; Domain=www.google.com"
436 // Add a domain cookie and check if it increases the cookie count. 447 // Add a domain cookie and check if it increases the cookie count.
437 helper->AddChangedCookie(frame2_url, frame1_url, 448 helper->AddChangedCookie(frame2_url, frame1_url,
438 cookie_pair4 + "; Domain=" + cookie_domain, 449 cookie_pair4 + "; Domain=" + cookie_domain,
439 net::CookieOptions()); 450 net::CookieOptions());
440 EXPECT_EQ(5U, helper->GetCookieCount()); 451 EXPECT_EQ(5U, helper->GetCookieCount());
441 } 452 }
442 453
443 } // namespace 454 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698