diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-10 18:13:40 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-10 18:13:40 +0000 |
commit | b5c6e3061b38fc9936063c4b95a6fdb36dcd494d (patch) | |
tree | c33e9e39fe93750f0947b046f686df44d5ca5182 /chrome/browser/gtk | |
parent | 042c368e489772c0ff89f25beb396a948659a268 (diff) | |
download | chromium_src-b5c6e3061b38fc9936063c4b95a6fdb36dcd494d.zip chromium_src-b5c6e3061b38fc9936063c4b95a6fdb36dcd494d.tar.gz chromium_src-b5c6e3061b38fc9936063c4b95a6fdb36dcd494d.tar.bz2 |
Add support for HTML5 databases to the cookie tree model.
BUG=34633
TEST=create local databases, open cookie tree view from prefs.
Review URL: http://codereview.chromium.org/596009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/options/advanced_contents_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/options/cookies_view.cc | 87 | ||||
-rw-r--r-- | chrome/browser/gtk/options/cookies_view.h | 23 | ||||
-rw-r--r-- | chrome/browser/gtk/options/cookies_view_unittest.cc | 423 |
4 files changed, 452 insertions, 85 deletions
diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index aaa8c7e..84cb54c 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -773,6 +773,8 @@ void PrivacySection::OnShowCookiesButtonClicked( GtkButton *button, PrivacySection* privacy_section) { privacy_section->UserMetricsRecordAction("Options_ShowCookies", NULL); CookiesView::Show(privacy_section->profile(), + new BrowsingDataDatabaseHelper( + privacy_section->profile()), new BrowsingDataLocalStorageHelper( privacy_section->profile())); } diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc index 25abfa3..86a1d7e 100644 --- a/chrome/browser/gtk/options/cookies_view.cc +++ b/chrome/browser/gtk/options/cookies_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -59,23 +59,29 @@ CookiesView::~CookiesView() { // static void CookiesView::Show( Profile* profile, + BrowsingDataDatabaseHelper* browsing_data_database_helper, BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper) { DCHECK(profile); + DCHECK(browsing_data_database_helper); DCHECK(browsing_data_local_storage_helper); // If there's already an existing editor window, activate it. if (instance_) { gtk_window_present(GTK_WINDOW(instance_->dialog_)); } else { - instance_ = new CookiesView(profile, browsing_data_local_storage_helper); + instance_ = new CookiesView(profile, + browsing_data_database_helper, + browsing_data_local_storage_helper); instance_->InitStylesAndShow(); } } CookiesView::CookiesView( Profile* profile, + BrowsingDataDatabaseHelper* browsing_data_database_helper, BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper) : profile_(profile), + browsing_data_database_helper_(browsing_data_database_helper), browsing_data_local_storage_helper_(browsing_data_local_storage_helper), filter_update_factory_(this) { Init(); @@ -166,8 +172,9 @@ void CookiesView::Init() { GTK_SHADOW_ETCHED_IN); gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0); - cookies_tree_model_.reset(new CookiesTreeModel( - profile_, browsing_data_local_storage_helper_)); + cookies_tree_model_.reset(new CookiesTreeModel(profile_, + browsing_data_database_helper_, + browsing_data_local_storage_helper_)); cookies_tree_adapter_.reset( new gtk_tree::TreeAdapter(this, cookies_tree_model_.get())); tree_ = gtk_tree_view_new_with_model( @@ -226,6 +233,27 @@ void CookiesView::Init() { InitDetailRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL, cookie_details_table_, &cookie_expires_entry_); + // Database details. + GtkWidget* database_details_frame = gtk_frame_new(NULL); + gtk_frame_set_shadow_type(GTK_FRAME(database_details_frame), + GTK_SHADOW_ETCHED_IN); + gtk_box_pack_start(GTK_BOX(cookie_list_vbox), database_details_frame, + FALSE, FALSE, 0); + database_details_table_ = gtk_table_new(3, 2, FALSE); + gtk_container_add(GTK_CONTAINER(database_details_frame), + database_details_table_); + gtk_table_set_col_spacing(GTK_TABLE(database_details_table_), 0, + gtk_util::kLabelSpacing); + + row = 0; + InitDetailRow(row++, IDS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL, + database_details_table_, &database_description_entry_); + InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL, + database_details_table_, &database_size_entry_); + InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL, + database_details_table_, + &database_last_modified_entry_); + // Local storage details. GtkWidget* local_storage_details_frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(local_storage_details_frame), @@ -270,6 +298,13 @@ void CookiesView::InitStylesAndShow() { InitBrowserDetailStyle(cookie_created_entry_, label_style, dialog_style); InitBrowserDetailStyle(cookie_expires_entry_, label_style, dialog_style); + // Database details. + InitBrowserDetailStyle(database_description_entry_, label_style, + dialog_style); + InitBrowserDetailStyle(database_size_entry_, label_style, dialog_style); + InitBrowserDetailStyle(database_last_modified_entry_, label_style, + dialog_style); + // Local storage details. InitBrowserDetailStyle(local_storage_origin_entry_, label_style, dialog_style); @@ -321,6 +356,10 @@ void CookiesView::EnableControls() { PopulateCookieDetails(detailed_info.cookie->first, detailed_info.cookie->second); } else if (detailed_info.node_type == + CookieTreeNode::DetailedInfo::TYPE_DATABASE) { + UpdateVisibleDetailedInfo(database_details_table_); + PopulateDatabaseDetails(*detailed_info.database_info); + } else if (detailed_info.node_type == CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE) { UpdateVisibleDetailedInfo(local_storage_details_table_); PopulateLocalStorageDetails(*detailed_info.local_storage_info); @@ -343,6 +382,12 @@ void CookiesView::SetCookieDetailsSensitivity(gboolean enabled) { gtk_widget_set_sensitive(cookie_expires_entry_, enabled); } +void CookiesView::SetDatabaseDetailsSensitivity(gboolean enabled) { + gtk_widget_set_sensitive(database_description_entry_, enabled); + gtk_widget_set_sensitive(database_size_entry_, enabled); + gtk_widget_set_sensitive(database_last_modified_entry_, enabled); +} + void CookiesView::SetLocalStorageDetailsSensitivity(gboolean enabled) { gtk_widget_set_sensitive(local_storage_origin_entry_, enabled); gtk_widget_set_sensitive(local_storage_size_entry_, enabled); @@ -376,6 +421,21 @@ void CookiesView::PopulateCookieDetails( SetCookieDetailsSensitivity(TRUE); } +void CookiesView::PopulateDatabaseDetails( + const BrowsingDataDatabaseHelper::DatabaseInfo& database_info) { + gtk_entry_set_text(GTK_ENTRY(database_description_entry_), + database_info.description.c_str()); + gtk_entry_set_text(GTK_ENTRY(database_size_entry_), + WideToUTF8(FormatBytes( + database_info.size, + GetByteDisplayUnits(database_info.size), + true)).c_str()); + gtk_entry_set_text(GTK_ENTRY(database_last_modified_entry_), + WideToUTF8(base::TimeFormatFriendlyDateAndTime( + database_info.last_modified)).c_str()); + SetDatabaseDetailsSensitivity(TRUE); +} + void CookiesView::PopulateLocalStorageDetails( const BrowsingDataLocalStorageHelper::LocalStorageInfo& local_storage_info) { @@ -452,8 +512,7 @@ void CookiesView::OnResponse(GtkDialog* dialog, int response_id, if (response_id == RESPONSE_REMOVE) { window->RemoveSelectedItems(); } else if (response_id == RESPONSE_REMOVE_ALL) { - window->cookies_tree_model_->DeleteAllCookies(); - window->browsing_data_local_storage_helper_->DeleteAllLocalStorageFiles(); + window->cookies_tree_model_->DeleteAllStoredObjects(); } else { gtk_widget_destroy(window->dialog_); } @@ -505,18 +564,18 @@ void CookiesView::UpdateFilterResults() { } void CookiesView::UpdateVisibleDetailedInfo(GtkWidget* table) { + SetCookieDetailsSensitivity(table == cookie_details_table_); + SetDatabaseDetailsSensitivity(table == database_details_table_); + SetLocalStorageDetailsSensitivity(table == local_storage_details_table_); // Toggle the parent (the table frame) visibility and sensitivity. gtk_widget_show(gtk_widget_get_parent(table)); // Toggle the other tables. - if (table == cookie_details_table_) { - SetCookieDetailsSensitivity(true); - SetLocalStorageDetailsSensitivity(false); - gtk_widget_hide(gtk_widget_get_parent(local_storage_details_table_)); - } else if (table == local_storage_details_table_) { - SetCookieDetailsSensitivity(false); - SetLocalStorageDetailsSensitivity(true); + if (table != cookie_details_table_) gtk_widget_hide(gtk_widget_get_parent(cookie_details_table_)); - } + if (table != database_details_table_) + gtk_widget_hide(gtk_widget_get_parent(database_details_table_)); + if (table != local_storage_details_table_) + gtk_widget_hide(gtk_widget_get_parent(local_storage_details_table_)); } // static diff --git a/chrome/browser/gtk/options/cookies_view.h b/chrome/browser/gtk/options/cookies_view.h index 7720e13..80cad06 100644 --- a/chrome/browser/gtk/options/cookies_view.h +++ b/chrome/browser/gtk/options/cookies_view.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,6 +12,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "base/task.h" +#include "chrome/browser/browsing_data_database_helper.h" #include "chrome/browser/browsing_data_local_storage_helper.h" #include "chrome/common/gtk_tree.h" #include "net/base/cookie_monster.h" @@ -34,6 +35,7 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate { // Create (if necessary) and show the cookie manager window. static void Show( Profile* profile, + BrowsingDataDatabaseHelper* browsing_data_database_helper, BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper); // gtk_tree::TreeAdapter::Delegate implementation. @@ -43,6 +45,7 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate { private: CookiesView( Profile* profile, + BrowsingDataDatabaseHelper* browsing_data_database_helper, BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper); // Initialize the dialog contents and layout. @@ -64,6 +67,9 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate { // Set sensitivity of cookie details. void SetCookieDetailsSensitivity(gboolean enabled); + // Set sensitivity of database details. + void SetDatabaseDetailsSensitivity(gboolean enabled); + // Set sensitivity of local storage details. void SetLocalStorageDetailsSensitivity(gboolean enabled); @@ -71,6 +77,10 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate { void PopulateCookieDetails(const std::string& domain, const net::CookieMonster::CanonicalCookie& cookie); + // Show the details of the currently selected database. + void PopulateDatabaseDetails( + const BrowsingDataDatabaseHelper::DatabaseInfo& database_info); + // Show the details of the currently selected local storage. void PopulateLocalStorageDetails( const BrowsingDataLocalStorageHelper::LocalStorageInfo& @@ -137,6 +147,12 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate { GtkWidget* cookie_created_entry_; GtkWidget* cookie_expires_entry_; + // The database details widgets. + GtkWidget* database_details_table_; + GtkWidget* database_description_entry_; + GtkWidget* database_size_entry_; + GtkWidget* database_last_modified_entry_; + // The local storage details widgets. GtkWidget* local_storage_details_table_; GtkWidget* local_storage_origin_entry_; @@ -146,6 +162,9 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate { // The profile. Profile* profile_; + // Database Helper. + scoped_refptr<BrowsingDataDatabaseHelper> browsing_data_database_helper_; + // Local Storage Helper. scoped_refptr<BrowsingDataLocalStorageHelper> browsing_data_local_storage_helper_; @@ -164,7 +183,7 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate { FRIEND_TEST(CookiesViewTest, RemoveAll); FRIEND_TEST(CookiesViewTest, RemoveAllWithDefaultSelected); FRIEND_TEST(CookiesViewTest, Remove); - FRIEND_TEST(CookiesViewTest, RemoveCookiesByDomain); + FRIEND_TEST(CookiesViewTest, RemoveCookiesByType); FRIEND_TEST(CookiesViewTest, RemoveByDomain); FRIEND_TEST(CookiesViewTest, RemoveDefaultSelection); FRIEND_TEST(CookiesViewTest, Filter); diff --git a/chrome/browser/gtk/options/cookies_view_unittest.cc b/chrome/browser/gtk/options/cookies_view_unittest.cc index 4092dbf..501bb0a 100644 --- a/chrome/browser/gtk/options/cookies_view_unittest.cc +++ b/chrome/browser/gtk/options/cookies_view_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include <gtk/gtk.h> #include "base/string_util.h" +#include "chrome/browser/mock_browsing_data_database_helper.h" #include "chrome/browser/mock_browsing_data_local_storage_helper.h" #include "chrome/browser/net/url_request_context_getter.h" #include "chrome/test/testing_profile.h" @@ -27,11 +28,14 @@ class CookiesViewTest : public testing::Test { virtual void SetUp() { profile_.reset(new TestingProfile()); profile_->CreateRequestContext(); - mock_browsing_data_helper_ = new MockBrowsingDataLocalStorageHelper( - profile_.get()); + mock_browsing_data_database_helper_ = + new MockBrowsingDataDatabaseHelper(profile_.get()); + mock_browsing_data_local_storage_helper_ = + new MockBrowsingDataLocalStorageHelper(profile_.get()); } void CheckDetailsSensitivity(gboolean expected_cookies, + gboolean expected_database, gboolean expected_local_storage, const CookiesView& cookies_view) { // Cookies @@ -49,6 +53,14 @@ class CookiesViewTest : public testing::Test { GTK_WIDGET_SENSITIVE(cookies_view.cookie_created_entry_)); EXPECT_EQ(expected_cookies, GTK_WIDGET_SENSITIVE(cookies_view.cookie_expires_entry_)); + // Database + EXPECT_EQ(expected_database, + GTK_WIDGET_SENSITIVE(cookies_view.database_description_entry_)); + EXPECT_EQ(expected_database, + GTK_WIDGET_SENSITIVE(cookies_view.database_size_entry_)); + EXPECT_EQ(expected_database, + GTK_WIDGET_SENSITIVE( + cookies_view.database_last_modified_entry_)); // Local Storage EXPECT_EQ(expected_local_storage, GTK_WIDGET_SENSITIVE(cookies_view.local_storage_origin_entry_)); @@ -162,14 +174,19 @@ class CookiesViewTest : public testing::Test { ChromeThread io_thread_; scoped_ptr<TestingProfile> profile_; - scoped_refptr<MockBrowsingDataLocalStorageHelper> mock_browsing_data_helper_; + scoped_refptr<MockBrowsingDataDatabaseHelper> + mock_browsing_data_database_helper_; + scoped_refptr<MockBrowsingDataLocalStorageHelper> + mock_browsing_data_local_storage_helper_; }; TEST_F(CookiesViewTest, Empty) { - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); } @@ -182,27 +199,37 @@ TEST_F(CookiesViewTest, Noop) { monster->SetCookie(GURL("http://foo1"), "E=1"); monster->SetCookie(GURL("http://foo2"), "G=1"); monster->SetCookie(GURL("http://foo2"), "X=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); EXPECT_STREQ("foo0,_Cookies,__C,__D," "foo1,_Cookies,__A,__B,__E," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); } TEST_F(CookiesViewTest, RemoveAll) { net::CookieMonster* monster = profile_->GetCookieMonster(); monster->SetCookie(GURL("http://foo"), "A=1"); monster->SetCookie(GURL("http://foo2"), "B=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); // Reset the selection of the first row. gtk_tree_selection_unselect_all(cookies_view.selection_); @@ -211,22 +238,28 @@ TEST_F(CookiesViewTest, RemoveAll) { 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, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); } + mock_browsing_data_database_helper_->Reset(); + mock_browsing_data_local_storage_helper_->Reset(); + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); { 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, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); - EXPECT_TRUE(mock_browsing_data_helper_->delete_all_files_called_); + EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); + EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); } } @@ -234,9 +267,13 @@ TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) { net::CookieMonster* monster = profile_->GetCookieMonster(); monster->SetCookie(GURL("http://foo"), "A=1"); monster->SetCookie(GURL("http://foo2"), "B=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); EXPECT_EQ(1, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); @@ -244,24 +281,30 @@ TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) { SCOPED_TRACE("Before removing"); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); } + mock_browsing_data_database_helper_->Reset(); + mock_browsing_data_local_storage_helper_->Reset(); + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); { 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, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); - EXPECT_TRUE(mock_browsing_data_helper_->delete_all_files_called_); + EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); + EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); } } @@ -270,9 +313,13 @@ TEST_F(CookiesViewTest, Remove) { monster->SetCookie(GURL("http://foo1"), "A=1"); monster->SetCookie(GURL("http://foo2"), "B=1"); monster->SetCookie(GURL("http://foo2"), "C=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); ASSERT_TRUE(ExpandByPath(cookies_view, "1")); ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); @@ -281,8 +328,10 @@ TEST_F(CookiesViewTest, Remove) { 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, FALSE, cookies_view); + CheckDetailsSensitivity(TRUE, FALSE, FALSE, cookies_view); EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -294,13 +343,15 @@ TEST_F(CookiesViewTest, Remove) { SCOPED_TRACE("First selection removed"); EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); - CheckDetailsSensitivity(TRUE, FALSE, cookies_view); + CheckDetailsSensitivity(TRUE, FALSE, FALSE, cookies_view); } EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -310,17 +361,21 @@ TEST_F(CookiesViewTest, Remove) { SCOPED_TRACE("Second selection"); EXPECT_STREQ("A", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); } ASSERT_TRUE(ExpandByPath(cookies_view, "0")); EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -334,8 +389,10 @@ TEST_F(CookiesViewTest, Remove) { EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str()); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -343,7 +400,9 @@ TEST_F(CookiesViewTest, Remove) { ASSERT_TRUE(ExpandByPath(cookies_view, "2")); EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," - "host1,+Local Storage,++origin1," + "gdbhost1,+Web Databases,++db1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "2:0:0")); @@ -356,17 +415,49 @@ TEST_F(CookiesViewTest, Remove) { EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("2:0", GetSelectedPath(cookies_view).c_str()); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," + "gdbhost1,+Web Databases," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," + "host2,_Local Storage,__origin2", + GetDisplayedCookies(cookies_view).c_str()); + EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == + "http_gdbhost1_1"); + EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == + "db1"); + } + + ASSERT_TRUE(ExpandByPath(cookies_view, "4")); + EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," + "gdbhost1,+Web Databases," + "gdbhost2,_Web Databases,__db2," + "host1,+Local Storage,++origin1," + "host2,_Local Storage,__origin2", + GetDisplayedCookies(cookies_view).c_str()); + ASSERT_TRUE(SelectByPath(cookies_view, "4:0:0")); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); + + { + SCOPED_TRACE("Fourth selection removed"); + EXPECT_EQ(0u, monster->GetAllCookies().size()); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_STREQ("4:0", GetSelectedPath(cookies_view).c_str()); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); + EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," + "gdbhost1,+Web Databases," + "gdbhost2,_Web Databases,__db2," "host1,+Local Storage," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); - EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == + EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == FilePath(FILE_PATH_LITERAL("file1"))); } } -TEST_F(CookiesViewTest, RemoveCookiesByDomain) { +TEST_F(CookiesViewTest, RemoveCookiesByType) { net::CookieMonster* monster = profile_->GetCookieMonster(); monster->SetCookie(GURL("http://foo0"), "C=1"); monster->SetCookie(GURL("http://foo0"), "D=1"); @@ -375,13 +466,19 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { monster->SetCookie(GURL("http://foo1"), "E=1"); monster->SetCookie(GURL("http://foo2"), "G=1"); monster->SetCookie(GURL("http://foo2"), "X=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); EXPECT_STREQ("foo0,_Cookies,__C,__D," "foo1,_Cookies,__A,__B,__E," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -390,6 +487,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { EXPECT_STREQ("foo0,_Cookies,__C,__D," "foo1,+Cookies,++A,++B,++E," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -404,6 +503,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { EXPECT_STREQ("foo0,_Cookies,__C,__D," "foo1," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -415,6 +516,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { EXPECT_STREQ("foo0,+Cookies,++C,++D," "foo1," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -425,6 +528,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { EXPECT_STREQ("foo0," "foo1," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -436,6 +541,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { EXPECT_STREQ("foo0," "foo1," "foo2,+Cookies,++G,++X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -446,6 +553,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { EXPECT_STREQ("foo0," "foo1," "foo2," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -457,7 +566,9 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { EXPECT_STREQ("foo0," "foo1," "foo2," - "host1,+Local Storage,++origin1," + "gdbhost1,+Web Databases,++db1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "3:0")); @@ -467,13 +578,44 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) { EXPECT_STREQ("foo0," "foo1," "foo2," - "host1," + "gdbhost1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("3", GetSelectedPath(cookies_view).c_str()); - EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == + EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == + "http_gdbhost1_1"); + EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == + "db1"); + + ASSERT_TRUE(ExpandByPath(cookies_view, "5")); + EXPECT_STREQ("foo0," + "foo1," + "foo2," + "gdbhost1," + "gdbhost2,_Web Databases,__db2," + "host1,+Local Storage,++origin1," + "host2,_Local Storage,__origin2", + GetDisplayedCookies(cookies_view).c_str()); + ASSERT_TRUE(SelectByPath(cookies_view, "5:0")); + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); + + EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); + EXPECT_STREQ("foo0," + "foo1," + "foo2," + "gdbhost1," + "gdbhost2,_Web Databases,__db2," + "host1," + "host2,_Local Storage,__origin2", + GetDisplayedCookies(cookies_view).c_str()); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_STREQ("5", GetSelectedPath(cookies_view).c_str()); + EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == FilePath(FILE_PATH_LITERAL("file1"))); } @@ -486,13 +628,19 @@ TEST_F(CookiesViewTest, RemoveByDomain) { monster->SetCookie(GURL("http://foo1"), "E=1"); monster->SetCookie(GURL("http://foo2"), "G=1"); monster->SetCookie(GURL("http://foo2"), "X=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); EXPECT_STREQ("foo0,_Cookies,__C,__D," "foo1,_Cookies,__A,__B,__E," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -507,6 +655,8 @@ TEST_F(CookiesViewTest, RemoveByDomain) { EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("foo0,_Cookies,__C,__D," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -519,11 +669,40 @@ TEST_F(CookiesViewTest, RemoveByDomain) { EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," + "host2,_Local Storage,__origin2", + GetDisplayedCookies(cookies_view).c_str()); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); + + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); + + EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); + EXPECT_STREQ("gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," + "host2,_Local Storage,__origin2", + GetDisplayedCookies(cookies_view).c_str()); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); + + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); + + EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); + EXPECT_STREQ("gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == + "http_gdbhost1_1"); + EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == + "db1"); EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); @@ -534,6 +713,10 @@ TEST_F(CookiesViewTest, RemoveByDomain) { GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == + "http_gdbhost2_2"); + EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == + "db2"); EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); @@ -543,7 +726,7 @@ TEST_F(CookiesViewTest, RemoveByDomain) { GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); - EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == + EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == FilePath(FILE_PATH_LITERAL("file1"))); EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); @@ -553,7 +736,7 @@ TEST_F(CookiesViewTest, RemoveByDomain) { GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); - EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == + EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == FilePath(FILE_PATH_LITERAL("file2"))); EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); @@ -568,13 +751,19 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { monster->SetCookie(GURL("http://foo1"), "E=1"); monster->SetCookie(GURL("http://foo2"), "G=1"); monster->SetCookie(GURL("http://foo2"), "X=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); EXPECT_STREQ("foo0,_Cookies,__C,__D," "foo1,_Cookies,__A,__B,__E," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -588,6 +777,8 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { EXPECT_STREQ("B,A,E,G,X", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("foo1,_Cookies,__A,__B,__E," "foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -599,6 +790,31 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("foo2,_Cookies,__G,__X," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," + "host2,_Local Storage,__origin2", + GetDisplayedCookies(cookies_view).c_str()); + + 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("", GetMonsterCookies(monster).c_str()); + EXPECT_STREQ("gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," + "host2,_Local Storage,__origin2", + GetDisplayedCookies(cookies_view).c_str()); + + 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("", GetMonsterCookies(monster).c_str()); + EXPECT_STREQ("gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -640,14 +856,20 @@ TEST_F(CookiesViewTest, Filter) { monster->SetCookie(GURL("http://bar0"), "D=1"); monster->SetCookie(GURL("http://foo1"), "B=1"); monster->SetCookie(GURL("http://bar1"), "A=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); EXPECT_STREQ("bar0,_Cookies,__D," "bar1,_Cookies,__A," "foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -661,6 +883,8 @@ TEST_F(CookiesViewTest, Filter) { "bar1,_Cookies,__A," "foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -678,13 +902,17 @@ TEST_F(CookiesViewTest, Filter) { "bar1,_Cookies,__A," "foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos"); gtk_widget_activate(cookies_view.filter_entry_); - EXPECT_STREQ("host1,_Local Storage,__origin1," + EXPECT_STREQ("gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); } @@ -695,14 +923,20 @@ TEST_F(CookiesViewTest, FilterRemoveAll) { monster->SetCookie(GURL("http://bar0"), "D=1"); monster->SetCookie(GURL("http://foo1"), "B=1"); monster->SetCookie(GURL("http://bar1"), "A=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); EXPECT_STREQ("bar0,_Cookies,__D," "bar1,_Cookies,__A," "foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -716,6 +950,8 @@ TEST_F(CookiesViewTest, FilterRemoveAll) { "bar1,_Cookies,__A," "foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -739,6 +975,8 @@ TEST_F(CookiesViewTest, FilterRemoveAll) { EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); EXPECT_STREQ("foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -751,14 +989,20 @@ TEST_F(CookiesViewTest, FilterRemove) { monster->SetCookie(GURL("http://foo1"), "B=1"); monster->SetCookie(GURL("http://bar1"), "A=1"); monster->SetCookie(GURL("http://bar1"), "E=1"); - CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); - mock_browsing_data_helper_->AddLocalStorageSamples(); - mock_browsing_data_helper_->Notify(); + CookiesView cookies_view(profile_.get(), + mock_browsing_data_database_helper_, + mock_browsing_data_local_storage_helper_); + mock_browsing_data_database_helper_->AddDatabaseSamples(); + mock_browsing_data_database_helper_->Notify(); + mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); + mock_browsing_data_local_storage_helper_->Notify(); EXPECT_STREQ("bar0,_Cookies,__D," "bar1,_Cookies,__A,__E," "foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -773,6 +1017,8 @@ TEST_F(CookiesViewTest, FilterRemove) { "bar1,_Cookies,__A,__E," "foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -793,7 +1039,7 @@ TEST_F(CookiesViewTest, FilterRemove) { 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, FALSE, cookies_view); + CheckDetailsSensitivity(TRUE, FALSE, FALSE, cookies_view); } gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); @@ -807,7 +1053,7 @@ TEST_F(CookiesViewTest, FilterRemove) { EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); - CheckDetailsSensitivity(TRUE, FALSE, cookies_view); + CheckDetailsSensitivity(TRUE, FALSE, FALSE, cookies_view); } gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); @@ -821,7 +1067,7 @@ TEST_F(CookiesViewTest, FilterRemove) { EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); } ASSERT_TRUE(ExpandByPath(cookies_view, "0")); @@ -835,7 +1081,7 @@ TEST_F(CookiesViewTest, FilterRemove) { EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str()); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("bar0,+Cookies," "bar1,+Cookies", GetDisplayedCookies(cookies_view).c_str()); @@ -846,6 +1092,8 @@ TEST_F(CookiesViewTest, FilterRemove) { EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); EXPECT_STREQ("foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); @@ -855,19 +1103,25 @@ TEST_F(CookiesViewTest, FilterRemove) { // Entering text doesn't immediately filter the results. EXPECT_STREQ("foo0,_Cookies,__C," "foo1,_Cookies,__B," + "gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); // Results are filtered immediately if you activate (hit enter in the entry). gtk_widget_activate(cookies_view.filter_entry_); - EXPECT_STREQ("host1,_Local Storage,__origin1," + EXPECT_STREQ("gdbhost1,_Web Databases,__db1," + "gdbhost2,_Web Databases,__db2," + "host1,_Local Storage,__origin1," "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(ExpandByPath(cookies_view, "1")); - EXPECT_STREQ("host1,_Local Storage,__origin1," - "host2,+Local Storage,++origin2", + EXPECT_STREQ("gdbhost1,_Web Databases,__db1," + "gdbhost2,+Web Databases,++db2," + "host1,_Local Storage,__origin1," + "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); @@ -875,7 +1129,7 @@ TEST_F(CookiesViewTest, FilterRemove) { 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(FALSE, TRUE, cookies_view); + CheckDetailsSensitivity(FALSE, TRUE, FALSE, cookies_view); } gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); @@ -883,12 +1137,45 @@ TEST_F(CookiesViewTest, FilterRemove) { { SCOPED_TRACE("First selection removed"); EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); - EXPECT_STREQ("host1,_Local Storage,__origin1," - "host2,+Local Storage", + EXPECT_STREQ("gdbhost1,_Web Databases,__db1," + "gdbhost2,+Web Databases," + "host1,_Local Storage,__origin1," + "host2,_Local Storage,__origin2", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); - CheckDetailsSensitivity(FALSE, FALSE, cookies_view); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); + } + + ASSERT_TRUE(ExpandByPath(cookies_view, "3")); + EXPECT_STREQ("gdbhost1,_Web Databases,__db1," + "gdbhost2,+Web Databases," + "host1,_Local Storage,__origin1," + "host2,+Local Storage,++origin2", + GetDisplayedCookies(cookies_view).c_str()); + ASSERT_TRUE(SelectByPath(cookies_view, "3:0:0")); + + { + 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(FALSE, FALSE, TRUE, cookies_view); + } + + gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); + + { + SCOPED_TRACE("First selection removed"); + EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); + EXPECT_STREQ("gdbhost1,_Web Databases,__db1," + "gdbhost2,+Web Databases," + "host1,_Local Storage,__origin1," + "host2,+Local Storage", + GetDisplayedCookies(cookies_view).c_str()); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); + EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); + EXPECT_STREQ("3:0", GetSelectedPath(cookies_view).c_str()); + CheckDetailsSensitivity(FALSE, FALSE, FALSE, cookies_view); } } |