| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/gtk/options/cookies_view.h" | |
| 6 | |
| 7 #include <string> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include <gtk/gtk.h> | |
| 11 | |
| 12 #include "base/string_util.h" | |
| 13 #include "chrome/browser/mock_browsing_data_appcache_helper.h" | |
| 14 #include "chrome/browser/mock_browsing_data_database_helper.h" | |
| 15 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" | |
| 16 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | |
| 17 #include "chrome/browser/gtk/gtk_chrome_cookie_view.h" | |
| 18 #include "chrome/common/net/url_request_context_getter.h" | |
| 19 #include "chrome/test/testing_profile.h" | |
| 20 #include "net/url_request/url_request_context.h" | |
| 21 #include "testing/gtest/include/gtest/gtest.h" | |
| 22 | |
| 23 class CookiesViewTest : public testing::Test { | |
| 24 public: | |
| 25 CookiesViewTest() : io_thread_(BrowserThread::IO, &message_loop_) { | |
| 26 } | |
| 27 | |
| 28 virtual ~CookiesViewTest() { | |
| 29 } | |
| 30 | |
| 31 virtual void SetUp() { | |
| 32 profile_.reset(new TestingProfile()); | |
| 33 profile_->CreateRequestContext(); | |
| 34 mock_browsing_data_database_helper_ = | |
| 35 new MockBrowsingDataDatabaseHelper(profile_.get()); | |
| 36 mock_browsing_data_local_storage_helper_ = | |
| 37 new MockBrowsingDataLocalStorageHelper(profile_.get()); | |
| 38 mock_browsing_data_appcache_helper_ = | |
| 39 new MockBrowsingDataAppCacheHelper(profile_.get()); | |
| 40 mock_browsing_data_indexed_db_helper_ = | |
| 41 new MockBrowsingDataIndexedDBHelper(profile_.get()); | |
| 42 } | |
| 43 | |
| 44 void CheckDetailsSensitivity(gboolean expected_cookies, | |
| 45 gboolean expected_database, | |
| 46 gboolean expected_local_storage, | |
| 47 gboolean expected_appcache, | |
| 48 gboolean expected_indexed_db, | |
| 49 const CookiesView& cookies_view) { | |
| 50 GtkChromeCookieView* display = GTK_CHROME_COOKIE_VIEW( | |
| 51 cookies_view.cookie_display_); | |
| 52 | |
| 53 // Cookies | |
| 54 EXPECT_EQ(expected_cookies, | |
| 55 GTK_WIDGET_SENSITIVE(display->cookie_name_entry_)); | |
| 56 EXPECT_EQ(expected_cookies, | |
| 57 GTK_WIDGET_SENSITIVE(display->cookie_content_entry_)); | |
| 58 EXPECT_EQ(expected_cookies, | |
| 59 GTK_WIDGET_SENSITIVE(display->cookie_domain_entry_)); | |
| 60 EXPECT_EQ(expected_cookies, | |
| 61 GTK_WIDGET_SENSITIVE(display->cookie_path_entry_)); | |
| 62 EXPECT_EQ(expected_cookies, | |
| 63 GTK_WIDGET_SENSITIVE(display->cookie_send_for_entry_)); | |
| 64 EXPECT_EQ(expected_cookies, | |
| 65 GTK_WIDGET_SENSITIVE(display->cookie_created_entry_)); | |
| 66 EXPECT_EQ(expected_cookies, | |
| 67 GTK_WIDGET_SENSITIVE(display->cookie_expires_entry_)); | |
| 68 // Database | |
| 69 EXPECT_EQ(expected_database, | |
| 70 GTK_WIDGET_SENSITIVE(display->database_description_entry_)); | |
| 71 EXPECT_EQ(expected_database, | |
| 72 GTK_WIDGET_SENSITIVE(display->database_size_entry_)); | |
| 73 EXPECT_EQ(expected_database, | |
| 74 GTK_WIDGET_SENSITIVE(display->database_last_modified_entry_)); | |
| 75 // Local Storage | |
| 76 EXPECT_EQ(expected_local_storage, | |
| 77 GTK_WIDGET_SENSITIVE(display->local_storage_origin_entry_)); | |
| 78 EXPECT_EQ(expected_local_storage, | |
| 79 GTK_WIDGET_SENSITIVE(display->local_storage_size_entry_)); | |
| 80 EXPECT_EQ(expected_local_storage, GTK_WIDGET_SENSITIVE( | |
| 81 display->local_storage_last_modified_entry_)); | |
| 82 // AppCache | |
| 83 EXPECT_EQ(expected_appcache, | |
| 84 GTK_WIDGET_SENSITIVE(display->appcache_manifest_entry_)); | |
| 85 EXPECT_EQ(expected_appcache, | |
| 86 GTK_WIDGET_SENSITIVE(display->appcache_size_entry_)); | |
| 87 EXPECT_EQ(expected_appcache, | |
| 88 GTK_WIDGET_SENSITIVE(display->appcache_created_entry_)); | |
| 89 EXPECT_EQ(expected_appcache, | |
| 90 GTK_WIDGET_SENSITIVE(display->appcache_last_accessed_entry_)); | |
| 91 // IndexedDB | |
| 92 EXPECT_EQ(expected_indexed_db, | |
| 93 GTK_WIDGET_SENSITIVE(display->indexed_db_origin_entry_)); | |
| 94 EXPECT_EQ(expected_indexed_db, | |
| 95 GTK_WIDGET_SENSITIVE(display->indexed_db_size_entry_)); | |
| 96 EXPECT_EQ(expected_indexed_db, | |
| 97 GTK_WIDGET_SENSITIVE(display->indexed_db_last_modified_entry_)); | |
| 98 } | |
| 99 | |
| 100 // Get the cookie names in the cookie list, as a comma seperated string. | |
| 101 // (Note that the CookieMonster cookie list is sorted by domain.) | |
| 102 // Ex: | |
| 103 // monster->SetCookie(GURL("http://b"), "X=1") | |
| 104 // monster->SetCookie(GURL("http://a"), "Y=1") | |
| 105 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); | |
| 106 std::string GetMonsterCookies(net::CookieMonster* monster) { | |
| 107 std::vector<std::string> parts; | |
| 108 net::CookieList cookie_list = monster->GetAllCookies(); | |
| 109 for (size_t i = 0; i < cookie_list.size(); ++i) | |
| 110 parts.push_back(cookie_list[i].Name()); | |
| 111 return JoinString(parts, ','); | |
| 112 } | |
| 113 | |
| 114 typedef std::pair<std::vector<std::string>*, GtkTreeView*> | |
| 115 DisplayedCookiesData; | |
| 116 | |
| 117 static gboolean GetDisplayedCookiesHelper(GtkTreeModel *model, | |
| 118 GtkTreePath *path, | |
| 119 GtkTreeIter *iter, | |
| 120 gpointer user_data) { | |
| 121 DisplayedCookiesData* data = | |
| 122 reinterpret_cast<DisplayedCookiesData*>(user_data); | |
| 123 gchar* title; | |
| 124 gtk_tree_model_get(model, iter, | |
| 125 gtk_tree::TreeAdapter::COL_TITLE, &title, | |
| 126 -1); | |
| 127 std::string str; | |
| 128 if (gtk_tree_path_get_depth(path) > 1) { | |
| 129 // There isn't a function to check if a row is visible, instead we have to | |
| 130 // check whether the parent is expanded. | |
| 131 GtkTreePath* parent_path = gtk_tree_path_copy(path); | |
| 132 gtk_tree_path_up(parent_path); | |
| 133 str.append( | |
| 134 gtk_tree_path_get_depth(parent_path), | |
| 135 gtk_tree_view_row_expanded(data->second, parent_path) ? '+' : '_'); | |
| 136 gtk_tree_path_free(parent_path); | |
| 137 } | |
| 138 str += title; | |
| 139 g_free(title); | |
| 140 data->first->push_back(str); | |
| 141 return FALSE; | |
| 142 } | |
| 143 | |
| 144 // Get the cookie names displayed in the dialog in the order they are | |
| 145 // displayed, as a comma seperated string. | |
| 146 // Items are prefixed with _ or + up to their indent level. | |
| 147 // _ when hidden (parent is closed) and + when visible (parent is expanded). | |
| 148 // Ex: EXPECT_STREQ("a,+Cookies,++Y,b,_Cookies,__X", | |
| 149 // GetDisplayedCookies(cookies_view).c_str()); | |
| 150 std::string GetDisplayedCookies(const CookiesView& cookies_view) { | |
| 151 GtkTreeStore* tree_store = cookies_view.cookies_tree_adapter_->tree_store(); | |
| 152 std::vector<std::string> parts; | |
| 153 DisplayedCookiesData helper_data(&parts, GTK_TREE_VIEW(cookies_view.tree_)); | |
| 154 gtk_tree_model_foreach(GTK_TREE_MODEL(tree_store), | |
| 155 GetDisplayedCookiesHelper, &helper_data); | |
| 156 return JoinString(parts, ','); | |
| 157 } | |
| 158 | |
| 159 bool ExpandByPath(const CookiesView& cookies_view, const char* path_str) { | |
| 160 GtkTreePath* path = gtk_tree_path_new_from_string(path_str); | |
| 161 if (!path) | |
| 162 return false; | |
| 163 bool rv = gtk_tree_view_expand_row(GTK_TREE_VIEW(cookies_view.tree_), path, | |
| 164 FALSE); | |
| 165 gtk_tree_path_free(path); | |
| 166 return rv; | |
| 167 } | |
| 168 | |
| 169 bool SelectByPath(const CookiesView& cookies_view, const char* path_str) { | |
| 170 GtkTreePath* path = gtk_tree_path_new_from_string(path_str); | |
| 171 if (!path) | |
| 172 return false; | |
| 173 gtk_tree_selection_select_path(cookies_view.selection_, path); | |
| 174 bool rv = gtk_tree_selection_path_is_selected(cookies_view.selection_, | |
| 175 path); | |
| 176 gtk_tree_path_free(path); | |
| 177 return rv; | |
| 178 } | |
| 179 | |
| 180 std::string GetSelectedPath(const CookiesView& cookies_view) { | |
| 181 std::string result; | |
| 182 GtkTreeIter iter; | |
| 183 bool selected = gtk_tree_selection_get_selected(cookies_view.selection_, | |
| 184 NULL, &iter); | |
| 185 if (selected) { | |
| 186 gchar* path_str = gtk_tree_model_get_string_from_iter( | |
| 187 GTK_TREE_MODEL(cookies_view.cookies_tree_adapter_->tree_store()), | |
| 188 &iter); | |
| 189 if (path_str) { | |
| 190 result = path_str; | |
| 191 g_free(path_str); | |
| 192 } | |
| 193 } | |
| 194 return result; | |
| 195 } | |
| 196 | |
| 197 protected: | |
| 198 MessageLoop message_loop_; | |
| 199 BrowserThread io_thread_; | |
| 200 | |
| 201 scoped_ptr<TestingProfile> profile_; | |
| 202 scoped_refptr<MockBrowsingDataDatabaseHelper> | |
| 203 mock_browsing_data_database_helper_; | |
| 204 scoped_refptr<MockBrowsingDataLocalStorageHelper> | |
| 205 mock_browsing_data_local_storage_helper_; | |
| 206 scoped_refptr<MockBrowsingDataAppCacheHelper> | |
| 207 mock_browsing_data_appcache_helper_; | |
| 208 scoped_refptr<MockBrowsingDataIndexedDBHelper> | |
| 209 mock_browsing_data_indexed_db_helper_; | |
| 210 }; | |
| 211 | |
| 212 TEST_F(CookiesViewTest, Empty) { | |
| 213 CookiesView cookies_view(NULL, | |
| 214 profile_.get(), | |
| 215 mock_browsing_data_database_helper_, | |
| 216 mock_browsing_data_local_storage_helper_, | |
| 217 mock_browsing_data_appcache_helper_, | |
| 218 mock_browsing_data_indexed_db_helper_); | |
| 219 cookies_view.TestDestroySynchronously(); | |
| 220 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 221 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 222 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 223 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | |
| 224 } | |
| 225 | |
| 226 TEST_F(CookiesViewTest, Noop) { | |
| 227 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 228 monster->SetCookie(GURL("http://foo0"), "C=1"); | |
| 229 monster->SetCookie(GURL("http://foo0"), "D=1"); | |
| 230 monster->SetCookie(GURL("http://foo1"), "B=1"); | |
| 231 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 232 monster->SetCookie(GURL("http://foo1"), "E=1"); | |
| 233 monster->SetCookie(GURL("http://foo2"), "G=1"); | |
| 234 monster->SetCookie(GURL("http://foo2"), "X=1"); | |
| 235 CookiesView cookies_view(NULL, | |
| 236 profile_.get(), | |
| 237 mock_browsing_data_database_helper_, | |
| 238 mock_browsing_data_local_storage_helper_, | |
| 239 mock_browsing_data_appcache_helper_, | |
| 240 mock_browsing_data_indexed_db_helper_); | |
| 241 cookies_view.TestDestroySynchronously(); | |
| 242 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 243 mock_browsing_data_database_helper_->Notify(); | |
| 244 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 245 mock_browsing_data_local_storage_helper_->Notify(); | |
| 246 EXPECT_STREQ("foo0,_Cookies,__C,__D," | |
| 247 "foo1,_Cookies,__A,__B,__E," | |
| 248 "foo2,_Cookies,__G,__X," | |
| 249 "gdbhost1,_Web Databases,__db1," | |
| 250 "gdbhost2,_Web Databases,__db2," | |
| 251 "host1,_Local Storage,__http://host1:1/," | |
| 252 "host2,_Local Storage,__http://host2:2/", | |
| 253 GetDisplayedCookies(cookies_view).c_str()); | |
| 254 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 255 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 256 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 257 } | |
| 258 | |
| 259 TEST_F(CookiesViewTest, RemoveAll) { | |
| 260 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 261 monster->SetCookie(GURL("http://foo"), "A=1"); | |
| 262 monster->SetCookie(GURL("http://foo2"), "B=1"); | |
| 263 CookiesView cookies_view(NULL, | |
| 264 profile_.get(), | |
| 265 mock_browsing_data_database_helper_, | |
| 266 mock_browsing_data_local_storage_helper_, | |
| 267 mock_browsing_data_appcache_helper_, | |
| 268 mock_browsing_data_indexed_db_helper_); | |
| 269 cookies_view.TestDestroySynchronously(); | |
| 270 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 271 mock_browsing_data_database_helper_->Notify(); | |
| 272 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 273 mock_browsing_data_local_storage_helper_->Notify(); | |
| 274 | |
| 275 // Reset the selection of the first row. | |
| 276 gtk_tree_selection_unselect_all(cookies_view.selection_); | |
| 277 | |
| 278 { | |
| 279 SCOPED_TRACE("Before removing"); | |
| 280 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 281 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 282 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 283 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," | |
| 284 "gdbhost1,_Web Databases,__db1," | |
| 285 "gdbhost2,_Web Databases,__db2," | |
| 286 "host1,_Local Storage,__http://host1:1/," | |
| 287 "host2,_Local Storage,__http://host2:2/", | |
| 288 GetDisplayedCookies(cookies_view).c_str()); | |
| 289 } | |
| 290 | |
| 291 mock_browsing_data_database_helper_->Reset(); | |
| 292 mock_browsing_data_local_storage_helper_->Reset(); | |
| 293 | |
| 294 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); | |
| 295 { | |
| 296 SCOPED_TRACE("After removing"); | |
| 297 EXPECT_EQ(0u, monster->GetAllCookies().size()); | |
| 298 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 299 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 300 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 301 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | |
| 302 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); | |
| 303 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); | |
| 304 } | |
| 305 } | |
| 306 | |
| 307 TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) { | |
| 308 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 309 monster->SetCookie(GURL("http://foo"), "A=1"); | |
| 310 monster->SetCookie(GURL("http://foo2"), "B=1"); | |
| 311 CookiesView cookies_view(NULL, | |
| 312 profile_.get(), | |
| 313 mock_browsing_data_database_helper_, | |
| 314 mock_browsing_data_local_storage_helper_, | |
| 315 mock_browsing_data_appcache_helper_, | |
| 316 mock_browsing_data_indexed_db_helper_); | |
| 317 cookies_view.TestDestroySynchronously(); | |
| 318 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 319 mock_browsing_data_database_helper_->Notify(); | |
| 320 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 321 mock_browsing_data_local_storage_helper_->Notify(); | |
| 322 | |
| 323 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | |
| 324 EXPECT_EQ(1, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); | |
| 325 { | |
| 326 SCOPED_TRACE("Before removing"); | |
| 327 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 328 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 329 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 330 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," | |
| 331 "gdbhost1,_Web Databases,__db1," | |
| 332 "gdbhost2,_Web Databases,__db2," | |
| 333 "host1,_Local Storage,__http://host1:1/," | |
| 334 "host2,_Local Storage,__http://host2:2/", | |
| 335 GetDisplayedCookies(cookies_view).c_str()); | |
| 336 } | |
| 337 | |
| 338 mock_browsing_data_database_helper_->Reset(); | |
| 339 mock_browsing_data_local_storage_helper_->Reset(); | |
| 340 | |
| 341 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); | |
| 342 { | |
| 343 SCOPED_TRACE("After removing"); | |
| 344 EXPECT_EQ(0u, monster->GetAllCookies().size()); | |
| 345 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 346 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 347 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 348 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | |
| 349 EXPECT_EQ(0, | |
| 350 gtk_tree_selection_count_selected_rows(cookies_view.selection_)); | |
| 351 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); | |
| 352 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); | |
| 353 } | |
| 354 } | |
| 355 | |
| 356 TEST_F(CookiesViewTest, Remove) { | |
| 357 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 358 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 359 monster->SetCookie(GURL("http://foo2"), "B=1"); | |
| 360 monster->SetCookie(GURL("http://foo2"), "C=1"); | |
| 361 CookiesView cookies_view(NULL, | |
| 362 profile_.get(), | |
| 363 mock_browsing_data_database_helper_, | |
| 364 mock_browsing_data_local_storage_helper_, | |
| 365 mock_browsing_data_appcache_helper_, | |
| 366 mock_browsing_data_indexed_db_helper_); | |
| 367 cookies_view.TestDestroySynchronously(); | |
| 368 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 369 mock_browsing_data_database_helper_->Notify(); | |
| 370 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 371 mock_browsing_data_local_storage_helper_->Notify(); | |
| 372 | |
| 373 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | |
| 374 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); | |
| 375 | |
| 376 { | |
| 377 SCOPED_TRACE("First selection"); | |
| 378 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 379 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 380 CheckDetailsSensitivity(TRUE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 381 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C," | |
| 382 "gdbhost1,_Web Databases,__db1," | |
| 383 "gdbhost2,_Web Databases,__db2," | |
| 384 "host1,_Local Storage,__http://host1:1/," | |
| 385 "host2,_Local Storage,__http://host2:2/", | |
| 386 GetDisplayedCookies(cookies_view).c_str()); | |
| 387 } | |
| 388 | |
| 389 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 390 | |
| 391 { | |
| 392 SCOPED_TRACE("First selection removed"); | |
| 393 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | |
| 394 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C," | |
| 395 "gdbhost1,_Web Databases,__db1," | |
| 396 "gdbhost2,_Web Databases,__db2," | |
| 397 "host1,_Local Storage,__http://host1:1/," | |
| 398 "host2,_Local Storage,__http://host2:2/", | |
| 399 GetDisplayedCookies(cookies_view).c_str()); | |
| 400 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 401 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 402 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); | |
| 403 CheckDetailsSensitivity(TRUE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 404 } | |
| 405 | |
| 406 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 407 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 408 | |
| 409 { | |
| 410 SCOPED_TRACE("Second selection"); | |
| 411 EXPECT_STREQ("A", GetMonsterCookies(monster).c_str()); | |
| 412 EXPECT_STREQ("foo1,_Cookies,__A," | |
| 413 "gdbhost1,_Web Databases,__db1," | |
| 414 "gdbhost2,_Web Databases,__db2," | |
| 415 "host1,_Local Storage,__http://host1:1/," | |
| 416 "host2,_Local Storage,__http://host2:2/", | |
| 417 GetDisplayedCookies(cookies_view).c_str()); | |
| 418 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 419 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 420 EXPECT_STREQ("", GetSelectedPath(cookies_view).c_str()); | |
| 421 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 422 } | |
| 423 | |
| 424 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | |
| 425 EXPECT_STREQ("foo1,+Cookies,++A," | |
| 426 "gdbhost1,_Web Databases,__db1," | |
| 427 "gdbhost2,_Web Databases,__db2," | |
| 428 "host1,_Local Storage,__http://host1:1/," | |
| 429 "host2,_Local Storage,__http://host2:2/", | |
| 430 GetDisplayedCookies(cookies_view).c_str()); | |
| 431 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); | |
| 432 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 433 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 434 | |
| 435 { | |
| 436 SCOPED_TRACE("Second selection removed"); | |
| 437 EXPECT_EQ(0u, monster->GetAllCookies().size()); | |
| 438 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 439 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 440 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 441 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 442 "gdbhost2,_Web Databases,__db2," | |
| 443 "host1,_Local Storage,__http://host1:1/," | |
| 444 "host2,_Local Storage,__http://host2:2/", | |
| 445 GetDisplayedCookies(cookies_view).c_str()); | |
| 446 } | |
| 447 | |
| 448 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | |
| 449 EXPECT_STREQ("gdbhost1,+Web Databases,++db1," | |
| 450 "gdbhost2,_Web Databases,__db2," | |
| 451 "host1,_Local Storage,__http://host1:1/," | |
| 452 "host2,_Local Storage,__http://host2:2/", | |
| 453 GetDisplayedCookies(cookies_view).c_str()); | |
| 454 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); | |
| 455 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 456 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 457 | |
| 458 { | |
| 459 SCOPED_TRACE("Third selection removed"); | |
| 460 EXPECT_EQ(0u, monster->GetAllCookies().size()); | |
| 461 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 462 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 463 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 464 EXPECT_STREQ("gdbhost2,_Web Databases,__db2," | |
| 465 "host1,_Local Storage,__http://host1:1/," | |
| 466 "host2,_Local Storage,__http://host2:2/", | |
| 467 GetDisplayedCookies(cookies_view).c_str()); | |
| 468 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == | |
| 469 "http_gdbhost1_1"); | |
| 470 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == | |
| 471 "db1"); | |
| 472 } | |
| 473 | |
| 474 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | |
| 475 EXPECT_STREQ("gdbhost2,_Web Databases,__db2," | |
| 476 "host1,+Local Storage,++http://host1:1/," | |
| 477 "host2,_Local Storage,__http://host2:2/", | |
| 478 GetDisplayedCookies(cookies_view).c_str()); | |
| 479 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); | |
| 480 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 481 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 482 | |
| 483 { | |
| 484 SCOPED_TRACE("Fourth selection removed"); | |
| 485 EXPECT_EQ(0u, monster->GetAllCookies().size()); | |
| 486 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 487 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 488 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 489 EXPECT_STREQ("gdbhost2,_Web Databases,__db2," | |
| 490 "host2,_Local Storage,__http://host2:2/", | |
| 491 GetDisplayedCookies(cookies_view).c_str()); | |
| 492 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == | |
| 493 FilePath(FILE_PATH_LITERAL("file1"))); | |
| 494 } | |
| 495 } | |
| 496 | |
| 497 TEST_F(CookiesViewTest, RemoveCookiesByType) { | |
| 498 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 499 monster->SetCookie(GURL("http://foo0"), "C=1"); | |
| 500 monster->SetCookie(GURL("http://foo0"), "D=1"); | |
| 501 monster->SetCookie(GURL("http://foo1"), "B=1"); | |
| 502 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 503 monster->SetCookie(GURL("http://foo1"), "E=1"); | |
| 504 monster->SetCookie(GURL("http://foo2"), "G=1"); | |
| 505 monster->SetCookie(GURL("http://foo2"), "X=1"); | |
| 506 CookiesView cookies_view(NULL, | |
| 507 profile_.get(), | |
| 508 mock_browsing_data_database_helper_, | |
| 509 mock_browsing_data_local_storage_helper_, | |
| 510 mock_browsing_data_appcache_helper_, | |
| 511 mock_browsing_data_indexed_db_helper_); | |
| 512 cookies_view.TestDestroySynchronously(); | |
| 513 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 514 mock_browsing_data_database_helper_->Notify(); | |
| 515 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 516 mock_browsing_data_local_storage_helper_->Notify(); | |
| 517 | |
| 518 EXPECT_STREQ("foo0,_Cookies,__C,__D," | |
| 519 "foo1,_Cookies,__A,__B,__E," | |
| 520 "foo2,_Cookies,__G,__X," | |
| 521 "gdbhost1,_Web Databases,__db1," | |
| 522 "gdbhost2,_Web Databases,__db2," | |
| 523 "host1,_Local Storage,__http://host1:1/," | |
| 524 "host2,_Local Storage,__http://host2:2/", | |
| 525 GetDisplayedCookies(cookies_view).c_str()); | |
| 526 | |
| 527 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | |
| 528 EXPECT_STREQ("foo0,_Cookies,__C,__D," | |
| 529 "foo1,+Cookies,++A,++B,++E," | |
| 530 "foo2,_Cookies,__G,__X," | |
| 531 "gdbhost1,_Web Databases,__db1," | |
| 532 "gdbhost2,_Web Databases,__db2," | |
| 533 "host1,_Local Storage,__http://host1:1/," | |
| 534 "host2,_Local Storage,__http://host2:2/", | |
| 535 GetDisplayedCookies(cookies_view).c_str()); | |
| 536 ASSERT_TRUE(SelectByPath(cookies_view, "1:0")); | |
| 537 | |
| 538 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 539 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 540 | |
| 541 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 542 | |
| 543 EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); | |
| 544 EXPECT_STREQ("foo0,_Cookies,__C,__D," | |
| 545 "foo2,_Cookies,__G,__X," | |
| 546 "gdbhost1,_Web Databases,__db1," | |
| 547 "gdbhost2,_Web Databases,__db2," | |
| 548 "host1,_Local Storage,__http://host1:1/," | |
| 549 "host2,_Local Storage,__http://host2:2/", | |
| 550 GetDisplayedCookies(cookies_view).c_str()); | |
| 551 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 552 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 553 | |
| 554 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | |
| 555 EXPECT_STREQ("foo0,+Cookies,++C,++D," | |
| 556 "foo2,_Cookies,__G,__X," | |
| 557 "gdbhost1,_Web Databases,__db1," | |
| 558 "gdbhost2,_Web Databases,__db2," | |
| 559 "host1,_Local Storage,__http://host1:1/," | |
| 560 "host2,_Local Storage,__http://host2:2/", | |
| 561 GetDisplayedCookies(cookies_view).c_str()); | |
| 562 ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); | |
| 563 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 564 | |
| 565 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); | |
| 566 EXPECT_STREQ("foo2,_Cookies,__G,__X," | |
| 567 "gdbhost1,_Web Databases,__db1," | |
| 568 "gdbhost2,_Web Databases,__db2," | |
| 569 "host1,_Local Storage,__http://host1:1/," | |
| 570 "host2,_Local Storage,__http://host2:2/", | |
| 571 GetDisplayedCookies(cookies_view).c_str()); | |
| 572 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 573 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 574 | |
| 575 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | |
| 576 EXPECT_STREQ("foo2,+Cookies,++G,++X," | |
| 577 "gdbhost1,_Web Databases,__db1," | |
| 578 "gdbhost2,_Web Databases,__db2," | |
| 579 "host1,_Local Storage,__http://host1:1/," | |
| 580 "host2,_Local Storage,__http://host2:2/", | |
| 581 GetDisplayedCookies(cookies_view).c_str()); | |
| 582 ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); | |
| 583 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 584 | |
| 585 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 586 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 587 "gdbhost2,_Web Databases,__db2," | |
| 588 "host1,_Local Storage,__http://host1:1/," | |
| 589 "host2,_Local Storage,__http://host2:2/", | |
| 590 GetDisplayedCookies(cookies_view).c_str()); | |
| 591 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 592 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 593 | |
| 594 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | |
| 595 EXPECT_STREQ("gdbhost1,+Web Databases,++db1," | |
| 596 "gdbhost2,_Web Databases,__db2," | |
| 597 "host1,_Local Storage,__http://host1:1/," | |
| 598 "host2,_Local Storage,__http://host2:2/", | |
| 599 GetDisplayedCookies(cookies_view).c_str()); | |
| 600 ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); | |
| 601 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 602 | |
| 603 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 604 EXPECT_STREQ("gdbhost2,_Web Databases,__db2," | |
| 605 "host1,_Local Storage,__http://host1:1/," | |
| 606 "host2,_Local Storage,__http://host2:2/", | |
| 607 GetDisplayedCookies(cookies_view).c_str()); | |
| 608 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 609 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 610 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == | |
| 611 "http_gdbhost1_1"); | |
| 612 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == | |
| 613 "db1"); | |
| 614 | |
| 615 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | |
| 616 EXPECT_STREQ("gdbhost2,_Web Databases,__db2," | |
| 617 "host1,+Local Storage,++http://host1:1/," | |
| 618 "host2,_Local Storage,__http://host2:2/", | |
| 619 GetDisplayedCookies(cookies_view).c_str()); | |
| 620 ASSERT_TRUE(SelectByPath(cookies_view, "1:0")); | |
| 621 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 622 | |
| 623 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 624 EXPECT_STREQ("gdbhost2,_Web Databases,__db2," | |
| 625 "host2,_Local Storage,__http://host2:2/", | |
| 626 GetDisplayedCookies(cookies_view).c_str()); | |
| 627 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 628 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 629 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == | |
| 630 FilePath(FILE_PATH_LITERAL("file1"))); | |
| 631 } | |
| 632 | |
| 633 TEST_F(CookiesViewTest, RemoveByDomain) { | |
| 634 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 635 monster->SetCookie(GURL("http://foo0"), "C=1"); | |
| 636 monster->SetCookie(GURL("http://foo0"), "D=1"); | |
| 637 monster->SetCookie(GURL("http://foo1"), "B=1"); | |
| 638 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 639 monster->SetCookie(GURL("http://foo1"), "E=1"); | |
| 640 monster->SetCookie(GURL("http://foo2"), "G=1"); | |
| 641 monster->SetCookie(GURL("http://foo2"), "X=1"); | |
| 642 CookiesView cookies_view(NULL, | |
| 643 profile_.get(), | |
| 644 mock_browsing_data_database_helper_, | |
| 645 mock_browsing_data_local_storage_helper_, | |
| 646 mock_browsing_data_appcache_helper_, | |
| 647 mock_browsing_data_indexed_db_helper_); | |
| 648 cookies_view.TestDestroySynchronously(); | |
| 649 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 650 mock_browsing_data_database_helper_->Notify(); | |
| 651 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 652 mock_browsing_data_local_storage_helper_->Notify(); | |
| 653 | |
| 654 EXPECT_STREQ("foo0,_Cookies,__C,__D," | |
| 655 "foo1,_Cookies,__A,__B,__E," | |
| 656 "foo2,_Cookies,__G,__X," | |
| 657 "gdbhost1,_Web Databases,__db1," | |
| 658 "gdbhost2,_Web Databases,__db2," | |
| 659 "host1,_Local Storage,__http://host1:1/," | |
| 660 "host2,_Local Storage,__http://host2:2/", | |
| 661 GetDisplayedCookies(cookies_view).c_str()); | |
| 662 | |
| 663 ASSERT_TRUE(SelectByPath(cookies_view, "1")); | |
| 664 | |
| 665 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 666 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 667 | |
| 668 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 669 | |
| 670 EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); | |
| 671 EXPECT_STREQ("foo0,_Cookies,__C,__D," | |
| 672 "foo2,_Cookies,__G,__X," | |
| 673 "gdbhost1,_Web Databases,__db1," | |
| 674 "gdbhost2,_Web Databases,__db2," | |
| 675 "host1,_Local Storage,__http://host1:1/," | |
| 676 "host2,_Local Storage,__http://host2:2/", | |
| 677 GetDisplayedCookies(cookies_view).c_str()); | |
| 678 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 679 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 680 EXPECT_STREQ("1", GetSelectedPath(cookies_view).c_str()); | |
| 681 | |
| 682 ASSERT_TRUE(SelectByPath(cookies_view, "0")); | |
| 683 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 684 | |
| 685 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); | |
| 686 EXPECT_STREQ("foo2,_Cookies,__G,__X," | |
| 687 "gdbhost1,_Web Databases,__db1," | |
| 688 "gdbhost2,_Web Databases,__db2," | |
| 689 "host1,_Local Storage,__http://host1:1/," | |
| 690 "host2,_Local Storage,__http://host2:2/", | |
| 691 GetDisplayedCookies(cookies_view).c_str()); | |
| 692 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 693 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 694 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | |
| 695 | |
| 696 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 697 | |
| 698 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 699 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 700 "gdbhost2,_Web Databases,__db2," | |
| 701 "host1,_Local Storage,__http://host1:1/," | |
| 702 "host2,_Local Storage,__http://host2:2/", | |
| 703 GetDisplayedCookies(cookies_view).c_str()); | |
| 704 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 705 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 706 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | |
| 707 | |
| 708 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 709 | |
| 710 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 711 EXPECT_STREQ("gdbhost2,_Web Databases,__db2," | |
| 712 "host1,_Local Storage,__http://host1:1/," | |
| 713 "host2,_Local Storage,__http://host2:2/", | |
| 714 GetDisplayedCookies(cookies_view).c_str()); | |
| 715 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 716 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 717 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == | |
| 718 "http_gdbhost1_1"); | |
| 719 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == | |
| 720 "db1"); | |
| 721 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | |
| 722 | |
| 723 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 724 | |
| 725 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 726 EXPECT_STREQ("host1,_Local Storage,__http://host1:1/," | |
| 727 "host2,_Local Storage,__http://host2:2/", | |
| 728 GetDisplayedCookies(cookies_view).c_str()); | |
| 729 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 730 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 731 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == | |
| 732 "http_gdbhost2_2"); | |
| 733 EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_db_ == | |
| 734 "db2"); | |
| 735 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | |
| 736 | |
| 737 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 738 | |
| 739 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 740 EXPECT_STREQ("host2,_Local Storage,__http://host2:2/", | |
| 741 GetDisplayedCookies(cookies_view).c_str()); | |
| 742 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 743 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 744 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == | |
| 745 FilePath(FILE_PATH_LITERAL("file1"))); | |
| 746 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | |
| 747 | |
| 748 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 749 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 750 EXPECT_STREQ("", | |
| 751 GetDisplayedCookies(cookies_view).c_str()); | |
| 752 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 753 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 754 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == | |
| 755 FilePath(FILE_PATH_LITERAL("file2"))); | |
| 756 | |
| 757 EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); | |
| 758 } | |
| 759 | |
| 760 TEST_F(CookiesViewTest, RemoveDefaultSelection) { | |
| 761 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 762 monster->SetCookie(GURL("http://foo0"), "C=1"); | |
| 763 monster->SetCookie(GURL("http://foo0"), "D=1"); | |
| 764 monster->SetCookie(GURL("http://foo1"), "B=1"); | |
| 765 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 766 monster->SetCookie(GURL("http://foo1"), "E=1"); | |
| 767 monster->SetCookie(GURL("http://foo2"), "G=1"); | |
| 768 monster->SetCookie(GURL("http://foo2"), "X=1"); | |
| 769 CookiesView cookies_view(NULL, | |
| 770 profile_.get(), | |
| 771 mock_browsing_data_database_helper_, | |
| 772 mock_browsing_data_local_storage_helper_, | |
| 773 mock_browsing_data_appcache_helper_, | |
| 774 mock_browsing_data_indexed_db_helper_); | |
| 775 cookies_view.TestDestroySynchronously(); | |
| 776 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 777 mock_browsing_data_database_helper_->Notify(); | |
| 778 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 779 mock_browsing_data_local_storage_helper_->Notify(); | |
| 780 | |
| 781 EXPECT_STREQ("foo0,_Cookies,__C,__D," | |
| 782 "foo1,_Cookies,__A,__B,__E," | |
| 783 "foo2,_Cookies,__G,__X," | |
| 784 "gdbhost1,_Web Databases,__db1," | |
| 785 "gdbhost2,_Web Databases,__db2," | |
| 786 "host1,_Local Storage,__http://host1:1/," | |
| 787 "host2,_Local Storage,__http://host2:2/", | |
| 788 GetDisplayedCookies(cookies_view).c_str()); | |
| 789 | |
| 790 | |
| 791 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 792 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 793 | |
| 794 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 795 | |
| 796 EXPECT_STREQ("B,A,E,G,X", GetMonsterCookies(monster).c_str()); | |
| 797 EXPECT_STREQ("foo1,_Cookies,__A,__B,__E," | |
| 798 "foo2,_Cookies,__G,__X," | |
| 799 "gdbhost1,_Web Databases,__db1," | |
| 800 "gdbhost2,_Web Databases,__db2," | |
| 801 "host1,_Local Storage,__http://host1:1/," | |
| 802 "host2,_Local Storage,__http://host2:2/", | |
| 803 GetDisplayedCookies(cookies_view).c_str()); | |
| 804 | |
| 805 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 806 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 807 | |
| 808 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 809 | |
| 810 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); | |
| 811 EXPECT_STREQ("foo2,_Cookies,__G,__X," | |
| 812 "gdbhost1,_Web Databases,__db1," | |
| 813 "gdbhost2,_Web Databases,__db2," | |
| 814 "host1,_Local Storage,__http://host1:1/," | |
| 815 "host2,_Local Storage,__http://host2:2/", | |
| 816 GetDisplayedCookies(cookies_view).c_str()); | |
| 817 | |
| 818 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 819 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 820 | |
| 821 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 822 | |
| 823 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 824 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 825 "gdbhost2,_Web Databases,__db2," | |
| 826 "host1,_Local Storage,__http://host1:1/," | |
| 827 "host2,_Local Storage,__http://host2:2/", | |
| 828 GetDisplayedCookies(cookies_view).c_str()); | |
| 829 | |
| 830 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 831 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 832 | |
| 833 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 834 | |
| 835 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 836 EXPECT_STREQ("gdbhost2,_Web Databases,__db2," | |
| 837 "host1,_Local Storage,__http://host1:1/," | |
| 838 "host2,_Local Storage,__http://host2:2/", | |
| 839 GetDisplayedCookies(cookies_view).c_str()); | |
| 840 | |
| 841 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 842 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 843 | |
| 844 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 845 | |
| 846 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 847 EXPECT_STREQ("host1,_Local Storage,__http://host1:1/," | |
| 848 "host2,_Local Storage,__http://host2:2/", | |
| 849 GetDisplayedCookies(cookies_view).c_str()); | |
| 850 | |
| 851 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 852 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 853 | |
| 854 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 855 | |
| 856 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 857 EXPECT_STREQ("host2,_Local Storage,__http://host2:2/", | |
| 858 GetDisplayedCookies(cookies_view).c_str()); | |
| 859 | |
| 860 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 861 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 862 | |
| 863 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 864 | |
| 865 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 866 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | |
| 867 | |
| 868 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 869 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 870 } | |
| 871 | |
| 872 TEST_F(CookiesViewTest, Filter) { | |
| 873 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 874 monster->SetCookie(GURL("http://foo0"), "C=1"); | |
| 875 monster->SetCookie(GURL("http://bar0"), "D=1"); | |
| 876 monster->SetCookie(GURL("http://foo1"), "B=1"); | |
| 877 monster->SetCookie(GURL("http://bar1"), "A=1"); | |
| 878 CookiesView cookies_view(NULL, | |
| 879 profile_.get(), | |
| 880 mock_browsing_data_database_helper_, | |
| 881 mock_browsing_data_local_storage_helper_, | |
| 882 mock_browsing_data_appcache_helper_, | |
| 883 mock_browsing_data_indexed_db_helper_); | |
| 884 cookies_view.TestDestroySynchronously(); | |
| 885 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 886 mock_browsing_data_database_helper_->Notify(); | |
| 887 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 888 mock_browsing_data_local_storage_helper_->Notify(); | |
| 889 | |
| 890 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 891 "bar1,_Cookies,__A," | |
| 892 "foo0,_Cookies,__C," | |
| 893 "foo1,_Cookies,__B," | |
| 894 "gdbhost1,_Web Databases,__db1," | |
| 895 "gdbhost2,_Web Databases,__db2," | |
| 896 "host1,_Local Storage,__http://host1:1/," | |
| 897 "host2,_Local Storage,__http://host2:2/", | |
| 898 GetDisplayedCookies(cookies_view).c_str()); | |
| 899 | |
| 900 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 901 | |
| 902 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); | |
| 903 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 904 // Entering text doesn't immediately filter the results. | |
| 905 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 906 "bar1,_Cookies,__A," | |
| 907 "foo0,_Cookies,__C," | |
| 908 "foo1,_Cookies,__B," | |
| 909 "gdbhost1,_Web Databases,__db1," | |
| 910 "gdbhost2,_Web Databases,__db2," | |
| 911 "host1,_Local Storage,__http://host1:1/," | |
| 912 "host2,_Local Storage,__http://host2:2/", | |
| 913 GetDisplayedCookies(cookies_view).c_str()); | |
| 914 | |
| 915 // Results are filtered immediately if you activate (hit enter in the entry). | |
| 916 gtk_widget_activate(cookies_view.filter_entry_); | |
| 917 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 918 "bar1,_Cookies,__A", | |
| 919 GetDisplayedCookies(cookies_view).c_str()); | |
| 920 | |
| 921 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); | |
| 922 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 923 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); | |
| 924 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 925 "bar1,_Cookies,__A," | |
| 926 "foo0,_Cookies,__C," | |
| 927 "foo1,_Cookies,__B," | |
| 928 "gdbhost1,_Web Databases,__db1," | |
| 929 "gdbhost2,_Web Databases,__db2," | |
| 930 "host1,_Local Storage,__http://host1:1/," | |
| 931 "host2,_Local Storage,__http://host2:2/", | |
| 932 GetDisplayedCookies(cookies_view).c_str()); | |
| 933 | |
| 934 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos"); | |
| 935 gtk_widget_activate(cookies_view.filter_entry_); | |
| 936 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 937 "gdbhost2,_Web Databases,__db2," | |
| 938 "host1,_Local Storage,__http://host1:1/," | |
| 939 "host2,_Local Storage,__http://host2:2/", | |
| 940 GetDisplayedCookies(cookies_view).c_str()); | |
| 941 } | |
| 942 | |
| 943 TEST_F(CookiesViewTest, FilterRemoveAll) { | |
| 944 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 945 monster->SetCookie(GURL("http://foo0"), "C=1"); | |
| 946 monster->SetCookie(GURL("http://bar0"), "D=1"); | |
| 947 monster->SetCookie(GURL("http://foo1"), "B=1"); | |
| 948 monster->SetCookie(GURL("http://bar1"), "A=1"); | |
| 949 CookiesView cookies_view(NULL, | |
| 950 profile_.get(), | |
| 951 mock_browsing_data_database_helper_, | |
| 952 mock_browsing_data_local_storage_helper_, | |
| 953 mock_browsing_data_appcache_helper_, | |
| 954 mock_browsing_data_indexed_db_helper_); | |
| 955 cookies_view.TestDestroySynchronously(); | |
| 956 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 957 mock_browsing_data_database_helper_->Notify(); | |
| 958 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 959 mock_browsing_data_local_storage_helper_->Notify(); | |
| 960 | |
| 961 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 962 "bar1,_Cookies,__A," | |
| 963 "foo0,_Cookies,__C," | |
| 964 "foo1,_Cookies,__B," | |
| 965 "gdbhost1,_Web Databases,__db1," | |
| 966 "gdbhost2,_Web Databases,__db2," | |
| 967 "host1,_Local Storage,__http://host1:1/," | |
| 968 "host2,_Local Storage,__http://host2:2/", | |
| 969 GetDisplayedCookies(cookies_view).c_str()); | |
| 970 | |
| 971 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 972 | |
| 973 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); | |
| 974 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 975 // Entering text doesn't immediately filter the results. | |
| 976 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 977 "bar1,_Cookies,__A," | |
| 978 "foo0,_Cookies,__C," | |
| 979 "foo1,_Cookies,__B," | |
| 980 "gdbhost1,_Web Databases,__db1," | |
| 981 "gdbhost2,_Web Databases,__db2," | |
| 982 "host1,_Local Storage,__http://host1:1/," | |
| 983 "host2,_Local Storage,__http://host2:2/", | |
| 984 GetDisplayedCookies(cookies_view).c_str()); | |
| 985 | |
| 986 // Results are filtered immediately if you activate (hit enter in the entry). | |
| 987 gtk_widget_activate(cookies_view.filter_entry_); | |
| 988 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 989 "bar1,_Cookies,__A", | |
| 990 GetDisplayedCookies(cookies_view).c_str()); | |
| 991 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 992 | |
| 993 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); | |
| 994 | |
| 995 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 996 EXPECT_STREQ("", | |
| 997 GetDisplayedCookies(cookies_view).c_str()); | |
| 998 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 999 | |
| 1000 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); | |
| 1001 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 1002 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); | |
| 1003 EXPECT_STREQ("foo0,_Cookies,__C," | |
| 1004 "foo1,_Cookies,__B," | |
| 1005 "gdbhost1,_Web Databases,__db1," | |
| 1006 "gdbhost2,_Web Databases,__db2," | |
| 1007 "host1,_Local Storage,__http://host1:1/," | |
| 1008 "host2,_Local Storage,__http://host2:2/", | |
| 1009 GetDisplayedCookies(cookies_view).c_str()); | |
| 1010 } | |
| 1011 | |
| 1012 TEST_F(CookiesViewTest, FilterRemove) { | |
| 1013 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 1014 monster->SetCookie(GURL("http://foo0"), "C=1"); | |
| 1015 monster->SetCookie(GURL("http://bar0"), "D=1"); | |
| 1016 monster->SetCookie(GURL("http://foo1"), "B=1"); | |
| 1017 monster->SetCookie(GURL("http://bar1"), "A=1"); | |
| 1018 monster->SetCookie(GURL("http://bar1"), "E=1"); | |
| 1019 CookiesView cookies_view(NULL, | |
| 1020 profile_.get(), | |
| 1021 mock_browsing_data_database_helper_, | |
| 1022 mock_browsing_data_local_storage_helper_, | |
| 1023 mock_browsing_data_appcache_helper_, | |
| 1024 mock_browsing_data_indexed_db_helper_); | |
| 1025 cookies_view.TestDestroySynchronously(); | |
| 1026 mock_browsing_data_database_helper_->AddDatabaseSamples(); | |
| 1027 mock_browsing_data_database_helper_->Notify(); | |
| 1028 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | |
| 1029 mock_browsing_data_local_storage_helper_->Notify(); | |
| 1030 | |
| 1031 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 1032 "bar1,_Cookies,__A,__E," | |
| 1033 "foo0,_Cookies,__C," | |
| 1034 "foo1,_Cookies,__B," | |
| 1035 "gdbhost1,_Web Databases,__db1," | |
| 1036 "gdbhost2,_Web Databases,__db2," | |
| 1037 "host1,_Local Storage,__http://host1:1/," | |
| 1038 "host2,_Local Storage,__http://host2:2/", | |
| 1039 GetDisplayedCookies(cookies_view).c_str()); | |
| 1040 // All default paths; order will be creation time. | |
| 1041 EXPECT_STREQ("C,D,B,A,E", GetMonsterCookies(monster).c_str()); | |
| 1042 | |
| 1043 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 1044 | |
| 1045 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); | |
| 1046 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 1047 // Entering text doesn't immediately filter the results. | |
| 1048 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 1049 "bar1,_Cookies,__A,__E," | |
| 1050 "foo0,_Cookies,__C," | |
| 1051 "foo1,_Cookies,__B," | |
| 1052 "gdbhost1,_Web Databases,__db1," | |
| 1053 "gdbhost2,_Web Databases,__db2," | |
| 1054 "host1,_Local Storage,__http://host1:1/," | |
| 1055 "host2,_Local Storage,__http://host2:2/", | |
| 1056 GetDisplayedCookies(cookies_view).c_str()); | |
| 1057 | |
| 1058 // Results are filtered immediately if you activate (hit enter in the entry). | |
| 1059 gtk_widget_activate(cookies_view.filter_entry_); | |
| 1060 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 1061 "bar1,_Cookies,__A,__E", | |
| 1062 GetDisplayedCookies(cookies_view).c_str()); | |
| 1063 | |
| 1064 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | |
| 1065 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 1066 "bar1,+Cookies,++A,++E", | |
| 1067 GetDisplayedCookies(cookies_view).c_str()); | |
| 1068 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); | |
| 1069 | |
| 1070 { | |
| 1071 SCOPED_TRACE("First selection"); | |
| 1072 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 1073 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1074 CheckDetailsSensitivity(TRUE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 1075 } | |
| 1076 | |
| 1077 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 1078 | |
| 1079 { | |
| 1080 SCOPED_TRACE("First selection removed"); | |
| 1081 EXPECT_STREQ("C,D,B,E", GetMonsterCookies(monster).c_str()); | |
| 1082 EXPECT_STREQ("bar0,_Cookies,__D," | |
| 1083 "bar1,+Cookies,++E", | |
| 1084 GetDisplayedCookies(cookies_view).c_str()); | |
| 1085 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 1086 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1087 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); | |
| 1088 CheckDetailsSensitivity(TRUE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 1089 } | |
| 1090 | |
| 1091 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 1092 | |
| 1093 { | |
| 1094 SCOPED_TRACE("Second selection"); | |
| 1095 EXPECT_STREQ("C,D,B", GetMonsterCookies(monster).c_str()); | |
| 1096 EXPECT_STREQ("bar0,_Cookies,__D", | |
| 1097 GetDisplayedCookies(cookies_view).c_str()); | |
| 1098 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 1099 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1100 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 1101 } | |
| 1102 | |
| 1103 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | |
| 1104 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); | |
| 1105 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1106 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 1107 | |
| 1108 { | |
| 1109 SCOPED_TRACE("Second selection removed"); | |
| 1110 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); | |
| 1111 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 1112 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1113 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 1114 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | |
| 1115 } | |
| 1116 | |
| 1117 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); | |
| 1118 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 1119 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); | |
| 1120 EXPECT_STREQ("foo0,_Cookies,__C," | |
| 1121 "foo1,_Cookies,__B," | |
| 1122 "gdbhost1,_Web Databases,__db1," | |
| 1123 "gdbhost2,_Web Databases,__db2," | |
| 1124 "host1,_Local Storage,__http://host1:1/," | |
| 1125 "host2,_Local Storage,__http://host2:2/", | |
| 1126 GetDisplayedCookies(cookies_view).c_str()); | |
| 1127 | |
| 1128 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos"); | |
| 1129 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | |
| 1130 // Entering text doesn't immediately filter the results. | |
| 1131 EXPECT_STREQ("foo0,_Cookies,__C," | |
| 1132 "foo1,_Cookies,__B," | |
| 1133 "gdbhost1,_Web Databases,__db1," | |
| 1134 "gdbhost2,_Web Databases,__db2," | |
| 1135 "host1,_Local Storage,__http://host1:1/," | |
| 1136 "host2,_Local Storage,__http://host2:2/", | |
| 1137 GetDisplayedCookies(cookies_view).c_str()); | |
| 1138 | |
| 1139 // Results are filtered immediately if you activate (hit enter in the entry). | |
| 1140 gtk_widget_activate(cookies_view.filter_entry_); | |
| 1141 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 1142 "gdbhost2,_Web Databases,__db2," | |
| 1143 "host1,_Local Storage,__http://host1:1/," | |
| 1144 "host2,_Local Storage,__http://host2:2/", | |
| 1145 GetDisplayedCookies(cookies_view).c_str()); | |
| 1146 | |
| 1147 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | |
| 1148 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 1149 "gdbhost2,+Web Databases,++db2," | |
| 1150 "host1,_Local Storage,__http://host1:1/," | |
| 1151 "host2,_Local Storage,__http://host2:2/", | |
| 1152 GetDisplayedCookies(cookies_view).c_str()); | |
| 1153 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); | |
| 1154 | |
| 1155 { | |
| 1156 SCOPED_TRACE("First selection"); | |
| 1157 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 1158 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1159 CheckDetailsSensitivity(FALSE, TRUE, FALSE, FALSE, FALSE, cookies_view); | |
| 1160 } | |
| 1161 | |
| 1162 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 1163 | |
| 1164 { | |
| 1165 SCOPED_TRACE("First selection removed"); | |
| 1166 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); | |
| 1167 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 1168 "host1,_Local Storage,__http://host1:1/," | |
| 1169 "host2,_Local Storage,__http://host2:2/", | |
| 1170 GetDisplayedCookies(cookies_view).c_str()); | |
| 1171 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 1172 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1173 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 1174 } | |
| 1175 | |
| 1176 ASSERT_TRUE(ExpandByPath(cookies_view, "2")); | |
| 1177 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 1178 "host1,_Local Storage,__http://host1:1/," | |
| 1179 "host2,+Local Storage,++http://host2:2/", | |
| 1180 GetDisplayedCookies(cookies_view).c_str()); | |
| 1181 ASSERT_TRUE(SelectByPath(cookies_view, "2:0:0")); | |
| 1182 | |
| 1183 { | |
| 1184 SCOPED_TRACE("First selection"); | |
| 1185 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 1186 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1187 CheckDetailsSensitivity(FALSE, FALSE, TRUE, FALSE, FALSE, cookies_view); | |
| 1188 } | |
| 1189 | |
| 1190 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | |
| 1191 | |
| 1192 { | |
| 1193 SCOPED_TRACE("First selection removed"); | |
| 1194 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); | |
| 1195 EXPECT_STREQ("gdbhost1,_Web Databases,__db1," | |
| 1196 "host1,_Local Storage,__http://host1:1/", | |
| 1197 GetDisplayedCookies(cookies_view).c_str()); | |
| 1198 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | |
| 1199 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | |
| 1200 CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, FALSE, cookies_view); | |
| 1201 } | |
| 1202 } | |
| OLD | NEW |