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/options/cookies_view_unittest.cc | |
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/options/cookies_view_unittest.cc')
-rw-r--r-- | chrome/browser/gtk/options/cookies_view_unittest.cc | 423 |
1 files changed, 355 insertions, 68 deletions
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); } } |