summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/options
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 00:07:33 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 00:07:33 +0000
commit918de45c8b78f05dbb6fef23dc1912174d51878d (patch)
tree52c6952e4cf61ae94c2a968068e09df7d687893e /chrome/browser/gtk/options
parent58fa398caf8b71a608490fee0457cf0d229c7e0d (diff)
downloadchromium_src-918de45c8b78f05dbb6fef23dc1912174d51878d.zip
chromium_src-918de45c8b78f05dbb6fef23dc1912174d51878d.tar.gz
chromium_src-918de45c8b78f05dbb6fef23dc1912174d51878d.tar.bz2
Changelist for mattm readability review.
Review URL: http://codereview.chromium.org/160037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/options')
-rw-r--r--chrome/browser/gtk/options/cookies_view.cc70
-rw-r--r--chrome/browser/gtk/options/cookies_view.h49
-rw-r--r--chrome/browser/gtk/options/cookies_view_unittest.cc225
3 files changed, 187 insertions, 157 deletions
diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc
index 83cfa21..31bcdb1 100644
--- a/chrome/browser/gtk/options/cookies_view.cc
+++ b/chrome/browser/gtk/options/cookies_view.cc
@@ -4,6 +4,9 @@
#include "chrome/browser/gtk/options/cookies_view.h"
+#include <string>
+#include <vector>
+
#include "app/l10n_util.h"
#include "base/gfx/gtk_util.h"
#include "base/message_loop.h"
@@ -40,8 +43,8 @@ void InitCookieDetailStyle(GtkWidget* entry, GtkStyle* label_style,
gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE,
&label_style->fg[GTK_STATE_INSENSITIVE]);
// GTK_NO_WINDOW widgets like GtkLabel don't draw their own background, so we
- // combine the normal or insensitive fg of the label style with the normal
- // background of the window style to achieve the "normal label" and
+ // combine the normal or insensitive foreground of the label style with the
+ // normal background of the window style to achieve the "normal label" and
// "insensitive label" colors.
gtk_widget_modify_base(entry, GTK_STATE_NORMAL,
&dialog_style->bg[GTK_STATE_NORMAL]);
@@ -205,17 +208,20 @@ void CookiesView::Init() {
gtk_table_set_col_spacing(GTK_TABLE(cookie_details_table_), 0,
gtk_util::kLabelSpacing);
- InitCookieDetailRow(0, IDS_COOKIES_COOKIE_NAME_LABEL, &cookie_name_entry_);
- InitCookieDetailRow(1, IDS_COOKIES_COOKIE_CONTENT_LABEL,
+ int row = 0;
+ InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL,
+ &cookie_name_entry_);
+ InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_CONTENT_LABEL,
&cookie_content_entry_);
- InitCookieDetailRow(2, IDS_COOKIES_COOKIE_DOMAIN_LABEL,
+ InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL,
&cookie_domain_entry_);
- InitCookieDetailRow(3, IDS_COOKIES_COOKIE_PATH_LABEL, &cookie_path_entry_);
- InitCookieDetailRow(4, IDS_COOKIES_COOKIE_SENDFOR_LABEL,
+ InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_PATH_LABEL,
+ &cookie_path_entry_);
+ InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_SENDFOR_LABEL,
&cookie_send_for_entry_);
- InitCookieDetailRow(5, IDS_COOKIES_COOKIE_CREATED_LABEL,
+ InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL,
&cookie_created_entry_);
- InitCookieDetailRow(6, IDS_COOKIES_COOKIE_EXPIRES_LABEL,
+ InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL,
&cookie_expires_entry_);
// Initialize model.
@@ -336,13 +342,11 @@ void CookiesView::ClearCookieDetails() {
void CookiesView::RemoveSelectedCookies() {
GList* list = gtk_tree_selection_get_selected_rows(selection_, NULL);
- std::vector<int> selected_rows(
- gtk_tree_selection_count_selected_rows(selection_));
+ std::vector<int> selected_rows;
GList* node;
- size_t i;
- for (i = 0, node = list; node != NULL; ++i, node = node->next) {
- selected_rows[i] = gtk_tree::GetTreeSortChildRowNumForPath(
- list_sort_, static_cast<GtkTreePath*>(node->data));
+ for (node = list; node != NULL; node = node->next) {
+ selected_rows.push_back(gtk_tree::GetTreeSortChildRowNumForPath(
+ list_sort_, static_cast<GtkTreePath*>(node->data)));
}
g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
g_list_free(list);
@@ -391,15 +395,17 @@ void CookiesView::OnModelChanged() {
void CookiesView::OnItemsChanged(int start, int length) {
GtkTreeIter iter;
- bool rv = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store_),
- &iter, NULL, start);
+ if (!gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store_),
+ &iter, NULL, start)) {
+ NOTREACHED();
+ return;
+ }
for (int i = 0; i < length; ++i) {
- if (!rv) {
+ SetColumnValues(start + i, &iter);
+ if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store_), &iter)) {
NOTREACHED();
return;
}
- SetColumnValues(start + i, &iter);
- rv = gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store_), &iter);
}
}
@@ -420,22 +426,26 @@ void CookiesView::OnItemsRemoved(int start, int length) {
EnableControls();
}
-// static
-gint CookiesView::CompareSite(GtkTreeModel* model, GtkTreeIter* a,
- GtkTreeIter* b, gpointer window) {
+// Compare the value of the given column at the given rows.
+gint CookiesView::CompareRows(GtkTreeModel* model, GtkTreeIter* a,
+ GtkTreeIter* b, int column_id) {
int row1 = gtk_tree::GetRowNumForIter(model, a);
int row2 = gtk_tree::GetRowNumForIter(model, b);
- return reinterpret_cast<CookiesView*>(window)->cookies_table_model_->
- CompareValues(row1, row2, IDS_COOKIES_DOMAIN_COLUMN_HEADER);
+ return cookies_table_model_->CompareValues(row1, row2, column_id);
+}
+
+// static
+gint CookiesView::CompareSite(GtkTreeModel* model, GtkTreeIter* a,
+ GtkTreeIter* b, gpointer window) {
+ return static_cast<CookiesView*>(window)->CompareRows(
+ model, a, b, IDS_COOKIES_DOMAIN_COLUMN_HEADER);
}
// static
gint CookiesView::CompareCookieName(GtkTreeModel* model, GtkTreeIter* a,
- GtkTreeIter* b, gpointer window) {
- int row1 = gtk_tree::GetRowNumForIter(model, a);
- int row2 = gtk_tree::GetRowNumForIter(model, b);
- return reinterpret_cast<CookiesView*>(window)->cookies_table_model_->
- CompareValues(row1, row2, IDS_COOKIES_NAME_COLUMN_HEADER);
+ GtkTreeIter* b, gpointer window) {
+ return static_cast<CookiesView*>(window)->CompareRows(
+ model, a, b, IDS_COOKIES_NAME_COLUMN_HEADER);
}
// static
diff --git a/chrome/browser/gtk/options/cookies_view.h b/chrome/browser/gtk/options/cookies_view.h
index 770904f..2cca9c6 100644
--- a/chrome/browser/gtk/options/cookies_view.h
+++ b/chrome/browser/gtk/options/cookies_view.h
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// This is the Gtk implementation of the Cookie Manager dialog.
+
#ifndef CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_
#define CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_
@@ -17,13 +19,25 @@ class CookiesTableModel;
class CookiesViewTest;
class Profile;
+// CookiesView is thread-hostile, and should only be called on the UI thread.
+// Usage:
+// CookiesView::Show(profile);
+// Once the CookiesView is shown, it is responsible for deleting itself when the
+// user closes the dialog.
+
class CookiesView : public TableModelObserver {
public:
virtual ~CookiesView();
- // Create (if necessary) and show the keyword window window.
+ // Create (if necessary) and show the cookie manager window.
static void Show(Profile* profile);
+ // TableModelObserver implementation.
+ virtual void OnModelChanged();
+ virtual void OnItemsChanged(int start, int length);
+ virtual void OnItemsAdded(int start, int length);
+ virtual void OnItemsRemoved(int start, int length);
+
private:
// Column ids for |list_store_|.
enum {
@@ -66,11 +80,9 @@ class CookiesView : public TableModelObserver {
// Add the values from |row| of |cookies_table_model_|.
void AddNodeToList(int row);
- // TableModelObserver implementation.
- virtual void OnModelChanged();
- virtual void OnItemsChanged(int start, int length);
- virtual void OnItemsAdded(int start, int length);
- virtual void OnItemsRemoved(int start, int length);
+ // Compare the value of the given column at the given rows.
+ gint CompareRows(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b,
+ int column_id);
// List sorting callbacks.
static gint CompareSite(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b,
@@ -98,8 +110,10 @@ class CookiesView : public TableModelObserver {
static void OnFilterClearButtonClicked(GtkButton* button,
CookiesView* window);
- // Widgets of the dialog.
+ // The parent widget.
GtkWidget* dialog_;
+
+ // Widgets of the dialog.
GtkWidget* description_label_;
GtkWidget* filter_entry_;
GtkWidget* filter_clear_button_;
@@ -125,7 +139,7 @@ class CookiesView : public TableModelObserver {
// The profile.
Profile* profile_;
- // The Cookies Table model
+ // The Cookies Table model.
scoped_ptr<CookiesTableModel> cookies_table_model_;
// A factory to construct Runnable Methods so that we can be called back to
@@ -133,18 +147,17 @@ class CookiesView : public TableModelObserver {
ScopedRunnableMethodFactory<CookiesView> filter_update_factory_;
friend class CookiesViewTest;
- FRIEND_TEST(CookiesViewTest, TestEmpty);
- FRIEND_TEST(CookiesViewTest, TestRemoveAll);
- FRIEND_TEST(CookiesViewTest, TestRemove);
- FRIEND_TEST(CookiesViewTest, TestFilter);
- FRIEND_TEST(CookiesViewTest, TestFilterRemoveAll);
- FRIEND_TEST(CookiesViewTest, TestFilterRemove);
- FRIEND_TEST(CookiesViewTest, TestSort);
- FRIEND_TEST(CookiesViewTest, TestSortRemove);
- FRIEND_TEST(CookiesViewTest, TestSortFilterRemove);
+ FRIEND_TEST(CookiesViewTest, Empty);
+ FRIEND_TEST(CookiesViewTest, RemoveAll);
+ FRIEND_TEST(CookiesViewTest, Remove);
+ FRIEND_TEST(CookiesViewTest, Filter);
+ FRIEND_TEST(CookiesViewTest, FilterRemoveAll);
+ FRIEND_TEST(CookiesViewTest, FilterRemove);
+ FRIEND_TEST(CookiesViewTest, Sort);
+ FRIEND_TEST(CookiesViewTest, SortRemove);
+ FRIEND_TEST(CookiesViewTest, SortFilterRemove);
DISALLOW_COPY_AND_ASSIGN(CookiesView);
};
-
#endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_
diff --git a/chrome/browser/gtk/options/cookies_view_unittest.cc b/chrome/browser/gtk/options/cookies_view_unittest.cc
index d5b65bc..c2c53dd 100644
--- a/chrome/browser/gtk/options/cookies_view_unittest.cc
+++ b/chrome/browser/gtk/options/cookies_view_unittest.cc
@@ -4,9 +4,12 @@
#include "chrome/browser/gtk/options/cookies_view.h"
-#include <cstdarg>
+#include <string>
+#include <vector>
+
#include <gtk/gtk.h>
+#include "base/string_util.h"
#include "chrome/browser/cookies_table_model.h"
#include "chrome/test/testing_profile.h"
#include "net/url_request/url_request_context.h"
@@ -41,16 +44,10 @@ class CookieTestingProfile : public TestingProfile {
class CookiesViewTest : public testing::Test {
public:
- CookiesViewTest() {
- }
-
virtual void SetUp() {
profile_.reset(new CookieTestingProfile());
}
- virtual void TearDown() {
- }
-
void CheckDetailsSensitivity(gboolean expected,
const CookiesView& cookies_view) {
EXPECT_EQ(expected,
@@ -69,46 +66,38 @@ class CookiesViewTest : public testing::Test {
GTK_WIDGET_SENSITIVE(cookies_view.cookie_expires_entry_));
}
- // Check if the cookie names in the cookie list match the given ones.
+ // Get the cookie names in the cookie list, as a comma seperated string.
// (Note that the CookieMonster cookie list is sorted by domain.)
// Ex:
// monster->SetCookie(GURL("http://b"), "X=1")
// monster->SetCookie(GURL("http://a"), "Y=1")
- // CheckCookieList(monster, "Y", "X", NULL);
- void CheckCookieList(net::CookieMonster* monster, ...) {
- va_list ap;
- va_start(ap, monster);
+ // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str());
+ std::string GetMonsterCookies(net::CookieMonster* monster) {
+ std::vector<std::string> parts;
net::CookieMonster::CookieList cookie_list = monster->GetAllCookies();
- size_t i = 0;
- while (const char* text = va_arg(ap, const char*)) {
- ASSERT_LT(i, cookie_list.size());
- EXPECT_EQ(text, cookie_list[i].second.Name());
- ++i;
- }
- va_end(ap);
- EXPECT_EQ(i, cookie_list.size());
+ for (size_t i = 0; i < cookie_list.size(); ++i)
+ parts.push_back(cookie_list[i].second.Name());
+ return JoinString(parts, ',');
}
- // Check if the cookie names shown in the cookie manager match the given ones.
- // Ex: CheckGtkTree(cookies_view, "X", "Y", NULL);
- void CheckGtkTree(const CookiesView& cookies_view, ...) {
- va_list ap;
- va_start(ap, cookies_view);
+ // Get the cookie names displayed in the dialog in the order they are
+ // displayed, as a comma seperated string.
+ // Ex: EXPECT_STREQ("X,Y", GetDisplayedCookies(cookies_view).c_str());
+ std::string GetDisplayedCookies(const CookiesView& cookies_view) {
+ std::vector<std::string> parts;
GtkTreeIter iter;
- int i = 0;
- while (const char* text = va_arg(ap, const char*)) {
- ASSERT_TRUE(gtk_tree_model_iter_nth_child(
- cookies_view.list_sort_, &iter, NULL, i));
+ if (!gtk_tree_model_get_iter_first(cookies_view.list_sort_, &iter))
+ return std::string();
+ while (true) {
gchar* name;
gtk_tree_model_get(cookies_view.list_sort_, &iter,
CookiesView::COL_COOKIE_NAME, &name, -1);
- EXPECT_STREQ(text, name);
+ parts.push_back(name);
g_free(name);
- ++i;
+ if (!gtk_tree_model_iter_next(cookies_view.list_sort_, &iter))
+ break;
}
- va_end(ap);
- EXPECT_EQ(i, gtk_tree_model_iter_n_children(
- GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ return JoinString(parts, ',');
}
protected:
@@ -116,7 +105,7 @@ class CookiesViewTest : public testing::Test {
scoped_ptr<CookieTestingProfile> profile_;
};
-TEST_F(CookiesViewTest, TestEmpty) {
+TEST_F(CookiesViewTest, Empty) {
CookiesView cookies_view(profile_.get());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
@@ -125,29 +114,35 @@ TEST_F(CookiesViewTest, TestEmpty) {
GTK_TREE_MODEL(cookies_view.list_store_), NULL));
}
-TEST_F(CookiesViewTest, TestRemoveAll) {
+TEST_F(CookiesViewTest, RemoveAll) {
net::CookieMonster* monster =
profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
monster->SetCookie(GURL("http://foo"), "A=1");
monster->SetCookie(GURL("http://foo2"), "B=1");
CookiesView cookies_view(profile_.get());
- EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
- EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
- EXPECT_EQ(2, gtk_tree_model_iter_n_children(
- GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ {
+ SCOPED_TRACE("Before removing");
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
+ EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
+ CheckDetailsSensitivity(FALSE, cookies_view);
+ EXPECT_EQ(2, gtk_tree_model_iter_n_children(
+ GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ }
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_));
- EXPECT_EQ(0u, monster->GetAllCookies().size());
- EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
- EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
- EXPECT_EQ(0, gtk_tree_model_iter_n_children(
- GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ {
+ SCOPED_TRACE("After removing");
+ EXPECT_EQ(0u, monster->GetAllCookies().size());
+ EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
+ EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
+ CheckDetailsSensitivity(FALSE, cookies_view);
+ EXPECT_EQ(0, gtk_tree_model_iter_n_children(
+ GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ }
}
-TEST_F(CookiesViewTest, TestRemove) {
+TEST_F(CookiesViewTest, Remove) {
net::CookieMonster* monster =
profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
monster->SetCookie(GURL("http://foo1"), "A=1");
@@ -158,47 +153,59 @@ TEST_F(CookiesViewTest, TestRemove) {
gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 1);
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_));
- CheckDetailsSensitivity(TRUE, cookies_view);
- EXPECT_EQ(3, gtk_tree_model_iter_n_children(
- GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ {
+ SCOPED_TRACE("First selection");
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
+ CheckDetailsSensitivity(TRUE, cookies_view);
+ EXPECT_EQ(3, gtk_tree_model_iter_n_children(
+ GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ }
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
- CheckCookieList(monster, "A", "C", NULL);
- CheckGtkTree(cookies_view, "A", "C", NULL);
- EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
- EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
+ {
+ SCOPED_TRACE("First selection removed");
+ EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("A,C", 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_));
+ CheckDetailsSensitivity(FALSE, cookies_view);
+ }
gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 1);
gtk_tree_selection_select_iter(cookies_view.selection_, &iter);
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
- CheckCookieList(monster, "A", NULL);
- CheckGtkTree(cookies_view, "A", NULL);
- EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
- EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
- EXPECT_EQ(1, gtk_tree_model_iter_n_children(
- GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ {
+ SCOPED_TRACE("Second selection");
+ EXPECT_STREQ("A", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("A", 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_));
+ CheckDetailsSensitivity(FALSE, cookies_view);
+ EXPECT_EQ(1, gtk_tree_model_iter_n_children(
+ GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ }
gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 0);
gtk_tree_selection_select_iter(cookies_view.selection_, &iter);
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
- EXPECT_EQ(0u, monster->GetAllCookies().size());
- EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
- EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
- EXPECT_EQ(0, gtk_tree_model_iter_n_children(
- GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ {
+ SCOPED_TRACE("Second selection removed");
+ EXPECT_EQ(0u, monster->GetAllCookies().size());
+ EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
+ EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
+ CheckDetailsSensitivity(FALSE, cookies_view);
+ EXPECT_EQ(0, gtk_tree_model_iter_n_children(
+ GTK_TREE_MODEL(cookies_view.list_store_), NULL));
+ }
}
-TEST_F(CookiesViewTest, TestFilter) {
+TEST_F(CookiesViewTest, Filter) {
net::CookieMonster* monster =
profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
monster->SetCookie(GURL("http://foo1"), "A=1");
@@ -218,12 +225,12 @@ TEST_F(CookiesViewTest, TestFilter) {
// Results are filtered immediately if you activate (hit enter in the entry.)
gtk_widget_activate(cookies_view.filter_entry_);
- CheckGtkTree(cookies_view, "B", "D", NULL);
+ EXPECT_STREQ("B,D", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar2");
gtk_widget_activate(cookies_view.filter_entry_);
- CheckGtkTree(cookies_view, "D", NULL);
+ EXPECT_STREQ("D", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar22");
@@ -233,7 +240,7 @@ TEST_F(CookiesViewTest, TestFilter) {
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
}
-TEST_F(CookiesViewTest, TestFilterRemoveAll) {
+TEST_F(CookiesViewTest, FilterRemoveAll) {
net::CookieMonster* monster =
profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
monster->SetCookie(GURL("http://foo1"), "A=1");
@@ -243,23 +250,23 @@ TEST_F(CookiesViewTest, TestFilterRemoveAll) {
CookiesView cookies_view(profile_.get());
gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar");
gtk_widget_activate(cookies_view.filter_entry_);
- CheckCookieList(monster, "B", "D", "A", "C", NULL);
- CheckGtkTree(cookies_view, "B", "D", NULL);
+ EXPECT_STREQ("B,D,A,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("B,D", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_));
- CheckCookieList(monster, "A", "C", NULL);
- CheckGtkTree(cookies_view, NULL);
+ EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "");
gtk_widget_activate(cookies_view.filter_entry_);
- CheckCookieList(monster, "A", "C", NULL);
- CheckGtkTree(cookies_view, "A", "C", NULL);
+ EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
}
-TEST_F(CookiesViewTest, TestFilterRemove) {
+TEST_F(CookiesViewTest, FilterRemove) {
net::CookieMonster* monster =
profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
monster->SetCookie(GURL("http://foo1"), "A=1");
@@ -269,8 +276,8 @@ TEST_F(CookiesViewTest, TestFilterRemove) {
CookiesView cookies_view(profile_.get());
gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar");
gtk_widget_activate(cookies_view.filter_entry_);
- CheckCookieList(monster, "B", "D", "A", "C", NULL);
- CheckGtkTree(cookies_view, "B", "D", NULL);
+ EXPECT_STREQ("B,D,A,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("B,D", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
GtkTreeIter iter;
@@ -280,8 +287,8 @@ TEST_F(CookiesViewTest, TestFilterRemove) {
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
- CheckCookieList(monster, "D", "A", "C", NULL);
- CheckGtkTree(cookies_view, "D", NULL);
+ EXPECT_STREQ("D,A,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("D", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 0);
@@ -290,12 +297,12 @@ TEST_F(CookiesViewTest, TestFilterRemove) {
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
- CheckCookieList(monster, "A", "C", NULL);
- CheckGtkTree(cookies_view, NULL);
+ EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
}
-TEST_F(CookiesViewTest, TestSort) {
+TEST_F(CookiesViewTest, Sort) {
net::CookieMonster* monster =
profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
monster->SetCookie(GURL("http://foo1"), "X=1");
@@ -303,35 +310,35 @@ TEST_F(CookiesViewTest, TestSort) {
monster->SetCookie(GURL("http://foo2"), "C=1");
monster->SetCookie(GURL("http://bar2"), "D=1");
CookiesView cookies_view(profile_.get());
- CheckCookieList(monster, "Z", "D", "X", "C", NULL);
- CheckGtkTree(cookies_view, "Z", "D", "X", "C", NULL);
+ EXPECT_STREQ("Z,D,X,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("Z,D,X,C", GetDisplayedCookies(cookies_view).c_str());
gtk_tree_sortable_set_sort_column_id(
GTK_TREE_SORTABLE(cookies_view.list_sort_),
CookiesView::COL_SITE,
GTK_SORT_ASCENDING);
- CheckGtkTree(cookies_view, "Z", "D", "X", "C", NULL);
+ EXPECT_STREQ("Z,D,X,C", GetDisplayedCookies(cookies_view).c_str());
gtk_tree_sortable_set_sort_column_id(
GTK_TREE_SORTABLE(cookies_view.list_sort_),
CookiesView::COL_SITE,
GTK_SORT_DESCENDING);
- CheckGtkTree(cookies_view, "C", "X", "D", "Z", NULL);
+ EXPECT_STREQ("C,X,D,Z", GetDisplayedCookies(cookies_view).c_str());
gtk_tree_sortable_set_sort_column_id(
GTK_TREE_SORTABLE(cookies_view.list_sort_),
CookiesView::COL_COOKIE_NAME,
GTK_SORT_ASCENDING);
- CheckGtkTree(cookies_view, "C", "D", "X", "Z", NULL);
+ EXPECT_STREQ("C,D,X,Z", GetDisplayedCookies(cookies_view).c_str());
gtk_tree_sortable_set_sort_column_id(
GTK_TREE_SORTABLE(cookies_view.list_sort_),
CookiesView::COL_COOKIE_NAME,
GTK_SORT_DESCENDING);
- CheckGtkTree(cookies_view, "Z", "X", "D", "C", NULL);
+ EXPECT_STREQ("Z,X,D,C", GetDisplayedCookies(cookies_view).c_str());
}
-TEST_F(CookiesViewTest, TestSortRemove) {
+TEST_F(CookiesViewTest, SortRemove) {
net::CookieMonster* monster =
profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
monster->SetCookie(GURL("http://foo1"), "B=1");
@@ -339,25 +346,25 @@ TEST_F(CookiesViewTest, TestSortRemove) {
monster->SetCookie(GURL("http://foo2"), "C=1");
monster->SetCookie(GURL("http://bar2"), "A=1");
CookiesView cookies_view(profile_.get());
- CheckCookieList(monster, "Z", "A", "B", "C", NULL);
- CheckGtkTree(cookies_view, "Z", "A", "B", "C", NULL);
+ EXPECT_STREQ("Z,A,B,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("Z,A,B,C", GetDisplayedCookies(cookies_view).c_str());
gtk_tree_sortable_set_sort_column_id(
GTK_TREE_SORTABLE(cookies_view.list_sort_),
CookiesView::COL_COOKIE_NAME,
GTK_SORT_DESCENDING);
- CheckGtkTree(cookies_view, "Z", "C", "B", "A", NULL);
+ EXPECT_STREQ("Z,C,B,A", GetDisplayedCookies(cookies_view).c_str());
GtkTreeIter iter;
gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 3);
gtk_tree_selection_select_iter(cookies_view.selection_, &iter);
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
- CheckCookieList(monster, "Z", "B", "C", NULL);
- CheckGtkTree(cookies_view, "Z", "C", "B", NULL);
+ EXPECT_STREQ("Z,B,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("Z,C,B", GetDisplayedCookies(cookies_view).c_str());
}
-TEST_F(CookiesViewTest, TestSortFilterRemove) {
+TEST_F(CookiesViewTest, SortFilterRemove) {
net::CookieMonster* monster =
profile_->GetRequestContext()->cookie_store()->GetCookieMonster();
monster->SetCookie(GURL("http://foo1"), "B=1");
@@ -365,8 +372,8 @@ TEST_F(CookiesViewTest, TestSortFilterRemove) {
monster->SetCookie(GURL("http://foo2"), "C=1");
monster->SetCookie(GURL("http://bar2"), "A=1");
CookiesView cookies_view(profile_.get());
- CheckCookieList(monster, "Z", "A", "B", "C", NULL);
- CheckGtkTree(cookies_view, "Z", "A", "B", "C", NULL);
+ EXPECT_STREQ("Z,A,B,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("Z,A,B,C", GetDisplayedCookies(cookies_view).c_str());
gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar");
gtk_widget_activate(cookies_view.filter_entry_);
@@ -374,20 +381,20 @@ TEST_F(CookiesViewTest, TestSortFilterRemove) {
GTK_TREE_SORTABLE(cookies_view.list_sort_),
CookiesView::COL_COOKIE_NAME,
GTK_SORT_ASCENDING);
- CheckGtkTree(cookies_view, "A", "Z", NULL);
+ EXPECT_STREQ("A,Z", GetDisplayedCookies(cookies_view).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);
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
- CheckCookieList(monster, "A", "B", "C", NULL);
- CheckGtkTree(cookies_view, "A", NULL);
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("A", GetDisplayedCookies(cookies_view).c_str());
gtk_tree_model_iter_nth_child(cookies_view.list_sort_, &iter, NULL, 0);
gtk_tree_selection_select_iter(cookies_view.selection_, &iter);
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
- CheckCookieList(monster, "B", "C", NULL);
- CheckGtkTree(cookies_view, NULL);
+ EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
}