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

Side by Side Diff: chrome/browser/gtk/options/cookies_view_unittest.cc

Issue 650110: Teach the cookie tree view / model about appcaches. Not hooked up to real dat... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/gtk/options/cookies_view.h" 5 #include "chrome/browser/gtk/options/cookies_view.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include <gtk/gtk.h> 10 #include <gtk/gtk.h>
11 11
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "chrome/browser/mock_browsing_data_appcache_helper.h"
13 #include "chrome/browser/mock_browsing_data_database_helper.h" 14 #include "chrome/browser/mock_browsing_data_database_helper.h"
14 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" 15 #include "chrome/browser/mock_browsing_data_local_storage_helper.h"
15 #include "chrome/browser/net/url_request_context_getter.h" 16 #include "chrome/browser/net/url_request_context_getter.h"
16 #include "chrome/test/testing_profile.h" 17 #include "chrome/test/testing_profile.h"
17 #include "net/url_request/url_request_context.h" 18 #include "net/url_request/url_request_context.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 class CookiesViewTest : public testing::Test { 21 class CookiesViewTest : public testing::Test {
21 public: 22 public:
22 CookiesViewTest() : io_thread_(ChromeThread::IO, &message_loop_) { 23 CookiesViewTest() : io_thread_(ChromeThread::IO, &message_loop_) {
23 } 24 }
24 25
25 virtual ~CookiesViewTest() { 26 virtual ~CookiesViewTest() {
26 } 27 }
27 28
28 virtual void SetUp() { 29 virtual void SetUp() {
29 profile_.reset(new TestingProfile()); 30 profile_.reset(new TestingProfile());
30 profile_->CreateRequestContext(); 31 profile_->CreateRequestContext();
31 mock_browsing_data_database_helper_ = 32 mock_browsing_data_database_helper_ =
32 new MockBrowsingDataDatabaseHelper(profile_.get()); 33 new MockBrowsingDataDatabaseHelper(profile_.get());
33 mock_browsing_data_local_storage_helper_ = 34 mock_browsing_data_local_storage_helper_ =
34 new MockBrowsingDataLocalStorageHelper(profile_.get()); 35 new MockBrowsingDataLocalStorageHelper(profile_.get());
36 mock_browsing_data_appcache_helper_ =
37 new MockBrowsingDataAppCacheHelper(profile_.get());
35 } 38 }
36 39
37 void CheckDetailsSensitivity(gboolean expected_cookies, 40 void CheckDetailsSensitivity(gboolean expected_cookies,
38 gboolean expected_database, 41 gboolean expected_database,
39 gboolean expected_local_storage, 42 gboolean expected_local_storage,
43 gboolean expected_appcache,
40 const CookiesView& cookies_view) { 44 const CookiesView& cookies_view) {
41 // Cookies 45 // Cookies
42 EXPECT_EQ(expected_cookies, 46 EXPECT_EQ(expected_cookies,
43 GTK_WIDGET_SENSITIVE(cookies_view.cookie_name_entry_)); 47 GTK_WIDGET_SENSITIVE(cookies_view.cookie_name_entry_));
44 EXPECT_EQ(expected_cookies, 48 EXPECT_EQ(expected_cookies,
45 GTK_WIDGET_SENSITIVE(cookies_view.cookie_content_entry_)); 49 GTK_WIDGET_SENSITIVE(cookies_view.cookie_content_entry_));
46 EXPECT_EQ(expected_cookies, 50 EXPECT_EQ(expected_cookies,
47 GTK_WIDGET_SENSITIVE(cookies_view.cookie_domain_entry_)); 51 GTK_WIDGET_SENSITIVE(cookies_view.cookie_domain_entry_));
48 EXPECT_EQ(expected_cookies, 52 EXPECT_EQ(expected_cookies,
49 GTK_WIDGET_SENSITIVE(cookies_view.cookie_path_entry_)); 53 GTK_WIDGET_SENSITIVE(cookies_view.cookie_path_entry_));
(...skipping 12 matching lines...) Expand all
62 GTK_WIDGET_SENSITIVE( 66 GTK_WIDGET_SENSITIVE(
63 cookies_view.database_last_modified_entry_)); 67 cookies_view.database_last_modified_entry_));
64 // Local Storage 68 // Local Storage
65 EXPECT_EQ(expected_local_storage, 69 EXPECT_EQ(expected_local_storage,
66 GTK_WIDGET_SENSITIVE(cookies_view.local_storage_origin_entry_)); 70 GTK_WIDGET_SENSITIVE(cookies_view.local_storage_origin_entry_));
67 EXPECT_EQ(expected_local_storage, 71 EXPECT_EQ(expected_local_storage,
68 GTK_WIDGET_SENSITIVE(cookies_view.local_storage_size_entry_)); 72 GTK_WIDGET_SENSITIVE(cookies_view.local_storage_size_entry_));
69 EXPECT_EQ(expected_local_storage, 73 EXPECT_EQ(expected_local_storage,
70 GTK_WIDGET_SENSITIVE( 74 GTK_WIDGET_SENSITIVE(
71 cookies_view.local_storage_last_modified_entry_)); 75 cookies_view.local_storage_last_modified_entry_));
72 76 // AppCache
77 EXPECT_EQ(expected_appcache,
78 GTK_WIDGET_SENSITIVE(cookies_view.appcache_manifest_entry_));
79 EXPECT_EQ(expected_appcache,
80 GTK_WIDGET_SENSITIVE(cookies_view.appcache_size_entry_));
81 EXPECT_EQ(expected_appcache,
82 GTK_WIDGET_SENSITIVE(cookies_view.appcache_created_entry_));
83 EXPECT_EQ(expected_appcache,
84 GTK_WIDGET_SENSITIVE(
85 cookies_view.appcache_last_accessed_entry_));
73 } 86 }
74 87
75 // Get the cookie names in the cookie list, as a comma seperated string. 88 // Get the cookie names in the cookie list, as a comma seperated string.
76 // (Note that the CookieMonster cookie list is sorted by domain.) 89 // (Note that the CookieMonster cookie list is sorted by domain.)
77 // Ex: 90 // Ex:
78 // monster->SetCookie(GURL("http://b"), "X=1") 91 // monster->SetCookie(GURL("http://b"), "X=1")
79 // monster->SetCookie(GURL("http://a"), "Y=1") 92 // monster->SetCookie(GURL("http://a"), "Y=1")
80 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); 93 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str());
81 std::string GetMonsterCookies(net::CookieMonster* monster) { 94 std::string GetMonsterCookies(net::CookieMonster* monster) {
82 std::vector<std::string> parts; 95 std::vector<std::string> parts;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 184
172 protected: 185 protected:
173 MessageLoop message_loop_; 186 MessageLoop message_loop_;
174 ChromeThread io_thread_; 187 ChromeThread io_thread_;
175 188
176 scoped_ptr<TestingProfile> profile_; 189 scoped_ptr<TestingProfile> profile_;
177 scoped_refptr<MockBrowsingDataDatabaseHelper> 190 scoped_refptr<MockBrowsingDataDatabaseHelper>
178 mock_browsing_data_database_helper_; 191 mock_browsing_data_database_helper_;
179 scoped_refptr<MockBrowsingDataLocalStorageHelper> 192 scoped_refptr<MockBrowsingDataLocalStorageHelper>
180 mock_browsing_data_local_storage_helper_; 193 mock_browsing_data_local_storage_helper_;
194 scoped_refptr<MockBrowsingDataAppCacheHelper>
195 mock_browsing_data_appcache_helper_;
181 }; 196 };
182 197
183 TEST_F(CookiesViewTest, Empty) { 198 TEST_F(CookiesViewTest, Empty) {
184 CookiesView cookies_view(NULL, 199 CookiesView cookies_view(NULL,
185 profile_.get(), 200 profile_.get(),
186 mock_browsing_data_database_helper_, 201 mock_browsing_data_database_helper_,
187 mock_browsing_data_local_storage_helper_); 202 mock_browsing_data_local_storage_helper_,
203 mock_browsing_data_appcache_helper_);
188 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 204 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
189 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 205 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
190 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 206 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
191 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); 207 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
192 } 208 }
193 209
194 TEST_F(CookiesViewTest, Noop) { 210 TEST_F(CookiesViewTest, Noop) {
195 net::CookieMonster* monster = profile_->GetCookieMonster(); 211 net::CookieMonster* monster = profile_->GetCookieMonster();
196 monster->SetCookie(GURL("http://foo0"), "C=1"); 212 monster->SetCookie(GURL("http://foo0"), "C=1");
197 monster->SetCookie(GURL("http://foo0"), "D=1"); 213 monster->SetCookie(GURL("http://foo0"), "D=1");
198 monster->SetCookie(GURL("http://foo1"), "B=1"); 214 monster->SetCookie(GURL("http://foo1"), "B=1");
199 monster->SetCookie(GURL("http://foo1"), "A=1"); 215 monster->SetCookie(GURL("http://foo1"), "A=1");
200 monster->SetCookie(GURL("http://foo1"), "E=1"); 216 monster->SetCookie(GURL("http://foo1"), "E=1");
201 monster->SetCookie(GURL("http://foo2"), "G=1"); 217 monster->SetCookie(GURL("http://foo2"), "G=1");
202 monster->SetCookie(GURL("http://foo2"), "X=1"); 218 monster->SetCookie(GURL("http://foo2"), "X=1");
203 CookiesView cookies_view(NULL, 219 CookiesView cookies_view(NULL,
204 profile_.get(), 220 profile_.get(),
205 mock_browsing_data_database_helper_, 221 mock_browsing_data_database_helper_,
206 mock_browsing_data_local_storage_helper_); 222 mock_browsing_data_local_storage_helper_,
223 mock_browsing_data_appcache_helper_);
207 mock_browsing_data_database_helper_->AddDatabaseSamples(); 224 mock_browsing_data_database_helper_->AddDatabaseSamples();
208 mock_browsing_data_database_helper_->Notify(); 225 mock_browsing_data_database_helper_->Notify();
209 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 226 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
210 mock_browsing_data_local_storage_helper_->Notify(); 227 mock_browsing_data_local_storage_helper_->Notify();
211 EXPECT_STREQ("foo0,_Cookies,__C,__D," 228 EXPECT_STREQ("foo0,_Cookies,__C,__D,"
212 "foo1,_Cookies,__A,__B,__E," 229 "foo1,_Cookies,__A,__B,__E,"
213 "foo2,_Cookies,__G,__X," 230 "foo2,_Cookies,__G,__X,"
214 "gdbhost1,_Web Databases,__db1," 231 "gdbhost1,_Web Databases,__db1,"
215 "gdbhost2,_Web Databases,__db2," 232 "gdbhost2,_Web Databases,__db2,"
216 "host1,_Local Storage,__origin1," 233 "host1,_Local Storage,__origin1,"
217 "host2,_Local Storage,__origin2", 234 "host2,_Local Storage,__origin2",
218 GetDisplayedCookies(cookies_view).c_str()); 235 GetDisplayedCookies(cookies_view).c_str());
219 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 236 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
220 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 237 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
221 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 238 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
222 } 239 }
223 240
224 TEST_F(CookiesViewTest, RemoveAll) { 241 TEST_F(CookiesViewTest, RemoveAll) {
225 net::CookieMonster* monster = profile_->GetCookieMonster(); 242 net::CookieMonster* monster = profile_->GetCookieMonster();
226 monster->SetCookie(GURL("http://foo"), "A=1"); 243 monster->SetCookie(GURL("http://foo"), "A=1");
227 monster->SetCookie(GURL("http://foo2"), "B=1"); 244 monster->SetCookie(GURL("http://foo2"), "B=1");
228 CookiesView cookies_view(NULL, 245 CookiesView cookies_view(NULL,
229 profile_.get(), 246 profile_.get(),
230 mock_browsing_data_database_helper_, 247 mock_browsing_data_database_helper_,
231 mock_browsing_data_local_storage_helper_); 248 mock_browsing_data_local_storage_helper_,
249 mock_browsing_data_appcache_helper_);
232 mock_browsing_data_database_helper_->AddDatabaseSamples(); 250 mock_browsing_data_database_helper_->AddDatabaseSamples();
233 mock_browsing_data_database_helper_->Notify(); 251 mock_browsing_data_database_helper_->Notify();
234 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 252 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
235 mock_browsing_data_local_storage_helper_->Notify(); 253 mock_browsing_data_local_storage_helper_->Notify();
236 254
237 // Reset the selection of the first row. 255 // Reset the selection of the first row.
238 gtk_tree_selection_unselect_all(cookies_view.selection_); 256 gtk_tree_selection_unselect_all(cookies_view.selection_);
239 257
240 { 258 {
241 SCOPED_TRACE("Before removing"); 259 SCOPED_TRACE("Before removing");
242 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 260 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
243 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 261 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
244 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 262 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
245 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," 263 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B,"
246 "gdbhost1,_Web Databases,__db1," 264 "gdbhost1,_Web Databases,__db1,"
247 "gdbhost2,_Web Databases,__db2," 265 "gdbhost2,_Web Databases,__db2,"
248 "host1,_Local Storage,__origin1," 266 "host1,_Local Storage,__origin1,"
249 "host2,_Local Storage,__origin2", 267 "host2,_Local Storage,__origin2",
250 GetDisplayedCookies(cookies_view).c_str()); 268 GetDisplayedCookies(cookies_view).c_str());
251 } 269 }
252 270
253 mock_browsing_data_database_helper_->Reset(); 271 mock_browsing_data_database_helper_->Reset();
254 mock_browsing_data_local_storage_helper_->Reset(); 272 mock_browsing_data_local_storage_helper_->Reset();
255 273
256 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); 274 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_));
257 { 275 {
258 SCOPED_TRACE("After removing"); 276 SCOPED_TRACE("After removing");
259 EXPECT_EQ(0u, monster->GetAllCookies().size()); 277 EXPECT_EQ(0u, monster->GetAllCookies().size());
260 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 278 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
261 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 279 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
262 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 280 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
263 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); 281 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
264 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); 282 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted());
265 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); 283 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted());
266 } 284 }
267 } 285 }
268 286
269 TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) { 287 TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) {
270 net::CookieMonster* monster = profile_->GetCookieMonster(); 288 net::CookieMonster* monster = profile_->GetCookieMonster();
271 monster->SetCookie(GURL("http://foo"), "A=1"); 289 monster->SetCookie(GURL("http://foo"), "A=1");
272 monster->SetCookie(GURL("http://foo2"), "B=1"); 290 monster->SetCookie(GURL("http://foo2"), "B=1");
273 CookiesView cookies_view(NULL, 291 CookiesView cookies_view(NULL,
274 profile_.get(), 292 profile_.get(),
275 mock_browsing_data_database_helper_, 293 mock_browsing_data_database_helper_,
276 mock_browsing_data_local_storage_helper_); 294 mock_browsing_data_local_storage_helper_,
295 mock_browsing_data_appcache_helper_);
277 mock_browsing_data_database_helper_->AddDatabaseSamples(); 296 mock_browsing_data_database_helper_->AddDatabaseSamples();
278 mock_browsing_data_database_helper_->Notify(); 297 mock_browsing_data_database_helper_->Notify();
279 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 298 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
280 mock_browsing_data_local_storage_helper_->Notify(); 299 mock_browsing_data_local_storage_helper_->Notify();
281 300
282 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); 301 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str());
283 EXPECT_EQ(1, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); 302 EXPECT_EQ(1, gtk_tree_selection_count_selected_rows(cookies_view.selection_));
284 { 303 {
285 SCOPED_TRACE("Before removing"); 304 SCOPED_TRACE("Before removing");
286 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 305 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
287 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 306 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
288 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 307 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
289 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," 308 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B,"
290 "gdbhost1,_Web Databases,__db1," 309 "gdbhost1,_Web Databases,__db1,"
291 "gdbhost2,_Web Databases,__db2," 310 "gdbhost2,_Web Databases,__db2,"
292 "host1,_Local Storage,__origin1," 311 "host1,_Local Storage,__origin1,"
293 "host2,_Local Storage,__origin2", 312 "host2,_Local Storage,__origin2",
294 GetDisplayedCookies(cookies_view).c_str()); 313 GetDisplayedCookies(cookies_view).c_str());
295 } 314 }
296 315
297 mock_browsing_data_database_helper_->Reset(); 316 mock_browsing_data_database_helper_->Reset();
298 mock_browsing_data_local_storage_helper_->Reset(); 317 mock_browsing_data_local_storage_helper_->Reset();
299 318
300 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); 319 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_));
301 { 320 {
302 SCOPED_TRACE("After removing"); 321 SCOPED_TRACE("After removing");
303 EXPECT_EQ(0u, monster->GetAllCookies().size()); 322 EXPECT_EQ(0u, monster->GetAllCookies().size());
304 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 323 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
305 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 324 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
306 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 325 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
307 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); 326 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
308 EXPECT_EQ(0, 327 EXPECT_EQ(0,
309 gtk_tree_selection_count_selected_rows(cookies_view.selection_)); 328 gtk_tree_selection_count_selected_rows(cookies_view.selection_));
310 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); 329 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted());
311 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); 330 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted());
312 } 331 }
313 } 332 }
314 333
315 TEST_F(CookiesViewTest, Remove) { 334 TEST_F(CookiesViewTest, Remove) {
316 net::CookieMonster* monster = profile_->GetCookieMonster(); 335 net::CookieMonster* monster = profile_->GetCookieMonster();
317 monster->SetCookie(GURL("http://foo1"), "A=1"); 336 monster->SetCookie(GURL("http://foo1"), "A=1");
318 monster->SetCookie(GURL("http://foo2"), "B=1"); 337 monster->SetCookie(GURL("http://foo2"), "B=1");
319 monster->SetCookie(GURL("http://foo2"), "C=1"); 338 monster->SetCookie(GURL("http://foo2"), "C=1");
320 CookiesView cookies_view(NULL, 339 CookiesView cookies_view(NULL,
321 profile_.get(), 340 profile_.get(),
322 mock_browsing_data_database_helper_, 341 mock_browsing_data_database_helper_,
323 mock_browsing_data_local_storage_helper_); 342 mock_browsing_data_local_storage_helper_,
343 mock_browsing_data_appcache_helper_);
324 mock_browsing_data_database_helper_->AddDatabaseSamples(); 344 mock_browsing_data_database_helper_->AddDatabaseSamples();
325 mock_browsing_data_database_helper_->Notify(); 345 mock_browsing_data_database_helper_->Notify();
326 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 346 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
327 mock_browsing_data_local_storage_helper_->Notify(); 347 mock_browsing_data_local_storage_helper_->Notify();
328 348
329 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); 349 ASSERT_TRUE(ExpandByPath(cookies_view, "1"));
330 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); 350 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0"));
331 351
332 { 352 {
333 SCOPED_TRACE("First selection"); 353 SCOPED_TRACE("First selection");
334 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 354 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
335 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 355 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
336 CheckDetailsSensitivity(TRUE, FALSE, FALSE, cookies_view); 356 CheckDetailsSensitivity(TRUE, FALSE, FALSE, FALSE, cookies_view);
337 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C," 357 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C,"
338 "gdbhost1,_Web Databases,__db1," 358 "gdbhost1,_Web Databases,__db1,"
339 "gdbhost2,_Web Databases,__db2," 359 "gdbhost2,_Web Databases,__db2,"
340 "host1,_Local Storage,__origin1," 360 "host1,_Local Storage,__origin1,"
341 "host2,_Local Storage,__origin2", 361 "host2,_Local Storage,__origin2",
342 GetDisplayedCookies(cookies_view).c_str()); 362 GetDisplayedCookies(cookies_view).c_str());
343 } 363 }
344 364
345 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 365 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
346 366
347 { 367 {
348 SCOPED_TRACE("First selection removed"); 368 SCOPED_TRACE("First selection removed");
349 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); 369 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
350 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C," 370 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C,"
351 "gdbhost1,_Web Databases,__db1," 371 "gdbhost1,_Web Databases,__db1,"
352 "gdbhost2,_Web Databases,__db2," 372 "gdbhost2,_Web Databases,__db2,"
353 "host1,_Local Storage,__origin1," 373 "host1,_Local Storage,__origin1,"
354 "host2,_Local Storage,__origin2", 374 "host2,_Local Storage,__origin2",
355 GetDisplayedCookies(cookies_view).c_str()); 375 GetDisplayedCookies(cookies_view).c_str());
356 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 376 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
357 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 377 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
358 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); 378 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str());
359 CheckDetailsSensitivity(TRUE, FALSE, FALSE, cookies_view); 379 CheckDetailsSensitivity(TRUE, FALSE, FALSE, FALSE, cookies_view);
360 } 380 }
361 381
362 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 382 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
363 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 383 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
364 384
365 { 385 {
366 SCOPED_TRACE("Second selection"); 386 SCOPED_TRACE("Second selection");
367 EXPECT_STREQ("A", GetMonsterCookies(monster).c_str()); 387 EXPECT_STREQ("A", GetMonsterCookies(monster).c_str());
368 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies," 388 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,"
369 "gdbhost1,_Web Databases,__db1," 389 "gdbhost1,_Web Databases,__db1,"
370 "gdbhost2,_Web Databases,__db2," 390 "gdbhost2,_Web Databases,__db2,"
371 "host1,_Local Storage,__origin1," 391 "host1,_Local Storage,__origin1,"
372 "host2,_Local Storage,__origin2", 392 "host2,_Local Storage,__origin2",
373 GetDisplayedCookies(cookies_view).c_str()); 393 GetDisplayedCookies(cookies_view).c_str());
374 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 394 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
375 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 395 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
376 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); 396 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str());
377 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 397 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
378 } 398 }
379 399
380 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); 400 ASSERT_TRUE(ExpandByPath(cookies_view, "0"));
381 EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies," 401 EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies,"
382 "gdbhost1,_Web Databases,__db1," 402 "gdbhost1,_Web Databases,__db1,"
383 "gdbhost2,_Web Databases,__db2," 403 "gdbhost2,_Web Databases,__db2,"
384 "host1,_Local Storage,__origin1," 404 "host1,_Local Storage,__origin1,"
385 "host2,_Local Storage,__origin2", 405 "host2,_Local Storage,__origin2",
386 GetDisplayedCookies(cookies_view).c_str()); 406 GetDisplayedCookies(cookies_view).c_str());
387 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); 407 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0"));
388 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 408 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
389 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 409 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
390 410
391 { 411 {
392 SCOPED_TRACE("Second selection removed"); 412 SCOPED_TRACE("Second selection removed");
393 EXPECT_EQ(0u, monster->GetAllCookies().size()); 413 EXPECT_EQ(0u, monster->GetAllCookies().size());
394 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 414 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
395 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 415 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
396 EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str()); 416 EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str());
397 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 417 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
398 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," 418 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies,"
399 "gdbhost1,_Web Databases,__db1," 419 "gdbhost1,_Web Databases,__db1,"
400 "gdbhost2,_Web Databases,__db2," 420 "gdbhost2,_Web Databases,__db2,"
401 "host1,_Local Storage,__origin1," 421 "host1,_Local Storage,__origin1,"
402 "host2,_Local Storage,__origin2", 422 "host2,_Local Storage,__origin2",
403 GetDisplayedCookies(cookies_view).c_str()); 423 GetDisplayedCookies(cookies_view).c_str());
404 } 424 }
405 425
406 ASSERT_TRUE(ExpandByPath(cookies_view, "2")); 426 ASSERT_TRUE(ExpandByPath(cookies_view, "2"));
407 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," 427 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies,"
408 "gdbhost1,+Web Databases,++db1," 428 "gdbhost1,+Web Databases,++db1,"
409 "gdbhost2,_Web Databases,__db2," 429 "gdbhost2,_Web Databases,__db2,"
410 "host1,_Local Storage,__origin1," 430 "host1,_Local Storage,__origin1,"
411 "host2,_Local Storage,__origin2", 431 "host2,_Local Storage,__origin2",
412 GetDisplayedCookies(cookies_view).c_str()); 432 GetDisplayedCookies(cookies_view).c_str());
413 ASSERT_TRUE(SelectByPath(cookies_view, "2:0:0")); 433 ASSERT_TRUE(SelectByPath(cookies_view, "2:0:0"));
414 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 434 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
415 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 435 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
416 436
417 { 437 {
418 SCOPED_TRACE("Third selection removed"); 438 SCOPED_TRACE("Third selection removed");
419 EXPECT_EQ(0u, monster->GetAllCookies().size()); 439 EXPECT_EQ(0u, monster->GetAllCookies().size());
420 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 440 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
421 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 441 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
422 EXPECT_STREQ("2:0", GetSelectedPath(cookies_view).c_str()); 442 EXPECT_STREQ("2:0", GetSelectedPath(cookies_view).c_str());
423 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 443 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
424 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," 444 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies,"
425 "gdbhost1,+Web Databases," 445 "gdbhost1,+Web Databases,"
426 "gdbhost2,_Web Databases,__db2," 446 "gdbhost2,_Web Databases,__db2,"
427 "host1,_Local Storage,__origin1," 447 "host1,_Local Storage,__origin1,"
428 "host2,_Local Storage,__origin2", 448 "host2,_Local Storage,__origin2",
429 GetDisplayedCookies(cookies_view).c_str()); 449 GetDisplayedCookies(cookies_view).c_str());
430 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == 450 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ ==
431 "http_gdbhost1_1"); 451 "http_gdbhost1_1");
432 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == 452 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ ==
433 "db1"); 453 "db1");
434 } 454 }
435 455
436 ASSERT_TRUE(ExpandByPath(cookies_view, "4")); 456 ASSERT_TRUE(ExpandByPath(cookies_view, "4"));
437 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," 457 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies,"
438 "gdbhost1,+Web Databases," 458 "gdbhost1,+Web Databases,"
439 "gdbhost2,_Web Databases,__db2," 459 "gdbhost2,_Web Databases,__db2,"
440 "host1,+Local Storage,++origin1," 460 "host1,+Local Storage,++origin1,"
441 "host2,_Local Storage,__origin2", 461 "host2,_Local Storage,__origin2",
442 GetDisplayedCookies(cookies_view).c_str()); 462 GetDisplayedCookies(cookies_view).c_str());
443 ASSERT_TRUE(SelectByPath(cookies_view, "4:0:0")); 463 ASSERT_TRUE(SelectByPath(cookies_view, "4:0:0"));
444 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 464 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
445 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 465 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
446 466
447 { 467 {
448 SCOPED_TRACE("Fourth selection removed"); 468 SCOPED_TRACE("Fourth selection removed");
449 EXPECT_EQ(0u, monster->GetAllCookies().size()); 469 EXPECT_EQ(0u, monster->GetAllCookies().size());
450 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 470 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
451 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 471 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
452 EXPECT_STREQ("4:0", GetSelectedPath(cookies_view).c_str()); 472 EXPECT_STREQ("4:0", GetSelectedPath(cookies_view).c_str());
453 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 473 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
454 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," 474 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies,"
455 "gdbhost1,+Web Databases," 475 "gdbhost1,+Web Databases,"
456 "gdbhost2,_Web Databases,__db2," 476 "gdbhost2,_Web Databases,__db2,"
457 "host1,+Local Storage," 477 "host1,+Local Storage,"
458 "host2,_Local Storage,__origin2", 478 "host2,_Local Storage,__origin2",
459 GetDisplayedCookies(cookies_view).c_str()); 479 GetDisplayedCookies(cookies_view).c_str());
460 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == 480 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ ==
461 FilePath(FILE_PATH_LITERAL("file1"))); 481 FilePath(FILE_PATH_LITERAL("file1")));
462 } 482 }
463 } 483 }
464 484
465 TEST_F(CookiesViewTest, RemoveCookiesByType) { 485 TEST_F(CookiesViewTest, RemoveCookiesByType) {
466 net::CookieMonster* monster = profile_->GetCookieMonster(); 486 net::CookieMonster* monster = profile_->GetCookieMonster();
467 monster->SetCookie(GURL("http://foo0"), "C=1"); 487 monster->SetCookie(GURL("http://foo0"), "C=1");
468 monster->SetCookie(GURL("http://foo0"), "D=1"); 488 monster->SetCookie(GURL("http://foo0"), "D=1");
469 monster->SetCookie(GURL("http://foo1"), "B=1"); 489 monster->SetCookie(GURL("http://foo1"), "B=1");
470 monster->SetCookie(GURL("http://foo1"), "A=1"); 490 monster->SetCookie(GURL("http://foo1"), "A=1");
471 monster->SetCookie(GURL("http://foo1"), "E=1"); 491 monster->SetCookie(GURL("http://foo1"), "E=1");
472 monster->SetCookie(GURL("http://foo2"), "G=1"); 492 monster->SetCookie(GURL("http://foo2"), "G=1");
473 monster->SetCookie(GURL("http://foo2"), "X=1"); 493 monster->SetCookie(GURL("http://foo2"), "X=1");
474 CookiesView cookies_view(NULL, 494 CookiesView cookies_view(NULL,
475 profile_.get(), 495 profile_.get(),
476 mock_browsing_data_database_helper_, 496 mock_browsing_data_database_helper_,
477 mock_browsing_data_local_storage_helper_); 497 mock_browsing_data_local_storage_helper_,
498 mock_browsing_data_appcache_helper_);
478 mock_browsing_data_database_helper_->AddDatabaseSamples(); 499 mock_browsing_data_database_helper_->AddDatabaseSamples();
479 mock_browsing_data_database_helper_->Notify(); 500 mock_browsing_data_database_helper_->Notify();
480 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 501 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
481 mock_browsing_data_local_storage_helper_->Notify(); 502 mock_browsing_data_local_storage_helper_->Notify();
482 503
483 EXPECT_STREQ("foo0,_Cookies,__C,__D," 504 EXPECT_STREQ("foo0,_Cookies,__C,__D,"
484 "foo1,_Cookies,__A,__B,__E," 505 "foo1,_Cookies,__A,__B,__E,"
485 "foo2,_Cookies,__G,__X," 506 "foo2,_Cookies,__G,__X,"
486 "gdbhost1,_Web Databases,__db1," 507 "gdbhost1,_Web Databases,__db1,"
487 "gdbhost2,_Web Databases,__db2," 508 "gdbhost2,_Web Databases,__db2,"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 monster->SetCookie(GURL("http://foo0"), "C=1"); 651 monster->SetCookie(GURL("http://foo0"), "C=1");
631 monster->SetCookie(GURL("http://foo0"), "D=1"); 652 monster->SetCookie(GURL("http://foo0"), "D=1");
632 monster->SetCookie(GURL("http://foo1"), "B=1"); 653 monster->SetCookie(GURL("http://foo1"), "B=1");
633 monster->SetCookie(GURL("http://foo1"), "A=1"); 654 monster->SetCookie(GURL("http://foo1"), "A=1");
634 monster->SetCookie(GURL("http://foo1"), "E=1"); 655 monster->SetCookie(GURL("http://foo1"), "E=1");
635 monster->SetCookie(GURL("http://foo2"), "G=1"); 656 monster->SetCookie(GURL("http://foo2"), "G=1");
636 monster->SetCookie(GURL("http://foo2"), "X=1"); 657 monster->SetCookie(GURL("http://foo2"), "X=1");
637 CookiesView cookies_view(NULL, 658 CookiesView cookies_view(NULL,
638 profile_.get(), 659 profile_.get(),
639 mock_browsing_data_database_helper_, 660 mock_browsing_data_database_helper_,
640 mock_browsing_data_local_storage_helper_); 661 mock_browsing_data_local_storage_helper_,
662 mock_browsing_data_appcache_helper_);
641 mock_browsing_data_database_helper_->AddDatabaseSamples(); 663 mock_browsing_data_database_helper_->AddDatabaseSamples();
642 mock_browsing_data_database_helper_->Notify(); 664 mock_browsing_data_database_helper_->Notify();
643 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 665 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
644 mock_browsing_data_local_storage_helper_->Notify(); 666 mock_browsing_data_local_storage_helper_->Notify();
645 667
646 EXPECT_STREQ("foo0,_Cookies,__C,__D," 668 EXPECT_STREQ("foo0,_Cookies,__C,__D,"
647 "foo1,_Cookies,__A,__B,__E," 669 "foo1,_Cookies,__A,__B,__E,"
648 "foo2,_Cookies,__G,__X," 670 "foo2,_Cookies,__G,__X,"
649 "gdbhost1,_Web Databases,__db1," 671 "gdbhost1,_Web Databases,__db1,"
650 "gdbhost2,_Web Databases,__db2," 672 "gdbhost2,_Web Databases,__db2,"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 monster->SetCookie(GURL("http://foo0"), "C=1"); 776 monster->SetCookie(GURL("http://foo0"), "C=1");
755 monster->SetCookie(GURL("http://foo0"), "D=1"); 777 monster->SetCookie(GURL("http://foo0"), "D=1");
756 monster->SetCookie(GURL("http://foo1"), "B=1"); 778 monster->SetCookie(GURL("http://foo1"), "B=1");
757 monster->SetCookie(GURL("http://foo1"), "A=1"); 779 monster->SetCookie(GURL("http://foo1"), "A=1");
758 monster->SetCookie(GURL("http://foo1"), "E=1"); 780 monster->SetCookie(GURL("http://foo1"), "E=1");
759 monster->SetCookie(GURL("http://foo2"), "G=1"); 781 monster->SetCookie(GURL("http://foo2"), "G=1");
760 monster->SetCookie(GURL("http://foo2"), "X=1"); 782 monster->SetCookie(GURL("http://foo2"), "X=1");
761 CookiesView cookies_view(NULL, 783 CookiesView cookies_view(NULL,
762 profile_.get(), 784 profile_.get(),
763 mock_browsing_data_database_helper_, 785 mock_browsing_data_database_helper_,
764 mock_browsing_data_local_storage_helper_); 786 mock_browsing_data_local_storage_helper_,
787 mock_browsing_data_appcache_helper_);
765 mock_browsing_data_database_helper_->AddDatabaseSamples(); 788 mock_browsing_data_database_helper_->AddDatabaseSamples();
766 mock_browsing_data_database_helper_->Notify(); 789 mock_browsing_data_database_helper_->Notify();
767 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 790 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
768 mock_browsing_data_local_storage_helper_->Notify(); 791 mock_browsing_data_local_storage_helper_->Notify();
769 792
770 EXPECT_STREQ("foo0,_Cookies,__C,__D," 793 EXPECT_STREQ("foo0,_Cookies,__C,__D,"
771 "foo1,_Cookies,__A,__B,__E," 794 "foo1,_Cookies,__A,__B,__E,"
772 "foo2,_Cookies,__G,__X," 795 "foo2,_Cookies,__G,__X,"
773 "gdbhost1,_Web Databases,__db1," 796 "gdbhost1,_Web Databases,__db1,"
774 "gdbhost2,_Web Databases,__db2," 797 "gdbhost2,_Web Databases,__db2,"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 883
861 TEST_F(CookiesViewTest, Filter) { 884 TEST_F(CookiesViewTest, Filter) {
862 net::CookieMonster* monster = profile_->GetCookieMonster(); 885 net::CookieMonster* monster = profile_->GetCookieMonster();
863 monster->SetCookie(GURL("http://foo0"), "C=1"); 886 monster->SetCookie(GURL("http://foo0"), "C=1");
864 monster->SetCookie(GURL("http://bar0"), "D=1"); 887 monster->SetCookie(GURL("http://bar0"), "D=1");
865 monster->SetCookie(GURL("http://foo1"), "B=1"); 888 monster->SetCookie(GURL("http://foo1"), "B=1");
866 monster->SetCookie(GURL("http://bar1"), "A=1"); 889 monster->SetCookie(GURL("http://bar1"), "A=1");
867 CookiesView cookies_view(NULL, 890 CookiesView cookies_view(NULL,
868 profile_.get(), 891 profile_.get(),
869 mock_browsing_data_database_helper_, 892 mock_browsing_data_database_helper_,
870 mock_browsing_data_local_storage_helper_); 893 mock_browsing_data_local_storage_helper_,
894 mock_browsing_data_appcache_helper_);
871 mock_browsing_data_database_helper_->AddDatabaseSamples(); 895 mock_browsing_data_database_helper_->AddDatabaseSamples();
872 mock_browsing_data_database_helper_->Notify(); 896 mock_browsing_data_database_helper_->Notify();
873 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 897 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
874 mock_browsing_data_local_storage_helper_->Notify(); 898 mock_browsing_data_local_storage_helper_->Notify();
875 899
876 EXPECT_STREQ("bar0,_Cookies,__D," 900 EXPECT_STREQ("bar0,_Cookies,__D,"
877 "bar1,_Cookies,__A," 901 "bar1,_Cookies,__A,"
878 "foo0,_Cookies,__C," 902 "foo0,_Cookies,__C,"
879 "foo1,_Cookies,__B," 903 "foo1,_Cookies,__B,"
880 "gdbhost1,_Web Databases,__db1," 904 "gdbhost1,_Web Databases,__db1,"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 952
929 TEST_F(CookiesViewTest, FilterRemoveAll) { 953 TEST_F(CookiesViewTest, FilterRemoveAll) {
930 net::CookieMonster* monster = profile_->GetCookieMonster(); 954 net::CookieMonster* monster = profile_->GetCookieMonster();
931 monster->SetCookie(GURL("http://foo0"), "C=1"); 955 monster->SetCookie(GURL("http://foo0"), "C=1");
932 monster->SetCookie(GURL("http://bar0"), "D=1"); 956 monster->SetCookie(GURL("http://bar0"), "D=1");
933 monster->SetCookie(GURL("http://foo1"), "B=1"); 957 monster->SetCookie(GURL("http://foo1"), "B=1");
934 monster->SetCookie(GURL("http://bar1"), "A=1"); 958 monster->SetCookie(GURL("http://bar1"), "A=1");
935 CookiesView cookies_view(NULL, 959 CookiesView cookies_view(NULL,
936 profile_.get(), 960 profile_.get(),
937 mock_browsing_data_database_helper_, 961 mock_browsing_data_database_helper_,
938 mock_browsing_data_local_storage_helper_); 962 mock_browsing_data_local_storage_helper_,
963 mock_browsing_data_appcache_helper_);
939 mock_browsing_data_database_helper_->AddDatabaseSamples(); 964 mock_browsing_data_database_helper_->AddDatabaseSamples();
940 mock_browsing_data_database_helper_->Notify(); 965 mock_browsing_data_database_helper_->Notify();
941 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 966 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
942 mock_browsing_data_local_storage_helper_->Notify(); 967 mock_browsing_data_local_storage_helper_->Notify();
943 968
944 EXPECT_STREQ("bar0,_Cookies,__D," 969 EXPECT_STREQ("bar0,_Cookies,__D,"
945 "bar1,_Cookies,__A," 970 "bar1,_Cookies,__A,"
946 "foo0,_Cookies,__C," 971 "foo0,_Cookies,__C,"
947 "foo1,_Cookies,__B," 972 "foo1,_Cookies,__B,"
948 "gdbhost1,_Web Databases,__db1," 973 "gdbhost1,_Web Databases,__db1,"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 TEST_F(CookiesViewTest, FilterRemove) { 1020 TEST_F(CookiesViewTest, FilterRemove) {
996 net::CookieMonster* monster = profile_->GetCookieMonster(); 1021 net::CookieMonster* monster = profile_->GetCookieMonster();
997 monster->SetCookie(GURL("http://foo0"), "C=1"); 1022 monster->SetCookie(GURL("http://foo0"), "C=1");
998 monster->SetCookie(GURL("http://bar0"), "D=1"); 1023 monster->SetCookie(GURL("http://bar0"), "D=1");
999 monster->SetCookie(GURL("http://foo1"), "B=1"); 1024 monster->SetCookie(GURL("http://foo1"), "B=1");
1000 monster->SetCookie(GURL("http://bar1"), "A=1"); 1025 monster->SetCookie(GURL("http://bar1"), "A=1");
1001 monster->SetCookie(GURL("http://bar1"), "E=1"); 1026 monster->SetCookie(GURL("http://bar1"), "E=1");
1002 CookiesView cookies_view(NULL, 1027 CookiesView cookies_view(NULL,
1003 profile_.get(), 1028 profile_.get(),
1004 mock_browsing_data_database_helper_, 1029 mock_browsing_data_database_helper_,
1005 mock_browsing_data_local_storage_helper_); 1030 mock_browsing_data_local_storage_helper_,
1031 mock_browsing_data_appcache_helper_);
1006 mock_browsing_data_database_helper_->AddDatabaseSamples(); 1032 mock_browsing_data_database_helper_->AddDatabaseSamples();
1007 mock_browsing_data_database_helper_->Notify(); 1033 mock_browsing_data_database_helper_->Notify();
1008 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); 1034 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
1009 mock_browsing_data_local_storage_helper_->Notify(); 1035 mock_browsing_data_local_storage_helper_->Notify();
1010 1036
1011 EXPECT_STREQ("bar0,_Cookies,__D," 1037 EXPECT_STREQ("bar0,_Cookies,__D,"
1012 "bar1,_Cookies,__A,__E," 1038 "bar1,_Cookies,__A,__E,"
1013 "foo0,_Cookies,__C," 1039 "foo0,_Cookies,__C,"
1014 "foo1,_Cookies,__B," 1040 "foo1,_Cookies,__B,"
1015 "gdbhost1,_Web Databases,__db1," 1041 "gdbhost1,_Web Databases,__db1,"
(...skipping 27 matching lines...) Expand all
1043 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); 1069 ASSERT_TRUE(ExpandByPath(cookies_view, "1"));
1044 EXPECT_STREQ("bar0,_Cookies,__D," 1070 EXPECT_STREQ("bar0,_Cookies,__D,"
1045 "bar1,+Cookies,++A,++E", 1071 "bar1,+Cookies,++A,++E",
1046 GetDisplayedCookies(cookies_view).c_str()); 1072 GetDisplayedCookies(cookies_view).c_str());
1047 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); 1073 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0"));
1048 1074
1049 { 1075 {
1050 SCOPED_TRACE("First selection"); 1076 SCOPED_TRACE("First selection");
1051 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 1077 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
1052 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1078 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1053 CheckDetailsSensitivity(TRUE, FALSE, FALSE, cookies_view); 1079 CheckDetailsSensitivity(TRUE, FALSE, FALSE, FALSE, cookies_view);
1054 } 1080 }
1055 1081
1056 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 1082 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
1057 1083
1058 { 1084 {
1059 SCOPED_TRACE("First selection removed"); 1085 SCOPED_TRACE("First selection removed");
1060 EXPECT_STREQ("D,E,C,B", GetMonsterCookies(monster).c_str()); 1086 EXPECT_STREQ("D,E,C,B", GetMonsterCookies(monster).c_str());
1061 EXPECT_STREQ("bar0,_Cookies,__D," 1087 EXPECT_STREQ("bar0,_Cookies,__D,"
1062 "bar1,+Cookies,++E", 1088 "bar1,+Cookies,++E",
1063 GetDisplayedCookies(cookies_view).c_str()); 1089 GetDisplayedCookies(cookies_view).c_str());
1064 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 1090 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
1065 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1091 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1066 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); 1092 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str());
1067 CheckDetailsSensitivity(TRUE, FALSE, FALSE, cookies_view); 1093 CheckDetailsSensitivity(TRUE, FALSE, FALSE, FALSE, cookies_view);
1068 } 1094 }
1069 1095
1070 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 1096 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
1071 1097
1072 { 1098 {
1073 SCOPED_TRACE("Second selection"); 1099 SCOPED_TRACE("Second selection");
1074 EXPECT_STREQ("D,C,B", GetMonsterCookies(monster).c_str()); 1100 EXPECT_STREQ("D,C,B", GetMonsterCookies(monster).c_str());
1075 EXPECT_STREQ("bar0,_Cookies,__D," 1101 EXPECT_STREQ("bar0,_Cookies,__D,"
1076 "bar1,+Cookies", 1102 "bar1,+Cookies",
1077 GetDisplayedCookies(cookies_view).c_str()); 1103 GetDisplayedCookies(cookies_view).c_str());
1078 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 1104 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
1079 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1105 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1080 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); 1106 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str());
1081 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 1107 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
1082 } 1108 }
1083 1109
1084 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); 1110 ASSERT_TRUE(ExpandByPath(cookies_view, "0"));
1085 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); 1111 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0"));
1086 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1112 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1087 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 1113 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
1088 1114
1089 { 1115 {
1090 SCOPED_TRACE("Second selection removed"); 1116 SCOPED_TRACE("Second selection removed");
1091 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); 1117 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str());
1092 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 1118 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
1093 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1119 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1094 EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str()); 1120 EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str());
1095 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 1121 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
1096 EXPECT_STREQ("bar0,+Cookies," 1122 EXPECT_STREQ("bar0,+Cookies,"
1097 "bar1,+Cookies", 1123 "bar1,+Cookies",
1098 GetDisplayedCookies(cookies_view).c_str()); 1124 GetDisplayedCookies(cookies_view).c_str());
1099 } 1125 }
1100 1126
1101 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); 1127 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_));
1102 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); 1128 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_));
1103 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); 1129 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_)));
1104 EXPECT_STREQ("foo0,_Cookies,__C," 1130 EXPECT_STREQ("foo0,_Cookies,__C,"
1105 "foo1,_Cookies,__B," 1131 "foo1,_Cookies,__B,"
(...skipping 27 matching lines...) Expand all
1133 "gdbhost2,+Web Databases,++db2," 1159 "gdbhost2,+Web Databases,++db2,"
1134 "host1,_Local Storage,__origin1," 1160 "host1,_Local Storage,__origin1,"
1135 "host2,_Local Storage,__origin2", 1161 "host2,_Local Storage,__origin2",
1136 GetDisplayedCookies(cookies_view).c_str()); 1162 GetDisplayedCookies(cookies_view).c_str());
1137 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); 1163 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0"));
1138 1164
1139 { 1165 {
1140 SCOPED_TRACE("First selection"); 1166 SCOPED_TRACE("First selection");
1141 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 1167 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
1142 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1168 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1143 CheckDetailsSensitivity(FALSE, TRUE, FALSE, cookies_view); 1169 CheckDetailsSensitivity(FALSE, TRUE, FALSE, FALSE, cookies_view);
1144 } 1170 }
1145 1171
1146 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 1172 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
1147 1173
1148 { 1174 {
1149 SCOPED_TRACE("First selection removed"); 1175 SCOPED_TRACE("First selection removed");
1150 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); 1176 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str());
1151 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," 1177 EXPECT_STREQ("gdbhost1,_Web Databases,__db1,"
1152 "gdbhost2,+Web Databases," 1178 "gdbhost2,+Web Databases,"
1153 "host1,_Local Storage,__origin1," 1179 "host1,_Local Storage,__origin1,"
1154 "host2,_Local Storage,__origin2", 1180 "host2,_Local Storage,__origin2",
1155 GetDisplayedCookies(cookies_view).c_str()); 1181 GetDisplayedCookies(cookies_view).c_str());
1156 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 1182 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
1157 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1183 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1158 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); 1184 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str());
1159 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 1185 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
1160 } 1186 }
1161 1187
1162 ASSERT_TRUE(ExpandByPath(cookies_view, "3")); 1188 ASSERT_TRUE(ExpandByPath(cookies_view, "3"));
1163 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," 1189 EXPECT_STREQ("gdbhost1,_Web Databases,__db1,"
1164 "gdbhost2,+Web Databases," 1190 "gdbhost2,+Web Databases,"
1165 "host1,_Local Storage,__origin1," 1191 "host1,_Local Storage,__origin1,"
1166 "host2,+Local Storage,++origin2", 1192 "host2,+Local Storage,++origin2",
1167 GetDisplayedCookies(cookies_view).c_str()); 1193 GetDisplayedCookies(cookies_view).c_str());
1168 ASSERT_TRUE(SelectByPath(cookies_view, "3:0:0")); 1194 ASSERT_TRUE(SelectByPath(cookies_view, "3:0:0"));
1169 1195
1170 { 1196 {
1171 SCOPED_TRACE("First selection"); 1197 SCOPED_TRACE("First selection");
1172 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 1198 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
1173 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1199 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1174 CheckDetailsSensitivity(FALSE, FALSE, TRUE, cookies_view); 1200 CheckDetailsSensitivity(FALSE, FALSE, TRUE, FALSE, cookies_view);
1175 } 1201 }
1176 1202
1177 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 1203 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
1178 1204
1179 { 1205 {
1180 SCOPED_TRACE("First selection removed"); 1206 SCOPED_TRACE("First selection removed");
1181 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); 1207 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str());
1182 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," 1208 EXPECT_STREQ("gdbhost1,_Web Databases,__db1,"
1183 "gdbhost2,+Web Databases," 1209 "gdbhost2,+Web Databases,"
1184 "host1,_Local Storage,__origin1," 1210 "host1,_Local Storage,__origin1,"
1185 "host2,+Local Storage", 1211 "host2,+Local Storage",
1186 GetDisplayedCookies(cookies_view).c_str()); 1212 GetDisplayedCookies(cookies_view).c_str());
1187 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 1213 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
1188 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 1214 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
1189 EXPECT_STREQ("3:0", GetSelectedPath(cookies_view).c_str()); 1215 EXPECT_STREQ("3:0", GetSelectedPath(cookies_view).c_str());
1190 CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); 1216 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view);
1191 } 1217 }
1192 } 1218 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/options/cookies_view.cc ('k') | chrome/browser/mock_browsing_data_appcache_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698