OLD | NEW |
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Check that each expectation has been matched. | 103 // Check that each expectation has been matched. |
104 unsigned long match_count = std::count_if(cookie_expectations_.begin(), | 104 unsigned long match_count = std::count_if(cookie_expectations_.begin(), |
105 cookie_expectations_.end(), | 105 cookie_expectations_.end(), |
106 ExpectationIsMatched); | 106 ExpectationIsMatched); |
107 EXPECT_EQ(cookie_expectations_.size(), match_count); | 107 EXPECT_EQ(cookie_expectations_.size(), match_count); |
108 | 108 |
109 cookie_expectations_.clear(); | 109 cookie_expectations_.clear(); |
110 } | 110 } |
111 | 111 |
112 void CreateCookiesForTest() { | 112 void CreateCookiesForTest() { |
113 scoped_refptr<net::CookieMonster> cookie_monster = | 113 net::CookieStore* cookie_store = testing_profile_->GetCookieStore(); |
114 testing_profile_->GetCookieMonster(); | 114 cookie_store->SetCookieWithOptionsAsync( |
115 cookie_monster->SetCookieWithOptionsAsync( | |
116 GURL("http://www.google.com"), "A=1", net::CookieOptions(), | 115 GURL("http://www.google.com"), "A=1", net::CookieOptions(), |
117 net::CookieMonster::SetCookiesCallback()); | 116 net::CookieMonster::SetCookiesCallback()); |
118 cookie_monster->SetCookieWithOptionsAsync( | 117 cookie_store->SetCookieWithOptionsAsync( |
119 GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(), | 118 GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(), |
120 net::CookieMonster::SetCookiesCallback()); | 119 net::CookieMonster::SetCookiesCallback()); |
121 } | 120 } |
122 | 121 |
123 void CreateCookiesForDomainCookieTest() { | 122 void CreateCookiesForDomainCookieTest() { |
124 scoped_refptr<net::CookieMonster> cookie_monster = | 123 net::CookieStore* cookie_store = testing_profile_->GetCookieStore(); |
125 testing_profile_->GetCookieMonster(); | 124 cookie_store->SetCookieWithOptionsAsync( |
126 cookie_monster->SetCookieWithOptionsAsync( | |
127 GURL("http://www.google.com"), "A=1", net::CookieOptions(), | 125 GURL("http://www.google.com"), "A=1", net::CookieOptions(), |
128 net::CookieMonster::SetCookiesCallback()); | 126 net::CookieMonster::SetCookiesCallback()); |
129 cookie_monster->SetCookieWithOptionsAsync( | 127 cookie_store->SetCookieWithOptionsAsync( |
130 GURL("http://www.google.com"), "A=2; Domain=.www.google.com ", | 128 GURL("http://www.google.com"), "A=2; Domain=.www.google.com ", |
131 net::CookieOptions(), net::CookieMonster::SetCookiesCallback()); | 129 net::CookieOptions(), net::CookieMonster::SetCookiesCallback()); |
132 } | 130 } |
133 | 131 |
134 void FetchCallback(const net::CookieList& cookies) { | 132 void FetchCallback(const net::CookieList& cookies) { |
135 cookie_list_ = cookies; | 133 cookie_list_ = cookies; |
136 | 134 |
137 AddCookieExpectation(nullptr, "www.google.com", nullptr, "A", nullptr); | 135 AddCookieExpectation(nullptr, "www.google.com", nullptr, "A", nullptr); |
138 AddCookieExpectation(nullptr, "www.gmail.google.com", nullptr, "B", | 136 AddCookieExpectation(nullptr, "www.gmail.google.com", nullptr, "B", |
139 nullptr); | 137 nullptr); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 // "A=1; | 490 // "A=1; |
493 // "A=3; Domain=www.google.com" | 491 // "A=3; Domain=www.google.com" |
494 // Add a domain cookie and check if it increases the cookie count. | 492 // Add a domain cookie and check if it increases the cookie count. |
495 helper->AddChangedCookie(frame2_url, frame1_url, | 493 helper->AddChangedCookie(frame2_url, frame1_url, |
496 cookie_pair4 + "; Domain=" + cookie_domain, | 494 cookie_pair4 + "; Domain=" + cookie_domain, |
497 net::CookieOptions()); | 495 net::CookieOptions()); |
498 EXPECT_EQ(5U, helper->GetCookieCount()); | 496 EXPECT_EQ(5U, helper->GetCookieCount()); |
499 } | 497 } |
500 | 498 |
501 } // namespace | 499 } // namespace |
OLD | NEW |