Index: chrome/browser/gtk/options/cookies_view_unittest.cc |
=================================================================== |
--- chrome/browser/gtk/options/cookies_view_unittest.cc (revision 36995) |
+++ chrome/browser/gtk/options/cookies_view_unittest.cc (working copy) |
@@ -10,6 +10,7 @@ |
#include <gtk/gtk.h> |
#include "base/string_util.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" |
#include "net/url_request/url_request_context.h" |
@@ -26,24 +27,37 @@ |
virtual void SetUp() { |
profile_.reset(new TestingProfile()); |
profile_->CreateRequestContext(); |
+ mock_browsing_data_helper_ = new MockBrowsingDataLocalStorageHelper( |
+ profile_.get()); |
} |
- void CheckDetailsSensitivity(gboolean expected, |
+ void CheckDetailsSensitivity(gboolean expected_cookies, |
+ gboolean expected_local_storage, |
const CookiesView& cookies_view) { |
- EXPECT_EQ(expected, |
+ // Cookies |
+ EXPECT_EQ(expected_cookies, |
GTK_WIDGET_SENSITIVE(cookies_view.cookie_name_entry_)); |
- EXPECT_EQ(expected, |
+ EXPECT_EQ(expected_cookies, |
GTK_WIDGET_SENSITIVE(cookies_view.cookie_content_entry_)); |
- EXPECT_EQ(expected, |
+ EXPECT_EQ(expected_cookies, |
GTK_WIDGET_SENSITIVE(cookies_view.cookie_domain_entry_)); |
- EXPECT_EQ(expected, |
+ EXPECT_EQ(expected_cookies, |
GTK_WIDGET_SENSITIVE(cookies_view.cookie_path_entry_)); |
- EXPECT_EQ(expected, |
+ EXPECT_EQ(expected_cookies, |
GTK_WIDGET_SENSITIVE(cookies_view.cookie_send_for_entry_)); |
- EXPECT_EQ(expected, |
+ EXPECT_EQ(expected_cookies, |
GTK_WIDGET_SENSITIVE(cookies_view.cookie_created_entry_)); |
- EXPECT_EQ(expected, |
+ EXPECT_EQ(expected_cookies, |
GTK_WIDGET_SENSITIVE(cookies_view.cookie_expires_entry_)); |
+ // Local Storage |
+ EXPECT_EQ(expected_local_storage, |
+ GTK_WIDGET_SENSITIVE(cookies_view.local_storage_origin_entry_)); |
+ EXPECT_EQ(expected_local_storage, |
+ GTK_WIDGET_SENSITIVE(cookies_view.local_storage_size_entry_)); |
+ EXPECT_EQ(expected_local_storage, |
+ GTK_WIDGET_SENSITIVE( |
+ cookies_view.local_storage_last_modified_entry_)); |
+ |
} |
// Get the cookie names in the cookie list, as a comma seperated string. |
@@ -148,13 +162,14 @@ |
ChromeThread io_thread_; |
scoped_ptr<TestingProfile> profile_; |
+ scoped_refptr<MockBrowsingDataLocalStorageHelper> mock_browsing_data_helper_; |
}; |
TEST_F(CookiesViewTest, Empty) { |
- CookiesView cookies_view(profile_.get()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
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); |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); |
} |
@@ -167,21 +182,27 @@ |
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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
EXPECT_STREQ("foo0,_Cookies,__C,__D," |
"foo1,_Cookies,__A,__B,__E," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "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, cookies_view); |
+ CheckDetailsSensitivity(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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
// Reset the selection of the first row. |
gtk_tree_selection_unselect_all(cookies_view.selection_); |
@@ -190,8 +211,10 @@ |
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_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B", |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
+ EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
} |
@@ -201,8 +224,9 @@ |
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); |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); |
+ EXPECT_TRUE(mock_browsing_data_helper_->delete_all_files_called_); |
} |
} |
@@ -210,7 +234,9 @@ |
net::CookieMonster* monster = profile_->GetCookieMonster(); |
monster->SetCookie(GURL("http://foo"), "A=1"); |
monster->SetCookie(GURL("http://foo2"), "B=1"); |
- CookiesView cookies_view(profile_.get()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); |
EXPECT_EQ(1, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); |
@@ -218,8 +244,10 @@ |
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, cookies_view); |
- EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B", |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
+ EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
} |
@@ -229,10 +257,11 @@ |
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); |
+ CheckDetailsSensitivity(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_); |
} |
} |
@@ -241,7 +270,9 @@ |
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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
ASSERT_TRUE(ExpandByPath(cookies_view, "1")); |
ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); |
@@ -250,8 +281,10 @@ |
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_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C", |
+ CheckDetailsSensitivity(TRUE, FALSE, cookies_view); |
+ EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
} |
@@ -260,12 +293,14 @@ |
{ |
SCOPED_TRACE("First selection removed"); |
EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
- EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C", |
+ EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C," |
+ "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, cookies_view); |
+ CheckDetailsSensitivity(TRUE, FALSE, cookies_view); |
} |
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
@@ -274,16 +309,20 @@ |
{ |
SCOPED_TRACE("Second selection"); |
EXPECT_STREQ("A", GetMonsterCookies(monster).c_str()); |
- EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies", |
+ EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies," |
+ "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, cookies_view); |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
} |
ASSERT_TRUE(ExpandByPath(cookies_view, "0")); |
- EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies", |
+ EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); |
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
@@ -295,10 +334,36 @@ |
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, cookies_view); |
- EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies", |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
+ EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
} |
+ |
+ ASSERT_TRUE(ExpandByPath(cookies_view, "2")); |
+ EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," |
+ "host1,+Local Storage,++origin1," |
+ "host2,_Local Storage,__origin2", |
+ GetDisplayedCookies(cookies_view).c_str()); |
+ ASSERT_TRUE(SelectByPath(cookies_view, "2:0:0")); |
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
+ gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
+ |
+ { |
+ SCOPED_TRACE("Third 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("2:0", GetSelectedPath(cookies_view).c_str()); |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
+ EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," |
+ "host1,+Local Storage," |
+ "host2,_Local Storage,__origin2", |
+ GetDisplayedCookies(cookies_view).c_str()); |
+ EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == |
+ FilePath(FILE_PATH_LITERAL("file1"))); |
+ } |
} |
TEST_F(CookiesViewTest, RemoveCookiesByDomain) { |
@@ -310,16 +375,23 @@ |
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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
+ |
EXPECT_STREQ("foo0,_Cookies,__C,__D," |
"foo1,_Cookies,__A,__B,__E," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
ASSERT_TRUE(ExpandByPath(cookies_view, "1")); |
EXPECT_STREQ("foo0,_Cookies,__C,__D," |
"foo1,+Cookies,++A,++B,++E," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
ASSERT_TRUE(SelectByPath(cookies_view, "1:0")); |
@@ -331,7 +403,9 @@ |
EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); |
EXPECT_STREQ("foo0,_Cookies,__C,__D," |
"foo1," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "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_)); |
@@ -340,7 +414,9 @@ |
ASSERT_TRUE(ExpandByPath(cookies_view, "0")); |
EXPECT_STREQ("foo0,+Cookies,++C,++D," |
"foo1," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); |
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
@@ -348,7 +424,9 @@ |
EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); |
EXPECT_STREQ("foo0," |
"foo1," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "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_)); |
@@ -357,7 +435,9 @@ |
ASSERT_TRUE(ExpandByPath(cookies_view, "2")); |
EXPECT_STREQ("foo0," |
"foo1," |
- "foo2,+Cookies,++G,++X", |
+ "foo2,+Cookies,++G,++X," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
ASSERT_TRUE(SelectByPath(cookies_view, "2:0")); |
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
@@ -365,11 +445,36 @@ |
EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
EXPECT_STREQ("foo0," |
"foo1," |
- "foo2", |
+ "foo2," |
+ "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("2", GetSelectedPath(cookies_view).c_str()); |
+ |
+ ASSERT_TRUE(ExpandByPath(cookies_view, "3")); |
+ EXPECT_STREQ("foo0," |
+ "foo1," |
+ "foo2," |
+ "host1,+Local Storage,++origin1," |
+ "host2,_Local Storage,__origin2", |
+ GetDisplayedCookies(cookies_view).c_str()); |
+ ASSERT_TRUE(SelectByPath(cookies_view, "3:0")); |
+ gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
+ |
+ EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
+ EXPECT_STREQ("foo0," |
+ "foo1," |
+ "foo2," |
+ "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("3", GetSelectedPath(cookies_view).c_str()); |
+ EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == |
+ FilePath(FILE_PATH_LITERAL("file1"))); |
} |
TEST_F(CookiesViewTest, RemoveByDomain) { |
@@ -381,10 +486,15 @@ |
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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
+ |
EXPECT_STREQ("foo0,_Cookies,__C,__D," |
"foo1,_Cookies,__A,__B,__E," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
ASSERT_TRUE(SelectByPath(cookies_view, "1")); |
@@ -396,7 +506,9 @@ |
EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); |
EXPECT_STREQ("foo0,_Cookies,__C,__D," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "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_)); |
@@ -406,7 +518,9 @@ |
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); |
- EXPECT_STREQ("foo2,_Cookies,__G,__X", |
+ EXPECT_STREQ("foo2,_Cookies,__G,__X," |
+ "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_)); |
@@ -415,9 +529,33 @@ |
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
- EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); |
+ EXPECT_STREQ("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("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_helper_->last_deleted_file_ == |
+ FilePath(FILE_PATH_LITERAL("file1"))); |
+ 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("", |
+ 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_ == |
+ FilePath(FILE_PATH_LITERAL("file2"))); |
+ |
EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); |
} |
@@ -430,10 +568,15 @@ |
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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
+ |
EXPECT_STREQ("foo0,_Cookies,__C,__D," |
"foo1,_Cookies,__A,__B,__E," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
@@ -444,7 +587,9 @@ |
EXPECT_STREQ("B,A,E,G,X", GetMonsterCookies(monster).c_str()); |
EXPECT_STREQ("foo1,_Cookies,__A,__B,__E," |
- "foo2,_Cookies,__G,__X", |
+ "foo2,_Cookies,__G,__X," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
@@ -453,7 +598,9 @@ |
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); |
- EXPECT_STREQ("foo2,_Cookies,__G,__X", |
+ EXPECT_STREQ("foo2,_Cookies,__G,__X," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
@@ -462,6 +609,25 @@ |
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
+ EXPECT_STREQ("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("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("", GetDisplayedCookies(cookies_view).c_str()); |
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
@@ -474,11 +640,16 @@ |
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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
+ |
EXPECT_STREQ("bar0,_Cookies,__D," |
"bar1,_Cookies,__A," |
"foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
@@ -489,7 +660,9 @@ |
EXPECT_STREQ("bar0,_Cookies,__D," |
"bar1,_Cookies,__A," |
"foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "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). |
@@ -504,8 +677,16 @@ |
EXPECT_STREQ("bar0,_Cookies,__D," |
"bar1,_Cookies,__A," |
"foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "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," |
+ "host2,_Local Storage,__origin2", |
+ GetDisplayedCookies(cookies_view).c_str()); |
} |
TEST_F(CookiesViewTest, FilterRemoveAll) { |
@@ -514,11 +695,16 @@ |
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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
+ |
EXPECT_STREQ("bar0,_Cookies,__D," |
"bar1,_Cookies,__A," |
"foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
@@ -529,7 +715,9 @@ |
EXPECT_STREQ("bar0,_Cookies,__D," |
"bar1,_Cookies,__A," |
"foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "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). |
@@ -550,7 +738,9 @@ |
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); |
EXPECT_STREQ("foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
} |
@@ -561,11 +751,16 @@ |
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()); |
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
+ mock_browsing_data_helper_->AddLocalStorageSamples(); |
+ mock_browsing_data_helper_->Notify(); |
+ |
EXPECT_STREQ("bar0,_Cookies,__D," |
"bar1,_Cookies,__A,__E," |
"foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
EXPECT_STREQ("D,A,E,C,B", GetMonsterCookies(monster).c_str()); |
@@ -577,7 +772,9 @@ |
EXPECT_STREQ("bar0,_Cookies,__D," |
"bar1,_Cookies,__A,__E," |
"foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "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). |
@@ -596,7 +793,7 @@ |
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); |
+ CheckDetailsSensitivity(TRUE, FALSE, cookies_view); |
} |
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
@@ -610,7 +807,7 @@ |
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, cookies_view); |
+ CheckDetailsSensitivity(TRUE, FALSE, cookies_view); |
} |
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
@@ -624,7 +821,7 @@ |
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, cookies_view); |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
} |
ASSERT_TRUE(ExpandByPath(cookies_view, "0")); |
@@ -638,7 +835,7 @@ |
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, cookies_view); |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
EXPECT_STREQ("bar0,+Cookies," |
"bar1,+Cookies", |
GetDisplayedCookies(cookies_view).c_str()); |
@@ -648,6 +845,50 @@ |
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); |
EXPECT_STREQ("foo0,_Cookies,__C," |
- "foo1,_Cookies,__B", |
+ "foo1,_Cookies,__B," |
+ "host1,_Local Storage,__origin1," |
+ "host2,_Local Storage,__origin2", |
GetDisplayedCookies(cookies_view).c_str()); |
+ |
+ gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos"); |
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
+ // Entering text doesn't immediately filter the results. |
+ EXPECT_STREQ("foo0,_Cookies,__C," |
+ "foo1,_Cookies,__B," |
+ "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," |
+ "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", |
+ GetDisplayedCookies(cookies_view).c_str()); |
+ ASSERT_TRUE(SelectByPath(cookies_view, "1: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, 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("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("1:0", GetSelectedPath(cookies_view).c_str()); |
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
+ } |
} |