summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/options
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/gtk/options')
-rw-r--r--chrome/browser/gtk/options/cookies_view.cc8
-rw-r--r--chrome/browser/gtk/options/cookies_view.h2
-rw-r--r--chrome/browser/gtk/options/cookies_view_unittest.cc74
3 files changed, 80 insertions, 4 deletions
diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc
index 4b4edf1..905e633 100644
--- a/chrome/browser/gtk/options/cookies_view.cc
+++ b/chrome/browser/gtk/options/cookies_view.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/gtk/options/cookies_view.h"
+#include <set>
#include <string>
-#include <vector>
#include "app/l10n_util.h"
#include "base/gfx/gtk_util.h"
@@ -350,16 +350,16 @@ void CookiesView::ClearCookieDetails() {
void CookiesView::RemoveSelectedCookies() {
GList* list = gtk_tree_selection_get_selected_rows(selection_, NULL);
- std::vector<int> selected_rows;
+ std::set<int> selected_rows;
GList* node;
for (node = list; node != NULL; node = node->next) {
- selected_rows.push_back(gtk_tree::GetTreeSortChildRowNumForPath(
+ selected_rows.insert(gtk_tree::GetTreeSortChildRowNumForPath(
list_sort_, static_cast<GtkTreePath*>(node->data)));
}
g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
g_list_free(list);
- for (std::vector<int>::reverse_iterator selected = selected_rows.rbegin();
+ for (std::set<int>::reverse_iterator selected = selected_rows.rbegin();
selected != selected_rows.rend(); ++selected) {
cookies_table_model_->RemoveCookies(*selected, 1);
}
diff --git a/chrome/browser/gtk/options/cookies_view.h b/chrome/browser/gtk/options/cookies_view.h
index a2ae010..8c565c7 100644
--- a/chrome/browser/gtk/options/cookies_view.h
+++ b/chrome/browser/gtk/options/cookies_view.h
@@ -142,12 +142,14 @@ class CookiesView : public gtk_tree::ModelAdapter::Delegate {
FRIEND_TEST(CookiesViewTest, Empty);
FRIEND_TEST(CookiesViewTest, RemoveAll);
FRIEND_TEST(CookiesViewTest, Remove);
+ FRIEND_TEST(CookiesViewTest, RemoveMultiple);
FRIEND_TEST(CookiesViewTest, Filter);
FRIEND_TEST(CookiesViewTest, FilterRemoveAll);
FRIEND_TEST(CookiesViewTest, FilterRemove);
FRIEND_TEST(CookiesViewTest, Sort);
FRIEND_TEST(CookiesViewTest, SortRemove);
FRIEND_TEST(CookiesViewTest, SortFilterRemove);
+ FRIEND_TEST(CookiesViewTest, SortRemoveMultiple);
DISALLOW_COPY_AND_ASSIGN(CookiesView);
};
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_));
+}