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

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

Issue 258008: Move initialization of ChromeURLRequestContexts to the IO thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync again, just in case Created 11 years, 2 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/cookies_table_model.h" 13 #include "chrome/browser/cookies_table_model.h"
14 #include "chrome/browser/net/url_request_context_getter.h"
14 #include "chrome/test/testing_profile.h" 15 #include "chrome/test/testing_profile.h"
15 #include "net/url_request/url_request_context.h" 16 #include "net/url_request/url_request_context.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace { 19 namespace {
19 20
20 class TestURLRequestContext : public URLRequestContext { 21 class TestURLRequestContext : public URLRequestContext {
21 public: 22 public:
22 TestURLRequestContext() { 23 TestURLRequestContext() {
23 cookie_store_ = new net::CookieMonster(); 24 cookie_store_ = new net::CookieMonster();
24 } 25 }
25 }; 26 };
26 27
28 class TestURLRequestContextGetter : public URLRequestContextGetter {
29 public:
30 virtual URLRequestContext* GetURLRequestContext() {
31 if (!context_)
32 context_ = new TestURLRequestContext();
33 return context_;
34 }
35 virtual net::CookieStore* GetCookieStore() {
36 return GetURLRequestContext()->cookie_store();
37 }
38 private:
39 scoped_refptr<URLRequestContext> context_;
40 };
41
27 class CookieTestingProfile : public TestingProfile { 42 class CookieTestingProfile : public TestingProfile {
28 public: 43 public:
29 virtual URLRequestContext* GetRequestContext() { 44 virtual URLRequestContextGetter* GetRequestContext() {
30 if (!url_request_context_.get()) 45 if (!url_request_context_getter_.get())
31 url_request_context_ = new TestURLRequestContext; 46 url_request_context_getter_ = new TestURLRequestContextGetter;
32 return url_request_context_.get(); 47 return url_request_context_getter_.get();
33 } 48 }
34 virtual ~CookieTestingProfile() {} 49 virtual ~CookieTestingProfile() {}
35 50
51 net::CookieMonster* GetCookieMonster() {
52 return GetRequestContext()->GetCookieStore()->GetCookieMonster();
53 }
54
36 private: 55 private:
37 scoped_refptr<TestURLRequestContext> url_request_context_; 56 scoped_refptr<URLRequestContextGetter> url_request_context_getter_;
38 }; 57 };
39 58
40 } // namespace 59 } // namespace
41 60
42 class CookiesViewTest : public testing::Test { 61 class CookiesViewTest : public testing::Test {
43 public: 62 public:
44 virtual void SetUp() { 63 virtual void SetUp() {
45 profile_.reset(new CookieTestingProfile()); 64 profile_.reset(new CookieTestingProfile());
46 } 65 }
47 66
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 TEST_F(CookiesViewTest, Empty) { 124 TEST_F(CookiesViewTest, Empty) {
106 CookiesView cookies_view(profile_.get()); 125 CookiesView cookies_view(profile_.get());
107 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 126 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
108 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 127 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
109 CheckDetailsSensitivity(FALSE, cookies_view); 128 CheckDetailsSensitivity(FALSE, cookies_view);
110 EXPECT_EQ(0, gtk_tree_model_iter_n_children( 129 EXPECT_EQ(0, gtk_tree_model_iter_n_children(
111 GTK_TREE_MODEL(cookies_view.list_store_), NULL)); 130 GTK_TREE_MODEL(cookies_view.list_store_), NULL));
112 } 131 }
113 132
114 TEST_F(CookiesViewTest, RemoveAll) { 133 TEST_F(CookiesViewTest, RemoveAll) {
115 net::CookieMonster* monster = 134 net::CookieMonster* monster = profile_->GetCookieMonster();
116 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
117 monster->SetCookie(GURL("http://foo"), "A=1"); 135 monster->SetCookie(GURL("http://foo"), "A=1");
118 monster->SetCookie(GURL("http://foo2"), "B=1"); 136 monster->SetCookie(GURL("http://foo2"), "B=1");
119 CookiesView cookies_view(profile_.get()); 137 CookiesView cookies_view(profile_.get());
120 138
121 // Reset the selection of the first row. 139 // Reset the selection of the first row.
122 gtk_tree_selection_unselect_all(cookies_view.selection_); 140 gtk_tree_selection_unselect_all(cookies_view.selection_);
123 141
124 { 142 {
125 SCOPED_TRACE("Before removing"); 143 SCOPED_TRACE("Before removing");
126 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 144 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 EXPECT_EQ(0u, monster->GetAllCookies().size()); 186 EXPECT_EQ(0u, monster->GetAllCookies().size());
169 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 187 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
170 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 188 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
171 CheckDetailsSensitivity(FALSE, cookies_view); 189 CheckDetailsSensitivity(FALSE, cookies_view);
172 EXPECT_EQ(0, gtk_tree_model_iter_n_children( 190 EXPECT_EQ(0, gtk_tree_model_iter_n_children(
173 GTK_TREE_MODEL(cookies_view.list_store_), NULL)); 191 GTK_TREE_MODEL(cookies_view.list_store_), NULL));
174 } 192 }
175 } 193 }
176 194
177 TEST_F(CookiesViewTest, Remove) { 195 TEST_F(CookiesViewTest, Remove) {
178 net::CookieMonster* monster = 196 net::CookieMonster* monster = profile_->GetCookieMonster();
179 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
180 monster->SetCookie(GURL("http://foo1"), "A=1"); 197 monster->SetCookie(GURL("http://foo1"), "A=1");
181 monster->SetCookie(GURL("http://foo2"), "B=1"); 198 monster->SetCookie(GURL("http://foo2"), "B=1");
182 monster->SetCookie(GURL("http://foo3"), "C=1"); 199 monster->SetCookie(GURL("http://foo3"), "C=1");
183 CookiesView cookies_view(profile_.get()); 200 CookiesView cookies_view(profile_.get());
184 201
185 // Reset the selection of the first row. 202 // Reset the selection of the first row.
186 gtk_tree_selection_unselect_all(cookies_view.selection_); 203 gtk_tree_selection_unselect_all(cookies_view.selection_);
187 204
188 GtkTreeIter iter; 205 GtkTreeIter iter;
189 gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 1); 206 gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 1);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 EXPECT_EQ(0u, monster->GetAllCookies().size()); 252 EXPECT_EQ(0u, monster->GetAllCookies().size());
236 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 253 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
237 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 254 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
238 CheckDetailsSensitivity(FALSE, cookies_view); 255 CheckDetailsSensitivity(FALSE, cookies_view);
239 EXPECT_EQ(0, gtk_tree_model_iter_n_children( 256 EXPECT_EQ(0, gtk_tree_model_iter_n_children(
240 GTK_TREE_MODEL(cookies_view.list_store_), NULL)); 257 GTK_TREE_MODEL(cookies_view.list_store_), NULL));
241 } 258 }
242 } 259 }
243 260
244 TEST_F(CookiesViewTest, RemoveMultiple) { 261 TEST_F(CookiesViewTest, RemoveMultiple) {
245 net::CookieMonster* monster = 262 net::CookieMonster* monster = profile_->GetCookieMonster();
246 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
247 monster->SetCookie(GURL("http://foo0"), "C=1"); 263 monster->SetCookie(GURL("http://foo0"), "C=1");
248 monster->SetCookie(GURL("http://foo1"), "D=1"); 264 monster->SetCookie(GURL("http://foo1"), "D=1");
249 monster->SetCookie(GURL("http://foo2"), "B=1"); 265 monster->SetCookie(GURL("http://foo2"), "B=1");
250 monster->SetCookie(GURL("http://foo3"), "A=1"); 266 monster->SetCookie(GURL("http://foo3"), "A=1");
251 monster->SetCookie(GURL("http://foo4"), "E=1"); 267 monster->SetCookie(GURL("http://foo4"), "E=1");
252 monster->SetCookie(GURL("http://foo5"), "G=1"); 268 monster->SetCookie(GURL("http://foo5"), "G=1");
253 monster->SetCookie(GURL("http://foo6"), "X=1"); 269 monster->SetCookie(GURL("http://foo6"), "X=1");
254 CookiesView cookies_view(profile_.get()); 270 CookiesView cookies_view(profile_.get());
255 271
256 // Reset the selection of the first row. 272 // Reset the selection of the first row.
(...skipping 15 matching lines...) Expand all
272 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 288 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
273 289
274 EXPECT_STREQ("C,B,X", GetMonsterCookies(monster).c_str()); 290 EXPECT_STREQ("C,B,X", GetMonsterCookies(monster).c_str());
275 EXPECT_STREQ("C,B,X", GetDisplayedCookies(cookies_view).c_str()); 291 EXPECT_STREQ("C,B,X", GetDisplayedCookies(cookies_view).c_str());
276 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 292 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
277 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 293 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
278 EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); 294 EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_));
279 } 295 }
280 296
281 TEST_F(CookiesViewTest, RemoveDefaultSelection) { 297 TEST_F(CookiesViewTest, RemoveDefaultSelection) {
282 net::CookieMonster* monster = 298 net::CookieMonster* monster = profile_->GetCookieMonster();
283 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
284 monster->SetCookie(GURL("http://foo1"), "A=1"); 299 monster->SetCookie(GURL("http://foo1"), "A=1");
285 monster->SetCookie(GURL("http://foo2"), "B=1"); 300 monster->SetCookie(GURL("http://foo2"), "B=1");
286 monster->SetCookie(GURL("http://foo3"), "C=1"); 301 monster->SetCookie(GURL("http://foo3"), "C=1");
287 // Now CookiesView select the first row when it is opened. 302 // Now CookiesView select the first row when it is opened.
288 CookiesView cookies_view(profile_.get()); 303 CookiesView cookies_view(profile_.get());
289 304
290 { 305 {
291 SCOPED_TRACE("First selection"); 306 SCOPED_TRACE("First selection");
292 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 307 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
293 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 308 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
294 CheckDetailsSensitivity(TRUE, cookies_view); 309 CheckDetailsSensitivity(TRUE, cookies_view);
295 EXPECT_EQ(3, gtk_tree_model_iter_n_children( 310 EXPECT_EQ(3, gtk_tree_model_iter_n_children(
296 GTK_TREE_MODEL(cookies_view.list_store_), NULL)); 311 GTK_TREE_MODEL(cookies_view.list_store_), NULL));
297 } 312 }
298 313
299 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 314 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
300 315
301 { 316 {
302 SCOPED_TRACE("First selection removed"); 317 SCOPED_TRACE("First selection removed");
303 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); 318 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str());
304 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_view).c_str()); 319 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_view).c_str());
305 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 320 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
306 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 321 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
307 CheckDetailsSensitivity(FALSE, cookies_view); 322 CheckDetailsSensitivity(FALSE, cookies_view);
308 } 323 }
309 } 324 }
310 325
311 TEST_F(CookiesViewTest, Filter) { 326 TEST_F(CookiesViewTest, Filter) {
312 net::CookieMonster* monster = 327 net::CookieMonster* monster = profile_->GetCookieMonster();
313 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
314 monster->SetCookie(GURL("http://foo1"), "A=1"); 328 monster->SetCookie(GURL("http://foo1"), "A=1");
315 monster->SetCookie(GURL("http://bar1"), "B=1"); 329 monster->SetCookie(GURL("http://bar1"), "B=1");
316 monster->SetCookie(GURL("http://foo2"), "C=1"); 330 monster->SetCookie(GURL("http://foo2"), "C=1");
317 monster->SetCookie(GURL("http://bar2"), "D=1"); 331 monster->SetCookie(GURL("http://bar2"), "D=1");
318 CookiesView cookies_view(profile_.get()); 332 CookiesView cookies_view(profile_.get());
319 EXPECT_EQ(4, gtk_tree_model_iter_n_children( 333 EXPECT_EQ(4, gtk_tree_model_iter_n_children(
320 GTK_TREE_MODEL(cookies_view.list_store_), NULL)); 334 GTK_TREE_MODEL(cookies_view.list_store_), NULL));
321 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 335 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
322 336
323 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); 337 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar");
(...skipping 13 matching lines...) Expand all
337 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 351 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
338 352
339 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar22"); 353 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar22");
340 gtk_widget_activate(cookies_view.filter_entry_); 354 gtk_widget_activate(cookies_view.filter_entry_);
341 EXPECT_EQ(0, gtk_tree_model_iter_n_children( 355 EXPECT_EQ(0, gtk_tree_model_iter_n_children(
342 GTK_TREE_MODEL(cookies_view.list_store_), NULL)); 356 GTK_TREE_MODEL(cookies_view.list_store_), NULL));
343 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 357 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
344 } 358 }
345 359
346 TEST_F(CookiesViewTest, FilterRemoveAll) { 360 TEST_F(CookiesViewTest, FilterRemoveAll) {
347 net::CookieMonster* monster = 361 net::CookieMonster* monster = profile_->GetCookieMonster();
348 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
349 monster->SetCookie(GURL("http://foo1"), "A=1"); 362 monster->SetCookie(GURL("http://foo1"), "A=1");
350 monster->SetCookie(GURL("http://bar1"), "B=1"); 363 monster->SetCookie(GURL("http://bar1"), "B=1");
351 monster->SetCookie(GURL("http://foo2"), "C=1"); 364 monster->SetCookie(GURL("http://foo2"), "C=1");
352 monster->SetCookie(GURL("http://bar2"), "D=1"); 365 monster->SetCookie(GURL("http://bar2"), "D=1");
353 CookiesView cookies_view(profile_.get()); 366 CookiesView cookies_view(profile_.get());
354 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); 367 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar");
355 gtk_widget_activate(cookies_view.filter_entry_); 368 gtk_widget_activate(cookies_view.filter_entry_);
356 EXPECT_STREQ("B,D,A,C", GetMonsterCookies(monster).c_str()); 369 EXPECT_STREQ("B,D,A,C", GetMonsterCookies(monster).c_str());
357 EXPECT_STREQ("B,D", GetDisplayedCookies(cookies_view).c_str()); 370 EXPECT_STREQ("B,D", GetDisplayedCookies(cookies_view).c_str());
358 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 371 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
359 372
360 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); 373 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_));
361 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); 374 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
362 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); 375 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
363 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 376 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
364 377
365 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), ""); 378 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "");
366 gtk_widget_activate(cookies_view.filter_entry_); 379 gtk_widget_activate(cookies_view.filter_entry_);
367 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); 380 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
368 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_view).c_str()); 381 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_view).c_str());
369 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 382 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
370 } 383 }
371 384
372 TEST_F(CookiesViewTest, FilterRemove) { 385 TEST_F(CookiesViewTest, FilterRemove) {
373 net::CookieMonster* monster = 386 net::CookieMonster* monster = profile_->GetCookieMonster();
374 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
375 monster->SetCookie(GURL("http://foo1"), "A=1"); 387 monster->SetCookie(GURL("http://foo1"), "A=1");
376 monster->SetCookie(GURL("http://bar1"), "B=1"); 388 monster->SetCookie(GURL("http://bar1"), "B=1");
377 monster->SetCookie(GURL("http://foo2"), "C=1"); 389 monster->SetCookie(GURL("http://foo2"), "C=1");
378 monster->SetCookie(GURL("http://bar2"), "D=1"); 390 monster->SetCookie(GURL("http://bar2"), "D=1");
379 CookiesView cookies_view(profile_.get()); 391 CookiesView cookies_view(profile_.get());
380 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); 392 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar");
381 gtk_widget_activate(cookies_view.filter_entry_); 393 gtk_widget_activate(cookies_view.filter_entry_);
382 EXPECT_STREQ("B,D,A,C", GetMonsterCookies(monster).c_str()); 394 EXPECT_STREQ("B,D,A,C", GetMonsterCookies(monster).c_str());
383 EXPECT_STREQ("B,D", GetDisplayedCookies(cookies_view).c_str()); 395 EXPECT_STREQ("B,D", GetDisplayedCookies(cookies_view).c_str());
384 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 396 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
(...skipping 14 matching lines...) Expand all
399 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 411 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
400 412
401 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 413 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
402 414
403 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); 415 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
404 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); 416 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
405 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 417 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
406 } 418 }
407 419
408 TEST_F(CookiesViewTest, Sort) { 420 TEST_F(CookiesViewTest, Sort) {
409 net::CookieMonster* monster = 421 net::CookieMonster* monster = profile_->GetCookieMonster();
410 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
411 monster->SetCookie(GURL("http://foo1"), "X=1"); 422 monster->SetCookie(GURL("http://foo1"), "X=1");
412 monster->SetCookie(GURL("http://bar1"), "Z=1"); 423 monster->SetCookie(GURL("http://bar1"), "Z=1");
413 monster->SetCookie(GURL("http://foo2"), "C=1"); 424 monster->SetCookie(GURL("http://foo2"), "C=1");
414 monster->SetCookie(GURL("http://bar2"), "D=1"); 425 monster->SetCookie(GURL("http://bar2"), "D=1");
415 CookiesView cookies_view(profile_.get()); 426 CookiesView cookies_view(profile_.get());
416 EXPECT_STREQ("Z,D,X,C", GetMonsterCookies(monster).c_str()); 427 EXPECT_STREQ("Z,D,X,C", GetMonsterCookies(monster).c_str());
417 EXPECT_STREQ("Z,D,X,C", GetDisplayedCookies(cookies_view).c_str()); 428 EXPECT_STREQ("Z,D,X,C", GetDisplayedCookies(cookies_view).c_str());
418 429
419 gtk_tree_sortable_set_sort_column_id( 430 gtk_tree_sortable_set_sort_column_id(
420 GTK_TREE_SORTABLE(cookies_view.list_sort_), 431 GTK_TREE_SORTABLE(cookies_view.list_sort_),
(...skipping 14 matching lines...) Expand all
435 EXPECT_STREQ("C,D,X,Z", GetDisplayedCookies(cookies_view).c_str()); 446 EXPECT_STREQ("C,D,X,Z", GetDisplayedCookies(cookies_view).c_str());
436 447
437 gtk_tree_sortable_set_sort_column_id( 448 gtk_tree_sortable_set_sort_column_id(
438 GTK_TREE_SORTABLE(cookies_view.list_sort_), 449 GTK_TREE_SORTABLE(cookies_view.list_sort_),
439 CookiesView::COL_COOKIE_NAME, 450 CookiesView::COL_COOKIE_NAME,
440 GTK_SORT_DESCENDING); 451 GTK_SORT_DESCENDING);
441 EXPECT_STREQ("Z,X,D,C", GetDisplayedCookies(cookies_view).c_str()); 452 EXPECT_STREQ("Z,X,D,C", GetDisplayedCookies(cookies_view).c_str());
442 } 453 }
443 454
444 TEST_F(CookiesViewTest, SortRemove) { 455 TEST_F(CookiesViewTest, SortRemove) {
445 net::CookieMonster* monster = 456 net::CookieMonster* monster = profile_->GetCookieMonster();
446 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
447 monster->SetCookie(GURL("http://foo1"), "B=1"); 457 monster->SetCookie(GURL("http://foo1"), "B=1");
448 monster->SetCookie(GURL("http://bar1"), "Z=1"); 458 monster->SetCookie(GURL("http://bar1"), "Z=1");
449 monster->SetCookie(GURL("http://foo2"), "C=1"); 459 monster->SetCookie(GURL("http://foo2"), "C=1");
450 monster->SetCookie(GURL("http://bar2"), "A=1"); 460 monster->SetCookie(GURL("http://bar2"), "A=1");
451 CookiesView cookies_view(profile_.get()); 461 CookiesView cookies_view(profile_.get());
452 EXPECT_STREQ("Z,A,B,C", GetMonsterCookies(monster).c_str()); 462 EXPECT_STREQ("Z,A,B,C", GetMonsterCookies(monster).c_str());
453 EXPECT_STREQ("Z,A,B,C", GetDisplayedCookies(cookies_view).c_str()); 463 EXPECT_STREQ("Z,A,B,C", GetDisplayedCookies(cookies_view).c_str());
454 464
455 gtk_tree_sortable_set_sort_column_id( 465 gtk_tree_sortable_set_sort_column_id(
456 GTK_TREE_SORTABLE(cookies_view.list_sort_), 466 GTK_TREE_SORTABLE(cookies_view.list_sort_),
457 CookiesView::COL_COOKIE_NAME, 467 CookiesView::COL_COOKIE_NAME,
458 GTK_SORT_DESCENDING); 468 GTK_SORT_DESCENDING);
459 EXPECT_STREQ("Z,C,B,A", GetDisplayedCookies(cookies_view).c_str()); 469 EXPECT_STREQ("Z,C,B,A", GetDisplayedCookies(cookies_view).c_str());
460 470
461 // Reset the selection of the first row. 471 // Reset the selection of the first row.
462 gtk_tree_selection_unselect_all(cookies_view.selection_); 472 gtk_tree_selection_unselect_all(cookies_view.selection_);
463 473
464 GtkTreeIter iter; 474 GtkTreeIter iter;
465 gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 3); 475 gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 3);
466 gtk_tree_selection_select_iter(cookies_view.selection_, &iter); 476 gtk_tree_selection_select_iter(cookies_view.selection_, &iter);
467 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 477 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
468 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 478 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
469 EXPECT_STREQ("Z,B,C", GetMonsterCookies(monster).c_str()); 479 EXPECT_STREQ("Z,B,C", GetMonsterCookies(monster).c_str());
470 EXPECT_STREQ("Z,C,B", GetDisplayedCookies(cookies_view).c_str()); 480 EXPECT_STREQ("Z,C,B", GetDisplayedCookies(cookies_view).c_str());
471 } 481 }
472 482
473 TEST_F(CookiesViewTest, SortFilterRemove) { 483 TEST_F(CookiesViewTest, SortFilterRemove) {
474 net::CookieMonster* monster = 484 net::CookieMonster* monster = profile_->GetCookieMonster();
475 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
476 monster->SetCookie(GURL("http://foo1"), "B=1"); 485 monster->SetCookie(GURL("http://foo1"), "B=1");
477 monster->SetCookie(GURL("http://bar1"), "Z=1"); 486 monster->SetCookie(GURL("http://bar1"), "Z=1");
478 monster->SetCookie(GURL("http://foo2"), "C=1"); 487 monster->SetCookie(GURL("http://foo2"), "C=1");
479 monster->SetCookie(GURL("http://bar2"), "A=1"); 488 monster->SetCookie(GURL("http://bar2"), "A=1");
480 CookiesView cookies_view(profile_.get()); 489 CookiesView cookies_view(profile_.get());
481 EXPECT_STREQ("Z,A,B,C", GetMonsterCookies(monster).c_str()); 490 EXPECT_STREQ("Z,A,B,C", GetMonsterCookies(monster).c_str());
482 EXPECT_STREQ("Z,A,B,C", GetDisplayedCookies(cookies_view).c_str()); 491 EXPECT_STREQ("Z,A,B,C", GetDisplayedCookies(cookies_view).c_str());
483 492
484 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); 493 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar");
485 gtk_widget_activate(cookies_view.filter_entry_); 494 gtk_widget_activate(cookies_view.filter_entry_);
(...skipping 13 matching lines...) Expand all
499 508
500 gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 0); 509 gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 0);
501 gtk_tree_selection_select_iter(cookies_view.selection_, &iter); 510 gtk_tree_selection_select_iter(cookies_view.selection_, &iter);
502 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 511 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
503 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 512 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
504 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); 513 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str());
505 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); 514 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
506 } 515 }
507 516
508 TEST_F(CookiesViewTest, SortRemoveMultiple) { 517 TEST_F(CookiesViewTest, SortRemoveMultiple) {
509 net::CookieMonster* monster = 518 net::CookieMonster* monster = profile_->GetCookieMonster();
510 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
511 monster->SetCookie(GURL("http://foo0"), "C=1"); 519 monster->SetCookie(GURL("http://foo0"), "C=1");
512 monster->SetCookie(GURL("http://foo1"), "D=1"); 520 monster->SetCookie(GURL("http://foo1"), "D=1");
513 monster->SetCookie(GURL("http://foo2"), "B=1"); 521 monster->SetCookie(GURL("http://foo2"), "B=1");
514 monster->SetCookie(GURL("http://foo3"), "A=1"); 522 monster->SetCookie(GURL("http://foo3"), "A=1");
515 monster->SetCookie(GURL("http://foo4"), "E=1"); 523 monster->SetCookie(GURL("http://foo4"), "E=1");
516 monster->SetCookie(GURL("http://foo5"), "G=1"); 524 monster->SetCookie(GURL("http://foo5"), "G=1");
517 monster->SetCookie(GURL("http://foo6"), "X=1"); 525 monster->SetCookie(GURL("http://foo6"), "X=1");
518 CookiesView cookies_view(profile_.get()); 526 CookiesView cookies_view(profile_.get());
519 gtk_tree_sortable_set_sort_column_id( 527 gtk_tree_sortable_set_sort_column_id(
520 GTK_TREE_SORTABLE(cookies_view.list_sort_), 528 GTK_TREE_SORTABLE(cookies_view.list_sort_),
(...skipping 18 matching lines...) Expand all
539 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 547 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
540 548
541 EXPECT_STREQ("X,E,A", GetDisplayedCookies(cookies_view).c_str()); 549 EXPECT_STREQ("X,E,A", GetDisplayedCookies(cookies_view).c_str());
542 EXPECT_STREQ("A,E,X", GetMonsterCookies(monster).c_str()); 550 EXPECT_STREQ("A,E,X", GetMonsterCookies(monster).c_str());
543 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); 551 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
544 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 552 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
545 EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); 553 EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_));
546 } 554 }
547 555
548 TEST_F(CookiesViewTest, SortRemoveDefaultSelection) { 556 TEST_F(CookiesViewTest, SortRemoveDefaultSelection) {
549 net::CookieMonster* monster = 557 net::CookieMonster* monster = profile_->GetCookieMonster();
550 profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
551 monster->SetCookie(GURL("http://foo1"), "Z=1"); 558 monster->SetCookie(GURL("http://foo1"), "Z=1");
552 monster->SetCookie(GURL("http://bar1"), "X=1"); 559 monster->SetCookie(GURL("http://bar1"), "X=1");
553 monster->SetCookie(GURL("http://foo2"), "W=1"); 560 monster->SetCookie(GURL("http://foo2"), "W=1");
554 monster->SetCookie(GURL("http://bar2"), "Y=1"); 561 monster->SetCookie(GURL("http://bar2"), "Y=1");
555 CookiesView cookies_view(profile_.get()); 562 CookiesView cookies_view(profile_.get());
556 EXPECT_STREQ("X,Y,Z,W", GetMonsterCookies(monster).c_str()); 563 EXPECT_STREQ("X,Y,Z,W", GetMonsterCookies(monster).c_str());
557 EXPECT_STREQ("X,Y,Z,W", GetDisplayedCookies(cookies_view).c_str()); 564 EXPECT_STREQ("X,Y,Z,W", GetDisplayedCookies(cookies_view).c_str());
558 565
559 gtk_tree_sortable_set_sort_column_id( 566 gtk_tree_sortable_set_sort_column_id(
560 GTK_TREE_SORTABLE(cookies_view.list_sort_), 567 GTK_TREE_SORTABLE(cookies_view.list_sort_),
561 CookiesView::COL_COOKIE_NAME, 568 CookiesView::COL_COOKIE_NAME,
562 GTK_SORT_ASCENDING); 569 GTK_SORT_ASCENDING);
563 EXPECT_STREQ("W,X,Y,Z", GetDisplayedCookies(cookies_view).c_str()); 570 EXPECT_STREQ("W,X,Y,Z", GetDisplayedCookies(cookies_view).c_str());
564 571
565 GtkTreeIter iter; 572 GtkTreeIter iter;
566 gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 3); 573 gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 3);
567 gtk_tree_selection_select_iter(cookies_view.selection_, &iter); 574 gtk_tree_selection_select_iter(cookies_view.selection_, &iter);
568 575
569 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); 576 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
570 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); 577 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
571 EXPECT_STREQ("Y,W", GetMonsterCookies(monster).c_str()); 578 EXPECT_STREQ("Y,W", GetMonsterCookies(monster).c_str());
572 EXPECT_STREQ("W,Y", GetDisplayedCookies(cookies_view).c_str()); 579 EXPECT_STREQ("W,Y", GetDisplayedCookies(cookies_view).c_str());
573 } 580 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/browser/importer/toolbar_importer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698