diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 02:51:40 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 02:51:40 +0000 |
commit | 2c76397c5f2905238200294b70388ce52603a4d6 (patch) | |
tree | 5485097fe3685ec9947557f2504a6549ab254813 /chrome/browser/gtk/options/cookies_view_unittest.cc | |
parent | 15f1a32e4d437f10fed7bc056d8877fb7c9d7d21 (diff) | |
download | chromium_src-2c76397c5f2905238200294b70388ce52603a4d6.zip chromium_src-2c76397c5f2905238200294b70388ce52603a4d6.tar.gz chromium_src-2c76397c5f2905238200294b70388ce52603a4d6.tar.bz2 |
Gtk Cookie Manager: Fix removing multiple cookies while the list is sorted.
BUG=11507
Review URL: http://codereview.chromium.org/165358
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/options/cookies_view_unittest.cc')
-rw-r--r-- | chrome/browser/gtk/options/cookies_view_unittest.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/chrome/browser/gtk/options/cookies_view_unittest.cc b/chrome/browser/gtk/options/cookies_view_unittest.cc index c2c53dd..e12969e 100644 --- a/chrome/browser/gtk/options/cookies_view_unittest.cc +++ b/chrome/browser/gtk/options/cookies_view_unittest.cc @@ -205,6 +205,39 @@ TEST_F(CookiesViewTest, Remove) { } } +TEST_F(CookiesViewTest, RemoveMultiple) { + net::CookieMonster* monster = + profile_->GetRequestContext()->cookie_store()->GetCookieMonster(); + monster->SetCookie(GURL("http://foo0"), "C=1"); + monster->SetCookie(GURL("http://foo1"), "D=1"); + monster->SetCookie(GURL("http://foo2"), "B=1"); + monster->SetCookie(GURL("http://foo3"), "A=1"); + monster->SetCookie(GURL("http://foo4"), "E=1"); + monster->SetCookie(GURL("http://foo5"), "G=1"); + monster->SetCookie(GURL("http://foo6"), "X=1"); + CookiesView cookies_view(profile_.get()); + GtkTreeIter iter; + gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 1); + gtk_tree_selection_select_iter(cookies_view.selection_, &iter); + gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 3); + gtk_tree_selection_select_iter(cookies_view.selection_, &iter); + gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 4); + gtk_tree_selection_select_iter(cookies_view.selection_, &iter); + gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 5); + gtk_tree_selection_select_iter(cookies_view.selection_, &iter); + + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); + + EXPECT_STREQ("C,B,X", GetMonsterCookies(monster).c_str()); + EXPECT_STREQ("C,B,X", GetDisplayedCookies(cookies_view).c_str()); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); +} + TEST_F(CookiesViewTest, Filter) { net::CookieMonster* monster = profile_->GetRequestContext()->cookie_store()->GetCookieMonster(); @@ -398,3 +431,44 @@ TEST_F(CookiesViewTest, SortFilterRemove) { EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); } + + +TEST_F(CookiesViewTest, SortRemoveMultiple) { + net::CookieMonster* monster = + profile_->GetRequestContext()->cookie_store()->GetCookieMonster(); + monster->SetCookie(GURL("http://foo0"), "C=1"); + monster->SetCookie(GURL("http://foo1"), "D=1"); + monster->SetCookie(GURL("http://foo2"), "B=1"); + monster->SetCookie(GURL("http://foo3"), "A=1"); + monster->SetCookie(GURL("http://foo4"), "E=1"); + monster->SetCookie(GURL("http://foo5"), "G=1"); + monster->SetCookie(GURL("http://foo6"), "X=1"); + CookiesView cookies_view(profile_.get()); + gtk_tree_sortable_set_sort_column_id( + GTK_TREE_SORTABLE(cookies_view.list_sort_), + CookiesView::COL_COOKIE_NAME, + GTK_SORT_DESCENDING); + EXPECT_STREQ("X,G,E,D,C,B,A", GetDisplayedCookies(cookies_view).c_str()); + EXPECT_STREQ("C,D,B,A,E,G,X", GetMonsterCookies(monster).c_str()); + + GtkTreeIter iter; + gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 1); + gtk_tree_selection_select_iter(cookies_view.selection_, &iter); + gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 3); + gtk_tree_selection_select_iter(cookies_view.selection_, &iter); + gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 4); + gtk_tree_selection_select_iter(cookies_view.selection_, &iter); + gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 5); + gtk_tree_selection_select_iter(cookies_view.selection_, &iter); + + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); + + EXPECT_STREQ("X,E,A", GetDisplayedCookies(cookies_view).c_str()); + EXPECT_STREQ("A,E,X", GetMonsterCookies(monster).c_str()); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); +} |