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

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

Issue 10092013: Display third party cookies and site data counts in the WebsiteSettings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 years, 7 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) 2011 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_cookie_helper.h" 5 #include "chrome/browser/browsing_data_cookie_helper.h"
6 6
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 cookie_list_ = cookies; 104 cookie_list_ = cookies;
105 net::CookieList::const_iterator it = cookies.begin(); 105 net::CookieList::const_iterator it = cookies.begin();
106 106
107 ASSERT_TRUE(it != cookies.end()); 107 ASSERT_TRUE(it != cookies.end());
108 EXPECT_EQ("http://www.google.com/", it->Source()); 108 EXPECT_EQ("http://www.google.com/", it->Source());
109 EXPECT_EQ("A", it->Name()); 109 EXPECT_EQ("A", it->Name());
110 110
111 ASSERT_TRUE(++it == cookies.end()); 111 ASSERT_TRUE(++it == cookies.end());
112 } 112 }
113 113
114 void CannedDifferentFramesCallback(const net::CookieList& cookie_list) {
115 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
bauerb at google 2012/04/27 16:12:50 This line does not test what you think it tests ;-
markusheintz_ 2012/05/10 16:32:36 :( . Stupid me. I removed the line. I also removed
116 ASSERT_EQ(3U, cookie_list.size());
117 }
118
114 protected: 119 protected:
115 MessageLoop message_loop_; 120 MessageLoop message_loop_;
116 scoped_ptr<content::TestBrowserThread> ui_thread_; 121 scoped_ptr<content::TestBrowserThread> ui_thread_;
117 scoped_ptr<content::TestBrowserThread> io_thread_; 122 scoped_ptr<content::TestBrowserThread> io_thread_;
118 scoped_ptr<TestingProfile> testing_profile_; 123 scoped_ptr<TestingProfile> testing_profile_;
119 124
120 net::CookieList cookie_list_; 125 net::CookieList cookie_list_;
121 }; 126 };
122 127
123 TEST_F(BrowsingDataCookieHelperTest, FetchData) { 128 TEST_F(BrowsingDataCookieHelperTest, FetchData) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 160 }
156 161
157 TEST_F(BrowsingDataCookieHelperTest, CannedUnique) { 162 TEST_F(BrowsingDataCookieHelperTest, CannedUnique) {
158 const GURL origin("http://www.google.com"); 163 const GURL origin("http://www.google.com");
159 net::CookieList cookie; 164 net::CookieList cookie;
160 165
161 scoped_refptr<CannedBrowsingDataCookieHelper> helper( 166 scoped_refptr<CannedBrowsingDataCookieHelper> helper(
162 new CannedBrowsingDataCookieHelper(testing_profile_.get())); 167 new CannedBrowsingDataCookieHelper(testing_profile_.get()));
163 168
164 ASSERT_TRUE(helper->empty()); 169 ASSERT_TRUE(helper->empty());
165 helper->AddChangedCookie(origin, "A=1", net::CookieOptions()); 170 helper->AddChangedCookie(origin, origin, "A=1", net::CookieOptions());
166 helper->AddChangedCookie(origin, "A=1", net::CookieOptions()); 171 helper->AddChangedCookie(origin, origin, "A=1", net::CookieOptions());
167 helper->StartFetching( 172 helper->StartFetching(
168 base::Bind(&BrowsingDataCookieHelperTest::CannedUniqueCallback, 173 base::Bind(&BrowsingDataCookieHelperTest::CannedUniqueCallback,
169 base::Unretained(this))); 174 base::Unretained(this)));
170 cookie = cookie_list_; 175 cookie = cookie_list_;
171 helper->Reset(); 176 helper->Reset();
172 ASSERT_TRUE(helper->empty()); 177 ASSERT_TRUE(helper->empty());
173 178
174 helper->AddReadCookies(origin, cookie); 179 helper->AddReadCookies(origin, origin, cookie);
175 helper->AddReadCookies(origin, cookie); 180 helper->AddReadCookies(origin, origin, cookie);
176 helper->StartFetching( 181 helper->StartFetching(
177 base::Bind(&BrowsingDataCookieHelperTest::CannedUniqueCallback, 182 base::Bind(&BrowsingDataCookieHelperTest::CannedUniqueCallback,
178 base::Unretained(this))); 183 base::Unretained(this)));
179 } 184 }
180 185
181 TEST_F(BrowsingDataCookieHelperTest, CannedEmpty) { 186 TEST_F(BrowsingDataCookieHelperTest, CannedEmpty) {
182 const GURL url_google("http://www.google.com"); 187 const GURL url_google("http://www.google.com");
183 188
184 scoped_refptr<CannedBrowsingDataCookieHelper> helper( 189 scoped_refptr<CannedBrowsingDataCookieHelper> helper(
185 new CannedBrowsingDataCookieHelper(testing_profile_.get())); 190 new CannedBrowsingDataCookieHelper(testing_profile_.get()));
186 191
187 ASSERT_TRUE(helper->empty()); 192 ASSERT_TRUE(helper->empty());
188 helper->AddChangedCookie(url_google, "a=1", 193 helper->AddChangedCookie(url_google, url_google, "a=1",
189 net::CookieOptions()); 194 net::CookieOptions());
190 ASSERT_FALSE(helper->empty()); 195 ASSERT_FALSE(helper->empty());
191 helper->Reset(); 196 helper->Reset();
192 ASSERT_TRUE(helper->empty()); 197 ASSERT_TRUE(helper->empty());
193 198
194 net::CookieList cookies; 199 net::CookieList cookies;
195 net::CookieMonster::ParsedCookie pc("a=1"); 200 net::CookieMonster::ParsedCookie pc("a=1");
196 scoped_ptr<net::CookieMonster::CanonicalCookie> cookie( 201 scoped_ptr<net::CookieMonster::CanonicalCookie> cookie(
197 new net::CookieMonster::CanonicalCookie(url_google, pc)); 202 new net::CookieMonster::CanonicalCookie(url_google, pc));
198 cookies.push_back(*cookie); 203 cookies.push_back(*cookie);
199 204
200 helper->AddReadCookies(url_google, cookies); 205 helper->AddReadCookies(url_google, url_google, cookies);
201 ASSERT_FALSE(helper->empty()); 206 ASSERT_FALSE(helper->empty());
202 helper->Reset(); 207 helper->Reset();
203 ASSERT_TRUE(helper->empty()); 208 ASSERT_TRUE(helper->empty());
204 } 209 }
205 210
211 TEST_F(BrowsingDataCookieHelperTest, CannedDifferentFrames) {
212 GURL frame1_url("http://www.google.com");
213 GURL frame2_url("http://www.google.de");
214 GURL request_url("http://www.google.com");
215
216 scoped_refptr<CannedBrowsingDataCookieHelper> helper(
217 new CannedBrowsingDataCookieHelper(testing_profile_.get()));
218
219 ASSERT_TRUE(helper->empty());
220 helper->AddChangedCookie(frame1_url, request_url, "a=1",
221 net::CookieOptions());
222 helper->AddChangedCookie(frame1_url, request_url, "b=1",
223 net::CookieOptions());
224 helper->AddChangedCookie(frame2_url, request_url, "c=1",
225 net::CookieOptions());
226
227 helper->StartFetching(
228 base::Bind(&BrowsingDataCookieHelperTest::CannedDifferentFramesCallback,
229 base::Unretained(this)));
230 }
231
206 } // namespace 232 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698